var opacita=0;
//var timerID=null;
var timerID_popup=null;
var timer_bottoni=null;
var lefttime_popup=null;
var lefttime_bottoni=null;
var first_loading=0;
var contatore_img=0;
var tmp_count=0;
var contatore_totale=0;
var descrizione="";
var userAgent;
var num_img=0;
var img=new Array();
var num=0;
var new_w;
var btn=0;
var opacita_bottoni=0;
var id_prodotto=0;
var lingua=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;
userAgent=navigator.userAgent;

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

	if (self.innerHeight) {	// all except Explorer
		if(top.document.documentElement.clientWidth){
			windowWidth = top.document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (top.document.documentElement && top.document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = top.document.documentElement.clientWidth;
		windowHeight = top.document.documentElement.clientHeight;
	} else if (top.document.body) { // other Explorers
		windowWidth = top.document.body.clientWidth;
		windowHeight = top.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 (top.document.documentElement && top.document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = top.document.documentElement.scrollTop;
		xScroll = top.document.documentElement.scrollLeft;
	} else if (top.document.body) {// all other Explorers
		yScroll = top.document.body.scrollTop;
		xScroll = top.document.body.scrollLeft;	
	}

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

function poppin()
{
	if(w3c) var livello=top.document.getElementById('layer_popup');
	if(ie4) var livello=top.document.all['layer_popup'];
	if(ns4) var livello=top.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.right=0+"px";
	livello.style.visibility="visible";
	
	if(w3c) var livello=top.document.getElementById('layer_popup2');
	if(ie4) var livello=top.document.all['layer_popup2'];
	if(ns4) var livello=top.document.layers['layer_popup2'];
	livello.style.visibility="visible";	
	
		if(w3c) var livello=top.document.getElementById('livello_filmato');
	if(ie4) var livello=top.document.all['livello_filmato'];
	if(ns4) var livello=top.document.layers['livello_filmato'];
	livello.style.visibility="visible";	
	
	livello.style.top=(arrayPageSize[1])-155+"px";
	
	livello.style.left=(arrayPageSize[2]-150)+"px";
	
	livello.style.width=150+"px";
	livello.style.height=96+"px";
}

function poppin2()
{
	if(w3c) var livello=top.document.getElementById('layer_popup_gallery');
	if(ie4) var livello=top.document.all['layer_popup_gallery'];
	if(ns4) var livello=top.document.layers['layer_popup_gallery'];

	var arrayPageSize=getPageSize();
	var arrayPageScroll=getPageScroll();
	livello.style.visibility="visible";	
	livello.style.display="block";	
	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];
		}	
	
	if(w3c) var livello=top.document.getElementById('layer_popup2_gallery');
	if(ie4) var livello=top.document.all['layer_popup2_gallery'];
	if(ns4) var livello=top.document.layers['layer_popup2_gallery'];
		
	livello.style.visibility="visible";	
	livello.style.display="block";
	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];
		}	
}

/*FUNZIONI PER RECUPERO NUM IMG*/
function AjaxNumImg(id,lang){
	file_prodotto="utility.php";
	if (window.XMLHttpRequest)
		ajax=new XMLHttpRequest();
	else
		ajax=new ActiveXObject("Microsoft.XMLHTTP");
	if(id!="")
		{
			id_prodotto=id;
			lingua=lang;
			file_prodotto=file_prodotto+"?gallery=si&lang="+lingua+"&id_prodotto="+id;
			ajax.onreadystatechange=AjaxRequestNumImg;
			ajax.open("GET",file_prodotto,true);
			ajax.send(null);
		}
}

function AjaxRequestNumImg() {
    if (ajax.readyState == 4) {
        if (ajax.status == 200)
			recupero_info(ajax.responseText);
		else
            //alert("Spiacenti e' avvenuto un errore nel recupero dei dati2:\n" + ajax.statusText);
			document.location.reload();
    }
}


