var fullscreenset = false;
var onload_test_pop = false
function redirect(vaia){
	location.href = vaia;
}

function apertura_admin(){
		
		
		var MSIE = navigator.appVersion
		MSIE = String(MSIE)
		
		if(navigator.appName.indexOf("Microsoft Internet Explorer")>-1 && MSIE.indexOf("8.0")>-1){
			SVopenWin('admin.asp',400,400,false,true)
		}else if(MSIE.indexOf("MSIE 9.0")>=0){
			SVopenWin('admin.asp',400,400,false,true)
			//var error_str = 'Siamo spiacenti ma il Vostro browser non supporta VisivaMod.<br/> Vi preghiamo di disinstallare Internet Explorer 9'
			//SVopenWin('include_App/varie/error_str.asp?erro='+error_str,420,205,false,true);
		/*}else if(navigator.appName.indexOf("Netscape")>=0){
			var error_str = 'Siamo spiacenti ma il Vostro browser non supporta VisivaMod.<br/> Vi preghiamo di scaricare Internet Explorer 8 <br/><br/><a href=&quot;http://www.microsoft.com/italy/windows/internet-explorer/default.aspx&quot; target=&quot;_blank&quot; >SCARICA SUBITO</a>'
			SVopenWin('include_App/varie/error_str.asp?erro='+error_str,420,205,false,true);*/
		}else{
			
			var error_str = 'Siamo spiacenti ma il Vostro browser non supporta il gestionale.<br/> Vi preghiamo di scaricare Internet Explorer 8 <br/><br/>Prego scegliere la versione per il Vostro sistema operativo:<br/><br/><a href=&quot;EXPLORER 8/Window XP 32-bit/IE8-WindowsXP-x86-ITA.exe&quot; target=&quot;_blank&quot;>WINDOWS XP 32bit</a><br/><br/><a href=&quot;http://www.italiadeivalori.tn.it/EXPLORER 8/Window Vista 32-bit/IE8-WindowsVista-x86-ITA.exe&quot; target=&quot;_blank&quot;>WINDOWS VISTA/7 32bit</a><br/><a href=&quot;EXPLORER 8/Window Vista 64-bit/IE8-WindowsVista-x64-ITA.exe&quot; target=&quot;_blank&quot;>WINDOWS VISTA/7 64bit</a>'
			SVopenWin('include_App/varie/error_str.asp?erro='+error_str,420,205,false,true);
		}

}

function popupResize(){
   
   var newheight;
   var newwidth;

	if(fullscreenset){
		if(document.getElementById("iframe_popup")){
			newheight=document.getElementById("iframe_popup").contentWindow.document.body.scrollHeight;
			newwidth=document.getElementById("iframe_popup").contentWindow.document.body.scrollWidth;
		};
		document.getElementById("iframe_popup").style.height= (newheight) +50+ "px";
		
		if(newwidth){document.getElementById("iframe_popup").style.width= (newwidth)+"px";}
		
		var hpop = document.getElementById("tablesetpop").offsetHeight
		var hwin = document.documentElement.clientHeight
		
		document.getElementById("win_handle").style.top = ((hwin-hpop)/2)+"px";
		
		if(hpop>hwin){
			document.getElementById("iframe_popup").style.height = hwin-92
			document.getElementById("win_handle").style.top = "0px"
			document.getElementById("iframe_popup").scrolling = "yes"
		}
		
		document.getElementById("iframe_popup").contentWindow.stat = hwin;
	}
	
};

function annulla(){
	innder ='';
	//document.getElementById("iframe_popup").contentWindow.clearInterval()
	
	document.getElementById("iframe_popup").style.width = framew+"px";
	document.getElementById("iframe_popup").style.height = frameh+"px";
		
	
	document.getElementById("win_handle").style.width = "500px";
	document.getElementById("win_handle").style.top = "200px";
	document.getElementById("win_handle").style.margin = "0 auto";
	
	framew_now = framew;
	frameh_now = frameh;

	
	//fullscreenset = false
	//document.getElementById("iframe_popup").contentWindow.changewh(framew,frameh);
	
	fullscreenset = true
	
	document.getElementById("win_handle").innerHTML = innder;
	document.getElementById("win_root").style.visibility = "hidden";	
	window.document.getElementsByTagName('html')[0].style.overflow = ''
}

function fullscreen(ifpop){
	if(onload_test_pop){
		if(fullscreenset){
		
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {
				//alert("A")
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//alert("B")
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//alert("C")
				//IE 4 compatible
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			}
			
			wtab = myWidth
			htab = myHeight
			
			//alert(wtab)
			//alert(htab)
			
			document.getElementById("iframe_popup").style.width = wtab-30+"px";
			document.getElementById("iframe_popup").style.height = htab-80+"px";
			document.getElementById("win_handle").style.width = "100%"
			document.getElementById("win_handle").style.height = "100%"
			document.getElementById("win_handle").style.top = "0"
			
			document.getElementById("win_handle").style.margin = "0 auto";
			//document.getElementById("win_handle").style.left = "0px";
			
			framew_now = wtab;
			frameh_now = htab;
			fullscreenset = true
			document.getElementById("iframe_popup").contentWindow.changewh(wtab,htab);
			
			fullscreenset = false
			
		}else{
			document.getElementById("iframe_popup").style.width = framew+"px";
			document.getElementById("iframe_popup").style.height = frameh+"px";
			
			document.getElementById("win_handle").style.width = "500px";
			var hpop = document.getElementById("tablesetpop").offsetHeight
			var hwin = document.documentElement.clientHeight
			
			
			document.getElementById("win_handle").style.top = ((hwin-hpop)/2)+"px";
			document.getElementById("win_handle").style.margin = "0 auto";
			
			framew_now = framew;
			frameh_now = frameh;
			
			fullscreenset = false
			
			document.getElementById("iframe_popup").contentWindow.changewh(framew,frameh);
			
			fullscreenset = true
			
		}
	
	popupResize()
	}
}

