var opacita=0;
//var timerID=null;
var timerID_popup=null;
var timer_immagine=null;
//var timerID2_popup=null;
var lefttime_popup=null;
//var lefttime=null;
var lefttime_immagine=null;
var info = new Array();
var gallery_sezione=null;
var screenshot_txt=null;
var screenshot_path=null;
var gallery = new Array();
var newImage;
var first_loading=0;
var contatore_img=0;
var tmp_count=0;
var contatore_totale=0;
var descrizione="";

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 getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

//-------------------------------------------------------------------------------------------------------------------------------------

function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
}

//--------------------------------------------------------------------------------------------------------------------------------------

function appaio_popup(ampiezza, altezza)
{
	clearTimeout(timerID_popup);	
	
	if(w3c){
		var livello=document.getElementById('layer_img');
		var tmp_ampiezza=document.getElementById('layer_img').style.width;
		var tmp_altezza=document.getElementById('layer_img').style.height;
		var livello_contatore=document.getElementById('contatore');
		var livello_descr=document.getElementById('descrizione');
		var content_img=document.getElementById('content_img');
		var img_left=document.getElementById('img_left');
		var img_right=document.getElementById('img_right');
	}
	if(ie4){
		var livello=document.all['layer_img'];
		var tmp_ampiezza=document.all['layer_img'].style.width;
		var tmp_altezza=document.all['layer_img'].style.height;
		var livello_contatore=document.all['contatore'];
		var livello_descr=document.all['descrizione'];
		var content_img=document.all['content_img'];
		var img_left=document.all['img_left'];
		var img_right=document.all['img_right'];
	}
	if(ns4){
		var livello=document.layers['layer_img'];
		var tmp_ampiezza=document.layers['layer_img'].style.width;
		var tmp_altezza=document.layers['layer_img'].style.height;
		var livello_contatore=document.layers['contatore'];
		var livello_descr=document.layers['descrizione'];
		var content_img=document.layers['content_img'];
		var img_left=document.layers['img_left'];
		var img_right=document.layers['img_right'];
	}
	
	if(first_loading==0)
		{
			livello.style.backgroundImage="";
			//livello.style.visibility="visible";
			first_loading++;		
		}
	
			livello_contatore.innerHTML="<b>"+(contatore_img+1)+"</b> di "+contatore_totale;
			livello_contatore.style.textAlign="left";
			livello_contatore.style.width="100%";
			livello_descr.innerHTML=descrizione;
	if(parseInt(tmp_altezza)<altezza+50)
		livello.style.height=(parseInt(tmp_altezza)+3)+ "px";
	else
		{
			if(parseInt(tmp_ampiezza)<ampiezza+20)
				{
					livello.style.width=(parseInt(tmp_ampiezza)+3)+ "px";
					if(tmp_count%3==0)
						livello.style.left=(parseInt(livello.style.left)-3)+ "px";
					tmp_count+=1;				
				}
			else
				{
					if(content_img.style.backgroundImage=="")
					{
						if(contatore_img!=0)
						{
							img_left.style.width=(ampiezza/2)-5+"px";
							img_left.style.height=altezza+"px";
							img_left.style.visibility="visible";
						}
						else
							img_left.style.visibility="hidden";
							
						if(contatore_img<=gallery.length-1)
						{
							img_right.style.width=(ampiezza/2)-5+"px";
							img_right.style.height=altezza+"px";
							img_right.style.visibility="visible";
						}
						else
							img_right.style.visibility="hidden";
							
						content_img.style.width=ampiezza+"px";
						content_img.style.height=altezza+"px";									
						content_img.style.backgroundImage=newImage;	
						timer_immagine=setTimeout("lefttime_immagine=setInterval('appaio_immagine("+altezza+")',1)", 100);
					}
				}
		}	
	}

//--------------------------------------------------------------------------------------------------------------------------------------

