resize = function() {
	var minH = 635;
	var minW = 980;
	var h = 635;
	var w = 980;
	var o = 'auto';
	var stageW = window.getScrollWidth();
	var stageH = window.getScrollHeight();
	if(stageW>minW && stageH>minH) {
		o = 'hidden';
	}
	if(stageW>minW) {
		w = "100%";
	}
	if(stageH>minH) {
		h = "100%";
	}
	$('page').setStyle('width',w);
	$('page').setStyle('height',h);
	$('page').setStyle('overflow','auto');
	$('html').setStyle('overflow',o);
}
startCheckResize = function() {
	if(!runningCheckResize) {
		runningCheckResize = true;
		var store = {oldWidth:window.getScrollWidth(),oldHeight:window.getScrollHeight()}
		intervalID = checkResize.periodical(300, store);
	}
}
checkResize = function() {
	var newWidth = window.getScrollWidth();
	var newHeight = window.getScrollHeight();
	if(newWidth==this.oldWidth && newHeight==this.oldHeight) {
		resize();
		$clear(intervalID);
		runningCheckResize = false;
	} else {
		this.oldWidth = newWidth;
		this.oldHeight = newHeight;
	}
}

getURLParam = function (name){
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec(window.location.href);
	if( results == null ) {
		return "";
	} else {
		return results[1];
	}
}


window.addEvent('domready', function(){
	var p = getURLParam("p");
	if(swfobject.getFlashPlayerVersion().major>6 && p!=1 && !DetectMobileQuick()) {
		$('html').setStyle('height','100%');
		$('html').setStyle('overflow','hidden');
		$('page').setStyle('height','100%');
		swfobject.embedSWF("website.swf", "flashContent", "100%", "100%", "9.0.0",  'expressinstall.swf', {location:window.location.href,page:page}, {bgcolor: '#ffffff', menu: 'false', wmode: 'opaque'}, {id: 'website'});
		runningCheckResize = false;
		resize();
		window.addEvent('resize',startCheckResize);	
	}
});



gotoPrint = function() {
	window.open("winprint","stampa.html");
}

openVideoHome = function() {
	Mediabox.open('popup_video_hp.html', 'videohome', '640 390');
}
openVideo1 = function() {
	Mediabox.open('popup_video_1.html', 'video1', '640 390');
}
openVideo2 = function() {
	Mediabox.open('popup_video_2.html', 'video2', '640 390');
}

