var x
var y
var step=30
var sc
var p=new Object() 
var SWFBool
var swfFILE
img_UNO="<p align='center'><img id='img' class='fjpg'><br>"
fl="<p align='center'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='50' height='50' id='load' align='middle' style='z-index:2'>"
fl+="<param name='allowScriptAccess' value='sameDomain' />"
fl+="<param name='movie' value='swf/load.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' />"
fl+="<embed src='swf/load.swf' quality='high' wmode='transparent' bgcolor='#000000' width='50' height='50' name='load' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
fl+="</object>"
function file_exists (url) {
    // Returns true if filename exists  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/file_exists    // +   original by: Enrique Gonzalez
    // +      input by: Jani Hartikainen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %        note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.
    // %        note 1: Synchronous so may lock up browser, mainly here for study purposes.     // *     example 1: file_exists('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
    // *     returns 1: '123'
    
    var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) {throw new Error('XMLHttpRequest not supported');}      
    // HEAD Results are usually shorter (faster) than GET
    req.open('HEAD', url, false);
    req.send(null);
    if (req.status == 200){        return true;
    }
    
    return false;
}

var ldy
var ldx
dx1=100
dy1=100
xPrec=0
yPrec=0
var _width=0
var opac2=0;
var opac3=0;
var CostrX=0
var CostrY=0
var dimx
var dimy
var carica 
var ld;
var pic

var fl1
var primo;

var p4=new Object()	
Object.prototype.centra=function(){
	
centroX=Math.ceil(parseInt(document.getElementById("xy_uno").getAttribute("width"))/2)
centroY=Math.ceil(screen.height/2);
var	Coords={x: 0, y: 0}
var XY=Coords.getPosXY(document.getElementById("xy_uno"))
var var_uno=document.getElementById("LayerZoom").style.width
var var_due=var_uno.split("px")

cx=XY.x+centroX-Math.ceil(parseInt(var_due[0])/2)
var var_tre=document.getElementById("LayerZoom").style.height
var var_quattro=var_tre.split("px")

cy=XY.y+centroY-Math.ceil(parseInt(var_quattro[0])/2)	
 if (isIE||isNN) {
	 document.getElementById("LayerZoom").style.left=cx
	 document.getElementById("LayerZoom").style.top=cy
  
	 }else if (isN4){ 
	 document.layers["LayerZoom"].style.left=cx
	 document.layers["LayerZoom"].style.top=cy
	 }	

}	


function loadSWF(_w,_h){
SWFBool=true		 	
if(p.vX==undefined){ 
	p.vX=0	;
	p.N_UNO=0
	
     boolX=false    
}	
if(p.vY==undefined){ 
	boolY=false
	p.vY=0;
	p.N_DUE=0
}

	
	p4._width=p.vX
    p4.centra() 
  
	ld=setInterval("p.Zoom('"+_w+"','"+_h+"')",5);	 	
}


function loadJPG() {

	

if(pic.complete!=false && pic.width>0){
		
clearInterval(LoadIMG)


   if (isIE||isNN){ 
	 
	
	document.getElementById("contenuto").innerHTML=img_UNO
	document.getElementById("img").src=pic.src
    document.getElementById("img").style.visibility = "visible"
    
   }else if (isN4){
	 
    }
   

fadeJPG("img",true)

		 
}else{
	clearInterval(LoadIMG)
	}

}



var fade
var v
var op
function fadeJPG(id,primo){
clearInterval(fade) 
if(primo==true) {
op=0	
primo=false	
}

if(op <100){ 

	op+=20
    v=op/100

   if (isIE) 
    document.getElementById(id).style.filter="alpha(opacity="+op+")"
   else if(isNN) {
    document.getElementById(id).style.MozOpacity=v
    document.getElementById(id).style.opacity = v; 
	}
 fade = setInterval("fadeJPG('"+id+"',"+primo+")",100);
 
  }

}