/*function appaio_screenshot(ampiezza, altezza)
{
	clearTimeout(timerID_popup);	
		
	if(w3c){
		var livello=document.getElementById('layer_img');
		var tmp_ampiezza=document.getElementById('layer_img').style.width;
		var tmp_altezza=document.getElementById('layer_img').style.height;
		var livello_descr=document.getElementById('descrizione');
		var content_img=document.getElementById('content_img');
		var img_left=document.getElementById('img_left');
		var img_right=document.getElementById('img_right');
	}
	if(ie4){
		var livello=document.all['layer_img'];
		var tmp_ampiezza=document.all['layer_img'].style.width;
		var tmp_altezza=document.all['layer_img'].style.height;
		var livello_descr=document.all['descrizione'];
		var content_img=document.all['content_img'];
		var img_left=document.all['img_left'];
		var img_right=document.all['img_right'];
	}
	if(ns4){
		var livello=document.layers['layer_img'];
		var tmp_ampiezza=document.layers['layer_img'].style.width;
		var tmp_altezza=document.layers['layer_img'].style.height;
		var livello_descr=document.layers['descrizione'];
		var content_img=document.layers['content_img'];
		var img_left=document.layers['img_left'];
		var img_right=document.layers['img_right'];
	}
	
	if(first_loading==0)
		{
			livello.style.backgroundImage="";
			first_loading++;
		}
		
	livello_descr.innerHTML=screenshot_txt;
	
	if(parseInt(tmp_altezza)<altezza+50)
		livello.style.height=(parseInt(tmp_altezza)+10)+ "px";
	else
		{
			if(parseInt(tmp_ampiezza)<ampiezza+20)
				{
					livello.style.width=(parseInt(tmp_ampiezza)+10)+ "px";
					if(tmp_count%2==0)
						livello.style.left=(parseInt(livello.style.left)-10)+ "px";
					tmp_count+=1;				
				}
			else
				{
					if(content_img.style.backgroundImage=="")
					{
						if(contatore_img!=0)
						{
							img_left.style.width=(ampiezza/2)-5+"px";
							img_left.style.height=altezza+"px";
							img_left.style.visibility="visible";
						}
						else
							img_left.style.visibility="hidden";
							
						if(contatore_img<=gallery.length-1)
						{
							img_right.style.width=(ampiezza/2)-5+"px";
							img_right.style.height=altezza+"px";
							img_right.style.visibility="visible";
						}
						else
							img_right.style.visibility="hidden";
							
						content_img.style.width=ampiezza+"px";
						content_img.style.height=altezza+"px";						
						content_img.style.backgroundImage=newImage;						
						timer_immagine=setTimeout("lefttime_immagine=setInterval('appaio_immagine("+altezza+")',1)", 100);
					}
				}
		}	
	}*/

//--------------------------------------------------------------------------------------------------------------------------------------

