//Javascript
var siteVersion = "HTML"
var altezzaMinBase = 800, currAltezza_fl = 830;
var objFla;
var contenitore;
window.onresize = function(){
	if(siteVersion == "FLASH"){
		centraCnt();
	}
}
window.onscroll = function() {
	if(siteVersion == "FLASH"){
		var yyy = null
		yyy = document.getElementsByTagName("body")[0].scrollTop
		if(yyy == 0){
			yyy = document.getElementsByTagName("html")[0].scrollTop
		}
		//var yyy = contenitore.scrollHeight
		//var yyy = contenitore.scrollTop
		//alert(yyy)
		objFla.ricava_y(yyy);
	}
}
window.onload = function() {
	//scriviFlash();
}
/*
function y_cnt(){
	objFla.ricava_y(100);
}
*/
function flashResizer(h){
	if(h > altezzaMinBase){
		currAltezza_fl = h
	}else{
		currAltezza_fl = altezzaMinBase
	}
	centraCnt();
}
/*
function writeCSS(){
	if (screen.availWidth<800) {
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/palm.css\" />");
	} else {
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/acc.css\" />");
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/flash_stile.css\" />");
	}
}
*/
function centraCnt(){
	var myHeight, myWidth

	if( typeof( window.innerHeight ) == 'number' ) {
		myHeight = window.innerHeight;
		myWidth = window.innerWidth;
	} else if( document.documentElement && (document.documentElement.clientHeight ) ) {
		myHeight = document.documentElement.clientHeight;
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myHeight = document.body.clientHeight;
		myWidth = document.body.clientWidth;
	}
	objFla.finestraW_H(myWidth, myHeight);

	if(myHeight<=currAltezza_fl){
		myHeight=currAltezza_fl
	}	
	if(myWidth<=930){myWidth=930}
	document.getElementsByTagName("body")[0].style.height=myHeight+"px";//"100%";
	document.getElementsByTagName("body")[0].style.width=myWidth+ "px";//"100%";
	//var contenitore = document.getElementById('contenitoreTotale');
	contenitore.style.width = "100%";//myWidth+"px";
	contenitore.style.height = myHeight+"px";//
}
function scriviFlash(){
	
	
	
	contenitore = document.getElementById('contenitoreTotale');
	
	
	
	
	//var flashDiv = document.getElementById('contenitoreGen');
	var percorso = ""
	if(window.location.href != null){
		percorso = window.location.href
	}else{
		percorso = "/"
	}
	
	if (screen.availWidth<600) {
	
	document.write("<meta name=\"viewport\" content=\"width=420\" />");
	}else if(screen.availWidth<800) {
	document.write("<meta name=\"viewport\" content=\"width=800\" />");
		/*	document.getElementsByTagName("html")[0].style.backgroundColor="#002222";

			document.getElementsByTagName("html")[0].style.width="320px";
			document.getElementsByTagName("body")[0].style.width="100%";//"320px";//
			
			contenitore.style.width="100%";//"320px";
			contenitore.style.backgroundColor="#002200";
			*/
		/*	contenitore.style.display = "block";
			siteVersion = "HTML"
			*/
	} else {
			
		
		var usAg = navigator.userAgent.toLowerCase();
		if(( usAg.indexOf("googlebot") < 0 ) && ( usAg.indexOf("msnbot") < 0 ) && ( usAg.indexOf("slurp") < 0 )){
			
			var myHeight, myWidth
			if( typeof( window.innerHeight ) == 'number' ) {
				myHeight = window.innerHeight;
				myWidth = window.innerWidth;
			} else if( document.documentElement && (document.documentElement.clientHeight ) ) {
				myHeight = document.documentElement.clientHeight;
				myWidth = document.documentElement.clientWidth;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				myHeight = document.body.clientHeight;
				myWidth = document.body.clientWidth;
			}
		
			if(myHeight<=currAltezza_fl){myHeight=currAltezza_fl}	
			if(myWidth<=930){myWidth=930}	
			
			var flashvars = {currentURL:percorso};
			var params = {};
				params.quality = "high";
				params.wmode = "window";
				params.devicefont = "false";
				params.allowFullScreen = "true";
				params.allowScriptAccess = "always";
			var attributes = {};
				attributes.id = "contenitoreGen";
				attributes.name = "index_flash";
				//attributes.align = "middle";
				
				
				
			swfobject.createCSS("html", "height:100%; margin:0; padding:0;");
			//swfobject.createCSS("body", "margin:0; padding:0; height:100%;");//overflow:hidden;
			swfobject.createCSS("body", "margin:0; padding:0; overflow-x:hidden;");//overflow:hidden;height:"+myHeight+"px;
			document.getElementsByTagName("body")[0].style.height=myHeight+"px";
			document.getElementsByTagName("body")[0].style.width=myWidth+ "px";//"100%";
			swfobject.embedSWF("/_swf/index.swf", "contenitoreGen", "100%", "100%", "9.0.0","", flashvars, params, attributes,playerReady);
			
		}
		
		//flashDiv.style.display = 'block';
	}
	contenitore.style.display = "block";
}



function playerReady(obj) {
	if(obj.success == true){
		objFla = document.getElementById(obj['id']);
		siteVersion = "FLASH"
	}
	/*
	else if(obj.success == false){
		siteVersion = "HTML"
		document.getElementsByTagName("body")[0].style.width="380px";
		var contenitore = document.getElementById('contenitoreTotale');
		contenitore.style.width = "380px";
	}
	document.getElementsByTagName("body")[0].style.height=myHeight+"px";
		document.getElementsByTagName("body")[0].style.width="100%";
*/
};
  






function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

/*
function mostra_img(path,img_id){
	var imgElem = document.getElementById(''+img_id+'');
	imgElem.src=path;
	
}
function caricaImg(ob, targ){
	var imgCnt = document.getElementById(''+targ+'');
	imgCnt.innerHTML = '<img src="'+ob+'" />'
}
function dynamicLayout(){
    var browserWidth = getBrowserWidth();

    // Narrow CSS rules
    if (browserWidth < 640){
        changeLayout("narrow");
    }
    // Normal (default) CSS rules
    if ((browserWidth >= 640) && (browserWidth <= 960)){
        changeLayout("default");
    }
    // Wide CSS rules
    if (browserWidth > 960){
        changeLayout("wide");
    }
}
*/