/*FUNZIONI PER RECUPERO NUM IMG*/
function AjaxNumImg2(id,lang){
	file_prodotto="utility.php";
	if (window.XMLHttpRequest)
		ajax2=new XMLHttpRequest();
	else
		ajax2=new ActiveXObject("Microsoft.XMLHTTP");
	if(id!="")
		{
			id_prodotto=id;
			lingua=lang;
			file_prodotto=file_prodotto+"?gallery2=si&lang="+lingua+"&id_prodotto="+id;
			ajax2.onreadystatechange=AjaxRequestNumImg2;
			ajax2.open("GET",file_prodotto,true);
			ajax2.send(null);
		}
}

function AjaxRequestNumImg2() {
    if (ajax2.readyState == 4) {
        if (ajax2.status == 200)
			recupero_info2(ajax2.responseText);
		else
            //alert("Spiacenti e' avvenuto un errore nel recupero dei dati1:\n" + ajax2.statusText);
			document.location.reload();
    }
}

function recupero_info(txt){
	var tmp_array=new Array();
	tmp_array=txt.split("&");
	for(i=0;i<tmp_array.length;i++){
		if(i==0){
			num_img=tmp_array[i].split("=")[1];
			}		
		else{
			img[i-1]=tmp_array[i].split("=")[1];
			}
		}
	var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
	tmp_img.src="gallery/"+lingua+"/"+id_prodotto+"/"+img[num];
	new_w = (700/tmp_img.height)*tmp_img.width;
	var livello=document.getElementById('livello_gallery');
	livello.style.width=(parseInt(new_w)+20)+"px";
	livello.style.display="block";
}

function recupero_info2(txt){
	var tmp_array=new Array();
	tmp_array=txt.split("&");
	for(i=0;i<tmp_array.length;i++){
		if(i==0){
			num_img=tmp_array[i].split("=")[1];
			}		
		else{
			img[i-1]=tmp_array[i].split("=")[1];
			}
		}
	var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
	tmp_img.src="rassegna/"+lingua+"/big/"+img[num];
	/*new_w = (700/tmp_img.height)*tmp_img.width;
	var livello=document.getElementById('livello_gallery');
	livello.style.width=(parseInt(new_w)+20)+"px";
	livello.style.display="block";*/
}

function caricato(obj){
	new_w = (700/obj.height)*obj.width;
	clearTimeout(timer_bottoni);
	clearInterval(lefttime_bottoni);
	clearTimeout(timerID_popup);
	opacita_bottoni=0;
	btn=0;
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	
	livello.style.width=(parseInt(new_w)+20)+"px";
	livello.style.display="block";
	
	livello_next.style.opacity = 0; 
    livello_next.style.MozOpacity = 0; 
    livello_next.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_next.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_next").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/next.png,sizingMethod='scale')";
	}
	
	livello_prev.style.opacity = 0; 
    livello_prev.style.MozOpacity = 0; 
    livello_prev.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_prev.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_prev").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/prev.png,sizingMethod='scale')";
	}
	
	livello_close.style.opacity = 0; 
    livello_close.style.MozOpacity = 0; 
    livello_close.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_close.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_close").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/close.png,sizingMethod='scale')";
	}
	livello_close.style.display="none";
	livello_next.style.display="none";
	livello_prev.style.display="none";
	livello.onmousemove="";
	
	setTimeout(function(){caricato2(obj);},500);
	}

function caricato2(obj){
	var obj_img=document.getElementById("img_gallery");
	if(w3c){
		var tmp_ampiezza=document.getElementById('livello_gallery').style.width;
	}
	if(ie4){
		var tmp_ampiezza=document.all['livello_gallery'].style.width;
	}
	if(ns4){
		var tmp_ampiezza=document.layers['livello_gallery'].style.width;
	}	
	obj_img.onmousemove="";
	new_w = (700/obj.height)*obj.width;
	obj_img.src=obj.src;
	obj_img.width=new_w;
	obj_img.height=700;
	if(parseInt(tmp_ampiezza)>parseInt(new_w)){
	clearTimeout(timerID_popup);
	timerID_popup=setTimeout(function(){clearInterval(lefttime_popup);lefttime_popup=setInterval("appaio_popup2()",1);}, 500);}
	else{
	clearTimeout(timerID_popup);
	timerID_popup=setTimeout(function(){clearInterval(lefttime_popup);lefttime_popup=setInterval("appaio_popup1()",1);}, 500);
	}
	}
	