function getNewXMLobj(){
       var XMLHttpRequestObject = false;
       if (window.XMLHttpRequest){XMLHttpRequestObject = new XMLHttpRequest();}
       else if (window.ActiveXObject){XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");}
       return XMLHttpRequestObject;
}

//------------------------------------------------------------------------------------------------------------------------------

function getImageInfo(){
       var XMLreq= getNewXMLobj();
       if(XMLreq) { 
          XMLreq.onreadystatechange = function() {
              if ((XMLreq.readyState ==4)  ){  
			  	
                  var xml_obj = XMLreq.responseXML;
                  info[0] = parseInt(xml_obj.documentElement.getAttribute("dim_x"));
                  info[1] = parseInt(xml_obj.documentElement.getAttribute("dim_y"));				  
				  timerID_popup=setTimeout("lefttime_popup=setInterval('appaio_popup(info[0],info[1])',1)", 200);
                  }
              }// fine function()
		  var url="../it/"+gallery_sezione+"/"+gallery[contatore_img];
		  newImage="url(../"+gallery_sezione+"/"+gallery[contatore_img]+")";
          
		  dataSource = "../../js/get_info.php?url="+url+"&random="+Math.random();
//alert(url);
          XMLreq.open("GET", dataSource,true);
          XMLreq.send(null); 
       } else alert("error: the XMLhttpRequest object is not instantiated");
   }// fine getImageInfo(url)

//------------------------------------------------------------------------------------------------------------------------------

function getImageInfo2(){
	   //alert("Ma capperi !!!!!");
       var XMLreq= getNewXMLobj();
       if(XMLreq) { 
          XMLreq.onreadystatechange = function() {
              if ((XMLreq.readyState ==4)  ){  
                  var xml_obj = XMLreq.responseXML;
                  info[0] = parseInt(xml_obj.documentElement.getAttribute("dim_x"));
                  info[1] = parseInt(xml_obj.documentElement.getAttribute("dim_y"));				  
				  //timerID_popup=setTimeout("lefttime_popup=setInterval('appaio_popup(info[0],info[1])',1)", 500);
                  }
              }// fine function()
		  var url="../it/"+gallery_sezione+"/"+gallery[contatore_img];
		  newImage="url(../"+gallery_sezione+"/"+gallery[contatore_img]+")";
          dataSource = "../../js/get_info.php?url="+url+"&random="+Math.random();
          XMLreq.open("GET", dataSource,true);
          XMLreq.send(null); 
       } else alert("error: the XMLhttpRequest object is not instantiated");
   }// fine getImageInfo(url)
   
//------------------------------------------------------------------------------------------------------------------------------
  
/*function getScreenshotInfo(){
       var XMLreq= getNewXMLobj();
       if(XMLreq) { 
          XMLreq.onreadystatechange = function() {
              if ((XMLreq.readyState ==4)  ){
				  var xml_obj = XMLreq.responseXML;
                  info[0] = parseInt(xml_obj.documentElement.getAttribute("dim_x"));
                  info[1] = parseInt(xml_obj.documentElement.getAttribute("dim_y"));
				  
				  timerID_popup=setTimeout("lefttime_popup=setInterval('appaio_screenshot(info[0],info[1])',1)", 500);
                  }
              }// fine function()
		 
		  var url=screenshot_path;
		  newImage="url('"+screenshot_path+"')";
          dataSource = "../../js/get_info.php?url="+url+"&random="+Math.random();
          XMLreq.open("GET", dataSource, true);
          XMLreq.send(null); 
       } else alert("error: the XMLhttpRequest object is not instantiated");
   }// fine getImageInfo(url)*/
   
//------------------------------------------------------------------------------------------------------------------------------
  
function getImageTxt(){
       var XMLreq= getNewXMLobj();
       if(XMLreq) { 
          XMLreq.onreadystatechange = function() {
              if ((XMLreq.readyState ==4)){
                  var xml_obj = XMLreq.responseXML;
				  var testo=xml_obj.getElementsByTagName("testo");
				  descrizione=testo[0].firstChild.nodeValue;
				  getImageInfo();
                  }
              }// fine function()
          dataSource = "../img/software/"+gallery_sezione+"/"+contatore_img+".xml";
          XMLreq.open("GET", dataSource,true);
          XMLreq.send(null); 
       } else alert("error: the XMLhttpRequest object is not instantiated");
   }// fine getImageInfo(url)

//------------------------------------------------------------------------------------------------------------------------------

function getImages(){
       var XMLreq= getNewXMLobj();
	   
       if(XMLreq) { 
	      
          XMLreq.onreadystatechange = function() {
              if ((XMLreq.readyState ==4)  ){
                  var xml_obj = XMLreq.responseXML;	  
				  var tmp_array=xml_obj.documentElement.getAttribute("files");
				  contatore_totale=xml_obj.documentElement.getAttribute("contatore");
				  gallery = tmp_array.split(',');
				  var tmp="url(../../img/popup/loading.gif)";
				  if(w3c) var livello_tmp=document.getElementById('layer_img');
				  if(ie4) var livello_tmp=document.all['layer_img'];
				  if(ns4) var livello_tmp=document.layers['layer_img'];
				  
				  livello_tmp.style.backgroundImage=tmp;
				  livello_tmp.style.backgroundPosition="center";
				  livello_tmp.style.backgroundRepeat="no-repeat";
				  //getImageTxt();
				  getImageInfo();
                  }
              }// fine function()
		  dataSource = "../../js/get_info.php?sezione="+gallery_sezione;
//alert(gallery_sezione);
          XMLreq.open("GET", dataSource ,true);
		  
          XMLreq.send(null);
		  
       } else alert("error: the XMLhttpRequest object is not instantiated");
   }// fine getImageInfo(url)

//------------------------------------------------------------------------------------------------------------------------------

function zoom_popup(tmp_sezione)
{
	if(tmp_sezione!="")
	{
		
	contatore_img=0;
	if(w3c) var livello=document.getElementById('layer_popup');
	if(ie4) var livello=document.all['layer_popup'];
	if(ns4) var livello=document.layers['layer_popup'];
	
	var arrayPageSize=getPageSize();
	var arrayPageScroll=getPageScroll();
		
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0]+"px";
			livello.style.height=arrayPageSize[1]+arrayPageScroll[1]+"px";
		}
	else
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0];
			livello.style.height=arrayPageSize[1]+arrayPageScroll[1];
		}
	livello.style.visibility="visible";
	
	if(w3c) var livello=document.getElementById('layer_popup2');
	if(ie4) var livello=document.all['layer_popup2'];
	if(ns4) var livello=document.layers['layer_popup2'];
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0]+"px";
			livello.style.height=arrayPageSize[1]+arrayPageScroll[1]+"px";
		}
	else
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0];
			livello.style.height=arrayPageSize[1]+arrayPageScroll[1];
		}
	livello.style.visibility="visible";
	
	gallery_sezione=tmp_sezione;
	getImages();
	
	if(w3c) var livello=document.getElementById('layer_img');
	if(ie4) var livello=document.all['layer_img'];
	if(ns4) var livello=document.layers['layer_img'];
	
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		livello.style.left=(arrayPageSize[2]/2)-100+"px";
	else
		livello.style.left=arrayPageSize[2]/2-100;
	}
}