function loadPIC(){
if(carica!=undefined)
clearInterval(carica)

if(pic.complete==false ){
	
  carica=setInterval("loadPIC()",50)
  }else{
  dimx=pic.width+20
  dimy=pic.height+35

if (isIE||isNN){ 
   if(p.vX==undefined){ 
	p.vX=0	;
	p.N_UNO=0
	
     boolX=false    
   }	
   if(p.vY==undefined){ 
	boolY=false
	p.vY=0;
	p.N_DUE=0
   }
    p4._width=p.vX
    p4.centra() 
	ld=setInterval("p.Zoom('"+dimx+"','"+dimy+"')",5);
}
	
	}

}
Object.prototype.Zoom=function(x,y){
	

if (isIE||isNN){
	 var Width=document.getElementById("LayerZoom").style.width
	 var Height=document.getElementById("LayerZoom").style.height
	 
	if(!boolX){
		this.N_UNO=Math.ceil((this.N_UNO+(x-this.vX)/1.1)/3)
	 
	     var var_uno=Width.split("px")
	     document.getElementById("LayerZoom").style.width=parseInt(var_uno[0])+this.N_UNO 
		 this.vX=parseInt(var_uno[0])+this.N_UNO
	    
	}
	
		if(!boolY){	
		
		this.N_DUE=Math.ceil((this.N_DUE+(y-this.vY)/1.1)/3)
	    
		 var var_due=Height.split("px")
		 document.getElementById("LayerZoom").style.height=parseInt(var_due[0])+this.N_DUE 
		this.vY=parseInt(var_due[0])+this.N_DUE
		
		}
         
        
		 p4._width=this.vX
		 p4.centra()  
		
	if(Math.abs(this.N_UNO)<=0.3){
		  
	      boolX=true
	      this.N_UNO=0
	     }else{
	       boolX=false
	       
     }
     if(Math.abs(this.N_DUE)<=0.3){ 
	        boolY=true  
	        this.N_DUE=0
	         }else{ 
	          boolY=false
	          }
		
	      
	     
          

if(boolY && boolX){   
 
 clearInterval(ld)
  

 boolY=false
 boolX=false
 if(SWFBool==true){
   fl1="<p align='center'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+x+"' height='"+y+"' id='Zswf' align='middle'>"
   fl1+="<param name='allowScriptAccess' value='sameDomain' />"
   fl1+="<param name='movie' value='"+swfFILE+"' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#000000' />"
   fl1+="<embed src='"+swfFILE+"' quality='high' wmode='transparent' bgcolor='#000000' width='"+x+"' height='"+y+"' name='Zswf' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
   fl1+="</object>"
  
	if (isIE||isNN){ 
		
     document.getElementById("contenuto").innerHTML=fl1
	 document.getElementById("x").style.visibility="visible";
	 
	} else if (isN4){
	 
	 document.layers["contenuto"].innerHTML=fl1
	 document.layers["x"].visibility="show";
	 document.layers["Zswf"].visibility="show";
	
	 	 }	 
	 
	 
	 
	 SWFBool=false
	 
	 }else{
		 
	  primo=true
      LoadIMG=setInterval("loadJPG()", 50);
		 
		 
		 
		 }

} 
}
   
   
}
function InEvidenza(){
var opac2=70
v2=opac2/100

if (isIE) { 
	document.getElementById("l").style.visibility="visible"
	 document.getElementById("l").style.filter="alpha(opacity=75)";
 }else if(isNN){
	document.getElementById("l").style.visibility="visible"
	 document.getElementById("l").style.MozOpacity=v2	
	  document.getElementById("l").style.opacity = v2; 
 }


}




function usato(){

window.open("Usato.php",'usato','screeny=0,screenx=150,scrollbars=yes,scroll=yes,resizable=no,width=780,height=400,status=no,location=no,toolbar=no');

}
function Zjpg(file,scelta,sez,w_,h_){
opac2=0;
opac3=0

	
if (isIE||isNN){
	
	
	if(document.getElementById("LayerZoom").style.display=="none")
     document.getElementById("LayerZoom").style.display = "block";
	document.getElementById("LayerZoom").style.visibility="visible";
	document.getElementById("Tit").style.color="#000000"
	document.getElementById("Tit").innerHTML =sez	
	document.getElementById("contenuto").innerHTML=""	
	if(scelta!="swf"){
	document.getElementById("x").style.visibility="visible";
	 
	document.getElementById("contenuto").innerHTML =fl 

	    }
	 document.getElementById("contenuto").innerHTML =fl    
    }
if (isIE||isNN){
	if(scelta=="jpg") document.getElementById("load").style.visibility="visible"
   document.getElementById("l").style.visibility="visible"
 
   if(isIE){
	   document.getElementById("l").style.filter="alpha(opacity=0)"
	   }else if(isNN){
	   document.getElementById("l").style.MozOpacity=0
	   }
 } 
sc=scelta
if(scelta=="jpg"){
pic=new Image()

InEvidenza()
pic.src =file
loadPIC()		
}else{
InEvidenza()
swfFILE=file	
loadSWF(w_,h_)	
	}
 
 


}

function Visibility(id){
		
if(isIE||isNN){
	   document.getElementById(id).style.visibility="hidden"
	   document.getElementById("LayerZoom").style.display = "none";
 }else if(isN4){
   document.layers[id].visibility="hide";
   document.layers["LayerZoom"].display = "none";
 }				
		
}
function Visibility2(id){
		
if(isIE||isNN){
	   document.getElementById(id).style.visibility="hidden"
	   document.getElementById(id).style.display = "none";
 }else if(isN4){
   document.layers[id].visibility="hide";
   document.layers[id].display = "none";
 }				
		
}



var str_2="";


function txt(t){
	
alert(t)	
	
	}
//--------------------------------------------------------------
function STOP(){
// var flashMovie=GetIDFlash("Zswf");
// flashMovie.SetVariable("_root.Command.Stop","");
}


 function GetIDFlash(ID)
{
  if (window.document[ID]){
    return window.document[ID];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1){
    if (document.embeds && document.embeds[ID])
      return document.embeds[ID]; 
  }
  else{
    return document.getElementById(ID);
  }
}



function chiudiJPG(){
	
 Visibility("LayerZoom")
  Visibility("l")
 STOP()
 
   
 			
 clearInterval(ldy)
 clearInterval(ldx)
 
}
Object.prototype.getPosXY=function(element) { 
	if(element){
		this.x += element.offsetLeft; 
		this.y += element.offsetTop; 
		element= element.offsetParent; 
	    this.getPosXY(element)
		}
	return this; 
}
function ridimensiona(){
	
if(isIE||isNN){
	   document.getElementById("l").style.width="100%"
	   document.getElementById("l").style.height ="900";	
	
	
}
}
function FlashMENU_DoFSCommand(command, args) {
	

if (command == "Menu") {
	
 if (isIE||isNN){
	document.getElementById("pag").src=args 
	}	
	
	
	}
	
}