function avanti(){
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var obj_img=document.getElementById('img_gallery');
		var obj1=document.getElementById("livello_wait");
		var obj2=document.getElementById("livello_img");
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var obj_img=document.all['img_gallery'];
		var obj1=document.all['livello_wait'];
		var obj2=document.all['livello_img'];
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
		var obj_img=document.layers['img_gallery'];
		var obj1=document.layers['livello_wait'];
		var obj2=document.layers['livello_img'];
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	clearTimeout(timer_bottoni);
	clearInterval(lefttime_bottoni);
	btn=0;
	opacita_bottoni=0;
	livello.onmousemove="";
	
	livello_next.style.opacity = 0; 
    livello_next.style.MozOpacity = 0; 
    livello_next.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_next.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_next").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/next.png,sizingMethod='scale')";
	}
	
	livello_prev.style.opacity = 0; 
    livello_prev.style.MozOpacity = 0; 
    livello_prev.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_prev.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_prev").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/prev.png,sizingMethod='scale')";
	}
	
	livello_close.style.opacity = 0; 
    livello_close.style.MozOpacity = 0; 
    livello_close.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_close.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_close").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/close.png,sizingMethod='scale')";
	}
	
	livello_close.style.display="none";	
	livello_next.style.display="none";
	livello_prev.style.display="none";
	
	obj1.style.display="block";
	obj2.style.display="none";
	obj_img.style.display="none";
	
	if(num!=num_img-1)
	{
		num+=1;
		var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
		tmp_img.src="gallery/"+lingua+"/"+id_prodotto+"/"+img[num];
		}
	else{
		num=0;
		var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
		tmp_img.src="gallery/"+lingua+"/"+id_prodotto+"/"+img[num];
		}
	}

function indietro(){
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var obj_img=document.getElementById('img_gallery');
		var obj1=document.getElementById("livello_wait");
		var obj2=document.getElementById("livello_img");
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var obj_img=document.all['img_gallery'];
		var obj1=document.all['livello_wait'];
		var obj2=document.all['livello_img'];
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
		var obj_img=document.layers['img_gallery'];
		var obj1=document.layers['livello_wait'];
		var obj2=document.layers['livello_img'];
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	
	clearTimeout(timer_bottoni);
	clearInterval(lefttime_bottoni);
	btn=0;
	opacita_bottoni=0;
	livello.onmousemove="";
	
	livello_next.style.opacity = 0; 
    livello_next.style.MozOpacity = 0; 
    livello_next.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_next.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_next").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/next.png,sizingMethod='scale')";
	}
	
	livello_prev.style.opacity = 0; 
    livello_prev.style.MozOpacity = 0; 
    livello_prev.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_prev.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_prev").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/prev.png,sizingMethod='scale')";
	}
	
	livello_close.style.opacity = 0; 
    livello_close.style.MozOpacity = 0; 
    livello_close.style.KhtmlOpacity = 0; 
	if(navigator.appName.indexOf("Explorer")!=-1){
    livello_close.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
	document.getElementById("img_close").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/close.png,sizingMethod='scale')";
	}
	
	livello_close.style.display="none";
	livello_next.style.display="none";
	livello_prev.style.display="none";
	
	obj1.style.display="block";
	obj2.style.display="none";
	obj_img.style.display="none";
	
	if(num!=0)
	{
		num-=1;
		var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
		tmp_img.src="gallery/"+lingua+"/"+id_prodotto+"/"+img[num];
		}
	else{
		num=num_img-1;
		var tmp_img=new Image;
	tmp_img.onload=function(){caricato(tmp_img);}
		tmp_img.src="gallery/"+lingua+"/"+id_prodotto+"/"+img[num];
		}
	}