//--------------------------------------------------------------------------------------------------------------------------------------
/*
function zoom_screenshot(sezione, path, txt)
{
	if(w3c) var livello=document.getElementById('layer_popup');
	if(ie4) var livello=document.all['layer_popup'];
	if(ns4) var livello=document.layers['layer_popup'];

	var arrayPageSize=getPageSize();
	var arrayPageScroll=getPageScroll();
	
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0]+"px";
			livello.style.height=arrayPageSize[1]+"px";
		}
	else
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0];
			livello.style.height=arrayPageSize[1];
		}
		
	livello.style.visibility="visible";
	
	if(w3c) var livello=document.getElementById('layer_popup2');
	if(ie4) var livello=document.all['layer_popup2'];
	if(ns4) var livello=document.layers['layer_popup2'];
	
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0]+"px";
			livello.style.top=arrayPageScroll[1]+"px";
			//livello.style.height=arrayPageSize[1]+"px";
		}
	else
		{
			livello.style.width=arrayPageSize[2]+arrayPageScroll[0];
			livello.style.top=arrayPageScroll[1];
			//livello.style.height=arrayPageSize[1];
		}
	livello.style.visibility="visible";
	
	screenshot_txt=txt;
	screenshot_path="../software/"+sezione+"/big/"+path+".jpg";
	var tmp="url(../../img/popup/loading.gif)";
	if(w3c) var livello=document.getElementById('layer_img');
	if(ie4) var livello=document.all['layer_img'];
	if(ns4) var livello=document.layers['layer_img'];
	
	livello.style.backgroundImage=tmp;
	livello.style.backgroundPosition="center";
	livello.style.backgroundRepeat="no-repeat";
				  
	getScreenshotInfo();	
	
	if((userAgent.indexOf('Firefox')!=-1)||(userAgent.indexOf('Safari')!=-1))
		livello.style.left=(arrayPageSize[2]/2)-100+"px";
	else
		livello.style.left=arrayPageSize[2]/2-100;

}*/

//---------------------------------------------------------------------------------------------------------------------------------------