var i = 0;
var inetrdownerMenu = ""

function SVopenWin(urlframe,w,h,full,closed){

	onload_test_pop = false;
	
	
	
	document.getElementById("win_handle").style.width = w;
	document.getElementById("win_handle").style.height = h;

	if(urlframe == "admin.asp" && login_set_test){	
	}else{
	
		window.document.getElementsByTagName('html')[0].style.overflow = 'hidden'
		
		framew = w; 
		frameh = h;
		
		innder ='<table border="0" cellpadding="0" cellspacing="0" id="tablesetpop">'
		innder +='<tr>'
		innder +='<td width="15" height="16"><img src="include_app/visivamod/images/popup_01.gif" width="15" height="16" /></td>'
		innder +='<td height="16" background="include_app/visivamod/images/popup_02.gif"></td>'
		innder +='<td width="15" height="16"><img src="include_app/visivamod/images/popup_03.gif" width="15" height="16" /></td>'
		innder +='</tr><tr>'
		innder +='<td><img src="include_app/visivamod/images/popup_04.gif" width="15" height="32" /></td>'
		innder +='<td background="include_app/visivamod/images/popup_06.gif">'
		
		
		
		innder +='<table width="100%" border="0" cellpadding="0" cellspacing="0">'
		//innder +='<tr><td width="100%" style="text-align:left; font-size:18px; font-family:helvetica, sans-serif; color:#ffffff; vertical-align: middle;"><span id="namepopframe"></span></td><td width="25px"><a href="javascript:annulla();"><img src="include_app/visivamod/images/closebig.png"/></a></td>'
		innder +='<tr><td width="100%" style="text-align:left; font-size:18px; font-family:helvetica, sans-serif; color:#ffffff; vertical-align: middle;"><span id="namepopframe"></span></td>'
		if (full){
			innder +='<td width="25px"><a href="javascript:fullscreen();"><img src="include_app/visivamod/images/fullscreen.png"/></a></td>'
		}else{
			innder +='<td width="25px">&nbsp;</td>'
		}
		
		if(closed){
			innder +='<td width="25px"><a href="javascript:annulla();"><img src="include_app/visivamod/images/closebig.png"/></a></td>'
		}else{
			innder +='<td width="25px">&nbsp;</td>'
		}
		innder +='</table>'
		
		innder +='</td><td><img src="include_app/visivamod/images/popup_07.gif" width="15" height="32" /></td>'
		innder +='</tr><tr>'
		innder +='<td rowspan="2" background="include_app/visivamod/images/popup_08.gif" ></td>'
		innder +='<td height="5px" background="include_app/visivamod/images/popup_09.gif"></td>'
		innder +='<td rowspan="2" background="include_app/visivamod/images/popup_10.gif" ></td>'
		innder +='</tr><tr>'
		innder +='<td height="10px" background="include_app/visivamod/images/popup_12.gif"></td>'
		innder += ' </tr><tr>'
		innder += '<td background="include_app/visivamod/images/popup_13.gif"></td>'
		innder += '<td bgcolor="#FFFFFF">'
		
		innder += '<iframe name="iframe_popup" src="'+urlframe+'" onload="onload_test_pop=true;popupResize()" id="iframe_popup" style="width:'+w+'px; height:'+h+'px;margin:0" frameborder="0" scrolling="auto" ></iframe>';
		
		innder += '</td>'
		innder += '<td background="include_app/visivamod/images/popup_15.gif">&nbsp;</td>'
		innder += '</tr><tr>'
		innder += '<td width="15" height="15"><img src="include_app/visivamod/images/popup_16.gif" width="15" height="15" /></td>'
		innder += '<td background="include_app/visivamod/images/popup_17.gif"></td>'
		innder += '<td width="15" height="15"><img src="include_app/visivamod/images/popup_18.gif" width="15" height="15" /></td>'
		innder += '</tr></table>'
		
		document.getElementById("win_handle").innerHTML = innder;
		//document.getElementById("win_handle").style.visibility = "hidden"
		document.getElementById("win_handle").style.margin = "0 auto";
		
		document.getElementById("win_root").style.visibility = "visible";
		
		var hpop = document.getElementById("tablesetpop").offsetHeight
		var hwin = document.documentElement.clientHeight
		
		
		document.getElementById("win_handle").style.top = ((hwin-hpop)/2)+"px";
		
		
	}
	fullscreenset = true
	
}

	/*
	function downerMenu(h,a){
		i = (i+(i/12));
		document.getElementById("win_handle").style.top = (a+i)+"px";		
		if((a+i) >= ((h/2)-70)){
			clearInterval(inetrdownerMenu)	
		}
	}
	*/