function appaio_popup1()
{
	clearTimeout(timerID_popup);	
		
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var tmp_ampiezza=document.getElementById('livello_gallery').style.width;
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var tmp_ampiezza=document.all['livello_gallery'].style.width;
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
		var tmp_ampiezza=document.layers['livello_gallery'].style.width;
	}
	
	if(parseInt(tmp_ampiezza)<parseInt(new_w))
		{
		livello.style.width=(parseInt(tmp_ampiezza)+5)+ "px";
		}
	else{
			clearInterval(lefttime_popup);
			var obj_img=document.getElementById("img_gallery");
			var obj1=document.getElementById("livello_wait");
			var obj2=document.getElementById("livello_img");
			obj1.style.display="none";
			obj2.style.display="block";			
			obj_img.style.display="block";
			livello.onmousemove = function(){vedi_bottoni();}
		}	
	}
	
function appaio_popup2()
{
	clearTimeout(timerID_popup);	
		
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var tmp_ampiezza=document.getElementById('livello_gallery').style.width;
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var tmp_ampiezza=document.all['livello_gallery'].style.width;
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
		var tmp_ampiezza=document.layers['livello_gallery'].style.width;
	}
	
	if(parseInt(tmp_ampiezza)>parseInt(new_w))
		{
		livello.style.width=(parseInt(tmp_ampiezza)-5)+ "px";		
		}
	else{
			clearInterval(lefttime_popup);
			var obj_img=document.getElementById("img_gallery");
			var obj1=document.getElementById("livello_wait");
			var obj2=document.getElementById("livello_img");
			obj1.style.display="none";
			obj2.style.display="block";			
			obj_img.style.display="block";			
			livello.onmousemove = function(){vedi_bottoni();}			
		}	
	}


function vedi_bottoni(){
	if(w3c){
		var livello=document.getElementById('img_gallery');
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello=document.all['img_gallery'];
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello=document.layers['img_gallery'];
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	
	if(btn==0){
		btn=1;
		clearTimeout(timer_bottoni);
		timer_bottoni=setTimeout(nascondi_bottoni,2000);
		livello_close.style.display="block";
		if(num_img>1)
		{
		livello_next.style.display="block";
		livello_prev.style.display="block";
		}
		clearInterval(lefttime_bottoni);
		lefttime_bottoni=setInterval("vedi_bottoni2()",1);
	}
	else{
		clearTimeout(timer_bottoni);
		timer_bottoni=setTimeout(nascondi_bottoni,2000);
		}
	}

function vedi_bottoni2(){
	if(w3c){
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	if(btn==1){
	if (opacita_bottoni!=100)
		{
			if(navigator.appName.indexOf("Explorer")!=-1)
				opacita_bottoni+=10;
			else
				opacita_bottoni+=2;
			if(num_img>1)
			{
			livello_next.style.opacity = (opacita_bottoni / 100); 
			livello_next.style.MozOpacity = (opacita_bottoni / 100); 
			livello_next.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_next.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity='+opacita_bottoni+')';
			document.getElementById("img_next").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/next.png,sizingMethod='scale')";
			}
			
			livello_prev.style.opacity = (opacita_bottoni / 100); 
			livello_prev.style.MozOpacity = (opacita_bottoni / 100); 
			livello_prev.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_prev.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity='+opacita_bottoni+')';
			document.getElementById("img_prev").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/prev.png,sizingMethod='scale')";
			}
			}
			livello_close.style.opacity = (opacita_bottoni / 100); 
			livello_close.style.MozOpacity = (opacita_bottoni / 100); 
			livello_close.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_close.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacita_bottoni + ')';
	document.getElementById("img_close").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/close.png,sizingMethod='scale')";
			}
		}
	else
		clearInterval(lefttime_bottoni);
	}
	}

function nascondi_bottoni(){
	if(w3c){
		var livello=document.getElementById('livello_gallery');
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
	}
	if(ns4){
		var livello=document.layers['livello_gallery'];
	}
	if(btn==1){
		btn=0;
		clearTimeout(timer_bottoni);
		clearInterval(lefttime_bottoni);
		lefttime_bottoni=setInterval("nascondi_bottoni2()",1);	
		livello.onmousemove = function(){vedi_bottoni();}	
	}
}