function close_popup()
{	
	clearInterval(lefttime_popup);
	clearInterval(lefttime_immagine);
	clearTimeout(timer_immagine);
	clearTimeout(timerID_popup);
	
	if(w3c){
		var livello=document.getElementById('layer_popup2');
		var livello_top=document.getElementById('layer_popup');
		var livello_left=document.getElementById('img_left');
		var livello_right=document.getElementById('img_right');
		var content_img=document.getElementById('content_img');
		var layer_img=document.getElementById('layer_img');
		var bottom_popup=document.getElementById('bottom_popup');
	}
	if(ie4){
		var livello=document.all['layer_popup2'];
		var livello_top=document.all['layer_popup'];
		var livello_left=document.all['img_left'];
		var livello_right=document.all['img_right'];
		var content_img=document.all['content_img'];
		var layer_img=document.all['layer_img'];
		var bottom_popup=document.all['bottom_popup'];
	}
	if(ns4){
		var livello=document.layers['layer_popup2'];
		var livello_top=document.layers['layer_popup'];
		var livello_left=document.layers['img_left'];
		var livello_right=document.layers['img_right'];
		var content_img=document.layers['content_img'];
		var layer_img=document.layers['layer_img'];
		var bottom_popup=document.layers['bottom_popup'];

	}
	
	livello.style.width=0+"px";
	livello_top.style.width=0+"px";
	livello.style.height=0+"px";
	livello_top.style.height=0+"px";
	livello.style.visibility="hidden";
	livello_top.style.visibility="hidden";
	livello_left.style.visibility="hidden";
	livello_right.style.visibility="hidden";
	bottom_popup.style.visibility="hidden";
	content_img.style.backgroundImage="";
	layer_img.style.left=0+"px";
	layer_img.style.width=200+"px";
	layer_img.style.height=200+"px";
	//layer_img.style.visibility="hidden";
	}
	
//---------------------------------------------------------------------------------------------------------------------------------------

function appaio_immagine(altezza)
{
	clearTimeout(timer_immagine);
	
	if(w3c){
		var livello=document.getElementById('content_img');
		var livello_top=document.getElementById('layer_img');
		var tmp_altezza=document.getElementById('layer_img').style.height;
		var bottom_popup=document.getElementById('bottom_popup');
		var tabella=document.getElementById('tabella');
	}
	if(ie4){
		var livello=document.all['content_img'];
		var livello_top=document.all['layer_img'];
		var tmp_altezza=document.all['layer_img'].style.height;
		var bottom_popup=document.all['bottom_popup'];
		var tabella=document.all['tabella'];
	}
	if(ns4){
		var livello=document.layers['content_img'];
		var livello_top=document.layers['layer_img'];
		var tmp_altezza=document.layers['layer_img'].style.height;
		var bottom_popup=document.layers['bottom_popup'];
		var tabella=document.layers['tabella'];
	}

	if (opacita!=100)
		{
				opacita+=4;
				livello.style.opacity = (opacita / 100); 
    			livello.style.MozOpacity = (opacita / 100); 
    			livello.style.KhtmlOpacity = (opacita / 100); 
    			livello.style.filter = "alpha(opacity=" + opacita + ")"; 	
		}
	else
		{
			if(parseInt(tmp_altezza)<altezza+50+(tabella.clientHeight))
					livello_top.style.height=(parseInt(tmp_altezza)+3)+ "px";
			else			
				{
						
					tabella.style.width="100%";
					bottom_popup.style.visibility="visible";
					bottom_popup.style.top=(altezza+50)+"px";
					clearInterval(lefttime_immagine);
					clearInterval(lefttime_popup);
				}
		}	
}

//---------------------------------------------------------------------------------------------------------------------------------------

function scompaio_immagine(altezza)
{
	clearTimeout(timer_immagine);
	
	if(w3c){
		var livello=document.getElementById('content_img');
		var livello_top=document.getElementById('layer_img');
		var tmp_altezza=document.getElementById('layer_img').style.height;
	}
	if(ie4){
		var livello=document.all['content_img'];
		var livello_top=document.all['layer_img'];
		var tmp_altezza=document.all['layer_img'].style.height;
	}
	if(ns4){
		var livello=document.layers['content_img'];
		var livello_top=document.layers['layer_img'];
		var tmp_altezza=document.layers['layer_img'].style.height;
	}
	
	if (opacita!=0)
		{
		opacita-=4;
		
		livello.style.opacity = (opacita / 100); 
    	livello.style.MozOpacity = (opacita / 100); 
    	livello.style.KhtmlOpacity = (opacita / 100); 
    	livello.style.filter = "alpha(opacity=" + opacita + ")"; 
		}
	else
		{
			if(parseInt(tmp_altezza)>=info[1]+50)
				{livello_top.style.height=(parseInt(tmp_altezza)-2)+ "px";}
			else
			{
				if(parseInt(livello_top.style.width)>info[0]+22)
					{
						livello_top.style.width=(parseInt(livello_top.style.width)-3)+ "px";
						if(tmp_count%3==0)
							livello_top.style.left=(parseInt(livello_top.style.left)+3)+ "px";
						tmp_count+=1;				
					}
				else
					{
					clearInterval(lefttime_immagine);
					livello.style.backgroundImage="";
					//getImageTxt();
					//getImageInfo();
					timerID_popup=setTimeout("lefttime_popup=setInterval('appaio_popup(info[0],info[1])',1)", 200);
					}
			}
		}
}

