var w=1080;
var h=700;
var h_min=700; w_min=1080;
var ml=40;
var mt=40;
var scale=0;
var menu=new Array("INFO", "CAMERE", "RISTORANTE", "PISCINA","GALLERY","DOVE SIAMO","UMBRIA","EVENTI");
var menu_src=new Array("", "images/ico/cam006.jpg", "images/ico/ris001.jpg", "images/ico/pis002.jpg","images/ico/gal009.jpg","images/ico/_illustrazione.jpg","images/ico/sanfrancesco.jpg","images/ico/calendimaggio.jpg");
var noFlash=false;

var menu_att=-1;
var icona_att=0
var email_click=0;
/// sezione   parametri Flash
		var flashvars = {};
		var params = {};
		params.allowscriptaccess = "sameDomain";
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "LeftFlash";
		swfobject.embedSWF("gallery.swf", "LeftFlash", "640", "500", "10.1.0", false, flashvars, params, attributes);
		var attributesTop = {};
		attributesTop.id = "TopFlash";
		swfobject.embedSWF("top.swf", "TopFlash", "440", "100", "10.1.0", false, flashvars, params, attributesTop);
		function getViewportSize() { 
			var size = [0, 0]; 
			if (typeof window.innerWidth != "undefined") { 
				size = [window.innerWidth, window.innerHeight];
			} 
			else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
				size = [document.documentElement.clientWidth, document.documentElement.clientHeight]; 
			}
			else {
				size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight]; 
			}
			return size; 
		}
		
function createFullBrowserFlash() {
			swfobject.createCSS("html", "height:100%;");
			swfobject.createCSS("body", "height:100%;");
			var n_w=0; var n_h=0; var n_mt=0; var n_ml=0; 
			var size = getViewportSize();
			if ((size[0]/size[1])>=(w/h)){	n_h=(((size[1]-ml-mt)>(h_min))?((size[1]-ml-mt)):(h_min));  n_w=n_h*(w/h); }
						else {  n_w=(((size[0]-ml-mt)>(w_min))?((size[0]-ml-mt)):(w_min));  n_h=n_w*(h/w); }
			
			
			var el = document.getElementById("Content");
			el.style.width = n_w+"px";
			el.style.height = n_h+"px";
			scale=w/n_w
			if (scale<=0.9){
				$(".button_orizzontale").css('width','110px');
			} else {$(".button_orizzontale").css('width','100px');}
			
			el.style.margin= "-"+(n_h/2)+"px 0 0 -"+(n_w/2)+"px";
			//alert("new_w="+n_w+"   new_h="+n_h+ " w="+size[0]+" h="+size[1] +" n_rap="+(n_w/n_h))
			resizeDiv();
			
	window.onresize = function() {
			
			var size = getViewportSize();
			if ((size[0]/size[1])>=(w/h)){	n_h=(((size[1]-ml-mt)>(h_min))?((size[1]-ml-mt)):(h_min));  n_w=n_h*(w/h); }
						else {  n_w=(((size[0]-ml-mt)>(w_min))?((size[0]-ml-mt)):(w_min));  n_h=n_w*(h/w); }
			scale=w/n_w;
			if (scale<=0.9){$(".button_orizzontale").css('width','110px');	
			} else {$(".button_orizzontale").css('width','100px');}
			
			var el = document.getElementById("Content");
			el.style.width = n_w+"px";
			el.style.height = n_h+"px";
			el.style.margin= "-"+(n_h/2)+"px 0 0 -"+(n_w/2)+"px";
			
			//$('#Control').html(size[1]);
			if (size[0]<=1096){$('#Content').css('left','540px');} else {$('#Content').css('left','50%');} ;
			if (size[1]<=700){$('#Content').css('top','350px');} else {$('#Content').css('top','50%');} ;
			resizeDiv();
			};
	
	window.onresize();
		}
			

	function resizeDiv(){
		
		if (!noFlash){
		$("#calroot").css('display','none');
		$("#menu_css_orizzontale").css('width',(1080/scale)+"px");
		$("#ButtonForm").css('margin-top',((350/scale)-345)+'px');	
		$("#sf_BR").css('margin-left',(640/scale)+'px').css('width',(440/scale)+'px');
		$(".dopo").css('margin-left',(640/scale)-((($(".dopo").width())*6)+20)+'px');
		$("#range .slider").css('height','400px');
		$("#maps").css('margin-top',(100/scale)).css('height',((400/scale)+"px")).css('width',((640/scale)+"px"));
		var el = document.getElementById("LeftFlash");
			el.style.width = (640/scale)+"px";
			el.style.height = (500/scale)+"px";
			
		el = document.getElementById("TopFlash");
			el.style.width = (440/scale)+"px";
			el.style.height = (100/scale)+"px";
			
		el = document.getElementById("Description");
			el.style.width = (440/scale)+"px";
			el.style.height = (400/scale)+"px";
		
		$("#pagine").css('margin-top',((42/38)*(350/scale)-386)+"px")
		if (typeof scr != 'undefined') {
		setTesto(testi[icona_att]);
		}
			
		el = document.getElementById("MenuDiv");
			el.style.width = (1080/scale)+"px";
			el.style.height = (200/scale)+"px";
		
		}
		}
		
		
		// Controllo  che ci sia la versione 10.1.0
if (swfobject.hasFlashPlayerVersion("10.1.0")) {
		swfobject.addDomLoadEvent(createFullBrowserFlash);
		} else {
		// No flash
			
		noFlash=true;
		
				
				
		$.ajax({
		type: "POST",
		url: "noflashcenter.php",
		success: function(risp){
			$("#LeftFlash").html(risp);
                 	  
		}
        	});
		$.ajax({
		type: "POST",
		url: "noflashtop.php",
		success: function(risp){
			$("#TopFlash").html(risp);  
		}
        	});
		
		window.onresize = function() {
		var size = getViewportSize();
		if (size[0]<=1096){$('#Content').css('left','540px');} else {$('#Content').css('left','50%');} ;
		if (size[1]<=700){$('#Content').css('top','350px');} else {$('#Content').css('top','50%');} ;
		}
		window.onresize();	
			
		}

	
