var modalBox;
var urlbase = '';

window.addEvent('domready', function(){

	initModalBox();
	
	//flash erin zetten
	var vars = {};
	var params = {scale:"noScale", salign:"lt", menu:"false"};
	var attributes = {id:"arsgrafisch", name:"mdwsite" };

	swfobject.embedSWF("ARS_base.swf", "flash", "990", "800", "7.0.19", "js/expressInstall.swf", vars, params, attributes);

});

var initModalBox = function(){

	modalBox = new mooFacebox({draggable: false});

}

var paperWeight = function(){

	modalBox.loading();
	modalBox.setTitle(null);

	new Request({
		url: 		'paperweight.html',
		method: 	'get',
		onSuccess: function(responseText, responseXML){
			modalBox.reveal(responseText);
		}
	}).send();
	
}

var initPaperWeightCalc = function(){
	
	var inputs = $$('#paperweight input');
	inputs.addEvent('keyup', function(){
	
		if(!this.hasClass('readonly')){
		
			this.value = this.value.replace(/[^0-9]/g, ''); 
			
			var width = $('fwidth').value.toInt() / 1000;
			var height = $('fheight').value.toInt() / 1000;
			var weight = $('fweight').value.toInt();
			var count = $('fcount').value.toInt();
			var totalweight = width * height * weight * count;
			
			if(NaN !== totalweight){
				$('ftotal1').set('text', Math.round(totalweight * 100) / 100);
				$('ftotal2').set('text', Math.round(totalweight) / 1000);
			}else{
				$('ftotal1').set('text', '');
				$('ftotal2').set('text', '');
			}
		}
		
	});
	
	$('fformat').addEvent('change', function(){
		
		var val = this.value.split('.');
		$('fwidth').value = val[0];
		$('fheight').value = val[1];
		
		$('fwidth').fireEvent('keyup');
		
	})
	
	$('fwidth').fireEvent('keyup');
	
}