//---------------------------------------------------------------------------------------------------------------------------------------
	
function next_popup()
{
	clearInterval(lefttime_popup);
	clearInterval(lefttime_immagine);
	clearTimeout(timer_immagine);
	clearTimeout(timerID_popup);
	
	if(w3c){
		var tmp_altezza=document.getElementById('content_img').style.height;
		var next=document.getElementById('next');
		var bottom_popup=document.getElementById('bottom_popup');
	}
	if(ie4){
		var tmp_altezza=document.all['content_img'].style.height;
		var next=document.all['next'];
		var bottom_popup=document.all['bottom_popup'];
	}
	if(ns4){
		var tmp_altezza=document.layers['content_img'].style.height;
		var next=document.layers['next'];
		var bottom_popup=document.layers['bottom_popup'];
	}
	
	contatore_img+=1;
	tmp_count=0;
	if(contatore_img==gallery.length-1)
		next.style.visibility='hidden';
	bottom_popup.style.visibility="hidden";
	getImageInfo2();
	timer_immagine=setTimeout("lefttime_immagine=setInterval('scompaio_immagine("+parseInt(tmp_altezza)+")',1)", 100);
}

//---------------------------------------------------------------------------------------------------------------------------------------

function prev_popup()
{
	clearInterval(lefttime_popup);
	clearInterval(lefttime_immagine);
	clearTimeout(timer_immagine);
	clearTimeout(timerID_popup);
	
	if(w3c){
		var tmp_altezza=document.getElementById('content_img').style.height;
		var bottom_popup=document.getElementById('bottom_popup');
		var prev=document.getElementById('prev');
	}
	if(ie4){
		var tmp_altezza=document.all['content_img'].style.height;
		var bottom_popup=document.all['bottom_popup'];
		var prev=document.all['prev'];
	}
	if(ns4){
		var tmp_altezza=document.layers['content_img'].style.height;
		var bottom_popup=document.layers['bottom_popup'];
		var prev=document.layers['prev'];
	}
	contatore_img-=1;
	tmp_count=0;
	if(contatore_img==0)
		prev.style.visibility='hidden';
	bottom_popup.style.visibility="hidden";
	getImageInfo2();
	timer_immagine=setTimeout("lefttime_immagine=setInterval('scompaio_immagine("+parseInt(tmp_altezza)+")',1)", 100);
}

//---------------------------------------------------------------------------------------------------------------------------------------

function is_next_on()
{
	if(w3c){
		var next=document.getElementById('next');
	}
	if(ie4){
		var next=document.all['next'];
	}
	if(ns4){
		var next=document.layers['next'];
	}
	if(contatore_img<gallery.length-1)
		next.style.visibility='visible'
}

//---------------------------------------------------------------------------------------------------------------------------------------

function is_next_off()
{
	if(w3c){
		var next=document.getElementById('next');
	}
	if(ie4){
		var next=document.all['next'];
	}
	if(ns4){
		var next=document.layers['next'];
	}
	
	if(contatore_img<gallery.length-1)
		next.style.visibility='hidden'
}

//---------------------------------------------------------------------------------------------------------------------------------------

function is_prev_on()
{
	if(w3c){
		var prev=document.getElementById('prev');
	}
	if(ie4){
		var prev=document.all['prev'];
	}
	if(ns4){
		var prev=document.layers['prev'];
	}
	if(contatore_img!=0)
		prev.style.visibility='visible'
}

//---------------------------------------------------------------------------------------------------------------------------------------

function is_prev_off()
{
	if(w3c){
		var prev=document.getElementById('prev');
	}
	if(ie4){
		var prev=document.all['prev'];
	}
	if(ns4){
		var prev=document.layers['prev'];
	}
	if(contatore_img!=0)
		prev.style.visibility='hidden'
}