﻿var first=0;
var filtro=100;
var timerID2=null;
var lefttime2=null;

ns4=(navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? 1 : 0;
ie4=(document.all && !document.getElementById)? 1 : 0;
ie5=(document.getElementById && document.all)? 1 : 0;
ns6=(document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? 1: 0;
w3c=(document.getElementById)? 1 : 0;
  
function adjustIFrameSize(iframeWindow) 
	{
	 userAgent=navigator.userAgent;
	 if(userAgent.indexOf('Safari')!=-1)
	 {
	  var iframeElement = document.getElementById(iframeWindow.name);
	  iframeElement.style.height=0+"px";
	  iframeElement.style.width=0+"px";
	 }
	 
	 if (document.getElementById) 
  		 {
		  var iframeElement = document.getElementById(iframeWindow.name);
		  
		  if(userAgent.indexOf('Safari')!=-1)
		  	iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px';
		  else
		   	iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px';
		 
		  if(((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf("Opera")!=-1))&&(first==0))
		  	{
		  	if(userAgent.indexOf("Opera")!=-1)
				iframeElement.style.width = iframeWindow.document.body.scrollWidth +  92 + 'px';
			else
	 	 	iframeElement.style.width = iframeWindow.document.body.scrollWidth + 110 + 'px';
			}
	 	  else
	  		if(userAgent.indexOf('Firefox')!=-1)
	  		 	iframeElement.style.width = iframeWindow.document.body.scrollWidth + 10 + 'px';
	  		 else
			 	iframeElement.style.width = iframeWindow.document.body.scrollWidth + 'px';
		 first++;	
      	}	 
  	else if (document.all) 
  		{
  		var iframeElement = document.all[iframeWindow.name];
   		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') 
   			{
      		iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 'px';
	  		if((userAgent.indexOf('Firefox')!=-1)&&(first==0))
	 			iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth + 110 + 'px';
	  		else
	  			if(userAgent.indexOf('Firefox')!=-1)
	  		 		iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth + 10 + 'px';
	  			else
      				iframeElement.style.width = iframeWindow.document.documentElement.scrollWidth +'px';
      		first++;
    		}
    	else 
			{
				iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px';
			 	if((userAgent.indexOf('Firefox')!=-1)&&(first==0))
			 		iframeElement.style.width = iframeWindow.document.body.scrollWidth + 110 + 'px';
				else
			 		if(userAgent.indexOf('Firefox')!=-1)
			 			iframeElement.style.width = iframeWindow.document.body.scrollWidth + 10 + 'px';
					else
	  					iframeElement.style.width = iframeWindow.document.body.scrollWidth +'px';
	  			first++;
    		}
  		}
  	else if (iframeWindow.document.height) 
	 	{
		 	 var iframeElement = document.getElementById(iframeWindow.name);
		 	 iframeElement.style.height = iframeWindow.document.height + 'px';
		 	 if((userAgent.indexOf('Firefox')!=-1)&&(first==0))
		 	 	iframeElement.style.width = iframeWindow.document.width + 110 +'px';
		 	 else 
		 	 	if(userAgent.indexOf('Firefox')!=-1)
		 	 			iframeElement.style.width = iframeWindow.document.width + 10 +'px';
		 		else 
		 	 		iframeElement.style.width = iframeWindow.document.width + 'px';
		 	 first++;
	 	 }
	
	}

function adjustIFrameSize2(iframeWindow) 
	{
	 userAgent=navigator.userAgent;	  
	 var iframeElement;
	 if (document.getElementById) 
	  	{	
			  iframeElement = document.getElementById(iframeWindow.name);
			  iframeElement.style.height=0+'px';
	    }
	 else if (document.all) 
	  		{
	  		iframeElement = document.all[iframeWindow.name];
			iframeElement.style.height=0+'px';
	  		}
	  	else if (iframeWindow.document.height) 
		 	{
		 	 iframeElement = document.getElementById(iframeWindow.name);
			 iframeElement.style.height=0+"px";
		 	 iframeElement.style.height = iframeWindow.document.height + 'px';
		 	 }
	
	document.getElementById("paletta").style.height=0+"px";	

	setTimeout(function(){
				 userAgent=navigator.userAgent;	  
	 var iframeElement;
	 if (document.getElementById) 
	  	{	
			  iframeElement = document.getElementById(iframeWindow.name);
			  iframeElement.style.height=0+'px';
			  iframeElement.style.height=iframeWindow.document.body.scrollHeight + 'px';
	    }
	 else if (document.all) 
	  		{
	  		iframeElement = document.all[iframeWindow.name];
			iframeElement.style.height=0+'px';			
	   		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') 
	      		{
					iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 'px';
				}
	    	else 
				{
					iframeElement.style.height = iframeWindow.document.body.scrollHeight + 'px';
				}
	  		}
	  	else if (iframeWindow.document.height) 
		 	{
			 iframeElement.style.height=0+"px";
				
		 	 iframeElement = document.getElementById(iframeWindow.name);
		 	 iframeElement.style.height = iframeWindow.document.height + 'px';
		 	 }
		parent.ridimensiona();
						},100);
	}

function scompari()
{
	filtro=100;
	if(w3c){var livello=top.document.getElementById('overlay');}
	if(ie4){var livello=top.document.all['overlay'];}
	if(ns4){var livello=top.document.layers['overlay'];}
	livello.style.opacity = 1; 
    livello.style.MozOpacity = 1; 
    livello.style.KhtmlOpacity = 1; 
    livello.style.filter = "alpha(opacity=100)"; 
	timerID2=setTimeout('lefttime2=setInterval("scompaio()",100)', 500)
}

function scompaio(){
	clearTimeout(timerID2);
	if(w3c){var livello=top.document.getElementById('overlay');var livello_top=top.document.getElementById('top_overlay');}
	if(ie4){var livello=top.document.all['overlay'];var livello_top=top.document.all['top_overlay'];}
	if(ns4){var livello=top.document.layers['overlay'];var livello_top=top.document.layers['top_overlay'];}
	if (filtro!=0)
		{
		filtro-=10;
		
		livello.style.opacity = (filtro / 100); 
    	livello.style.MozOpacity = (filtro / 100); 
    	livello.style.KhtmlOpacity = (filtro / 100); 
    	livello.style.filter = "alpha(opacity=" + filtro + ")"; 
		
		if(filtro<60)
			{
				livello_top.style.opacity = (filtro / 100); 
				livello_top.style.MozOpacity = (filtro / 100); 
				livello_top.style.KhtmlOpacity = (filtro / 100); 
				livello_top.style.filter = "alpha(opacity=" + filtro + ")"; 
			}
		}
	else
		{
			if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
				{
				livello_top.style.width=0+"px";
				livello_top.style.height=0+"px";
				}
			else
				{
					livello_top.style.width=0;
					livello_top.style.height=0;
				}	
			livello.style.visibility="hidden";
			livello_top.style.visibility="hidden";
			clearInterval(lefttime2);
		}
	}
	