function nascondi_bottoni2(){
	if(w3c){
		var livello_close=document.getElementById('livello_close_gallery');
		var livello_next=document.getElementById('livello_next_gallery');
		var livello_prev=document.getElementById('livello_prev_gallery');
	}
	if(ie4){
		var livello_close=document.all['livello_close_gallery'];
		var livello_next=document.all['livello_next_gallery'];
		var livello_prev=document.all['livello_prev_gallery'];
	}
	if(ns4){
		var livello_close=document.layers['livello_close_gallery'];
		var livello_next=document.layers['livello_next_gallery'];
		var livello_prev=document.layers['livello_prev_gallery'];
	}
	
	if (opacita_bottoni!=0)
		{
			if(navigator.appName.indexOf("Explorer")!=-1)
				opacita_bottoni-=10;
			else
				opacita_bottoni-=2;
			if(num_img>1)
			{
			livello_next.style.opacity = (opacita_bottoni / 100); 
			livello_next.style.MozOpacity = (opacita_bottoni / 100); 
			livello_next.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_next.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity='+opacita_bottoni+')';
			document.getElementById("img_next").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/next.png,sizingMethod='scale')";
			}
			
			livello_prev.style.opacity = (opacita_bottoni / 100); 
			livello_prev.style.MozOpacity = (opacita_bottoni / 100); 
			livello_prev.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_prev.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity='+opacita_bottoni+')';
			document.getElementById("img_prev").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/prev.png,sizingMethod='scale')";
			}
			}
			livello_close.style.opacity = (opacita_bottoni / 100); 
			livello_close.style.MozOpacity = (opacita_bottoni / 100); 
			livello_close.style.KhtmlOpacity = (opacita_bottoni / 100); 
			if(navigator.appName.indexOf("Explorer")!=-1){
			livello_close.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacita_bottoni + ')';
	document.getElementById("img_close").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=img/close.png,sizingMethod='scale')";
			}
			
		}
	else
		{
			clearInterval(lefttime_bottoni);
			livello_next.style.display="none";
			livello_prev.style.display="none";
			livello_close.style.display="none";
		}
	}
	
function close_gallery(){
	clearInterval(lefttime_bottoni);
	clearInterval(lefttime_popup);
	clearTimeout(timer_bottoni);
	clearTimeout(timerID_popup);
	if(w3c){
		var livello=document.getElementById('livello_gallery');
		var livello1=document.getElementById('img_gallery');
		var livello2=document.getElementById("livello_wait");
		var livello3=document.getElementById("livello_img");
		var livello4=document.getElementById('livello_close_gallery');
		var livello5=document.getElementById('livello_next_gallery');
		var livello6=document.getElementById('livello_prev_gallery');
		var livello7=top.document.getElementById('layer_popup_gallery');
		var livello8=top.document.getElementById('layer_popup2_gallery');
	}
	if(ie4){
		var livello=document.all['livello_gallery'];
		var livello1=document.all['img_gallery'];
		var livello2=document.all['livello_wait'];
		var livello3=document.all['livello_img'];
		var livello4=document.all['livello_close_gallery'];
		var livello5=document.all['livello_next_gallery'];
		var livello6=document.all['livello_prev_gallery'];
		var livello7=document.all['layer_popup_gallery'];
		var livello8=document.all['layer_popup2_gallery'];
	}
	if(ns4){
		var livello=document.all['livello_gallery'];
		var livello1=document.all['img_gallery'];
		var livello2=document.layers['livello_wait'];
		var livello3=document.layers['livello_img'];
		var livello4=document.layers['livello_close_gallery'];
		var livello5=document.layers['livello_next_gallery'];
		var livello6=document.layers['livello_prev_gallery'];
		var livello7=document.layers['layer_popup_gallery'];
		var livello8=document.layers['layer_popup2_gallery'];
	}
	
	livello.onmousemove="";
	
	livello.style.display="none";
	livello1.style.display="none";
	livello2.style.display="none";
	livello3.style.display="none";
	livello4.style.display="none";
	livello5.style.display="none";
	livello6.style.display="none";
	livello7.style.display="none";
	livello8.style.display="none";
}
