/********************************************************************************************************** 
 ***************** JS - Fabio Lucattini ******************************************************************
 **********************************************************************************************************/
 
 var httpImmaginiGrandi = createRequestObject(); 
 
 var action ;
 var idP, catP;
 
 	 function impostaAltezza(){
		var h = document.getElementById("fotoGrande").height;
		h += 200;
		resizaAreaCentrale( h+"px" );
		
	 }
 
	 function distruggiLoadMenu(){
		document.getElementById("spazioFotoGrande").removeChild(document.getElementById('divFotoGrande'));
	 }
 
	 function cambiaImg( id, cat ) {
	 	idP = id;
		catP = cat;
	 	var spazioFoto = document.getElementById("spazioFotoGrande");
	 	if(document.getElementById("divFotoGrande")){
			distruggiLoadMenu();
		}
		divFotoGrande = document.createElement('div');
		spazioFoto.appendChild(divFotoGrande);			
		divFotoGrande.setAttribute('id',"divFotoGrande");
		divFotoGrande.style.visible ="hidden";
		
		action = "script/visualizzaFaidate.php?id="+ id +"&cat="+ cat +"&width=620";
		httpImmaginiGrandi.open('get', action);  
		httpImmaginiGrandi.onreadystatechange = cambiaImgRisposta2;  
		httpImmaginiGrandi.send(null);  
		
	}  
	function cambiaImg2( id, cat ) {
	 	idP = id;
		catP = cat;
	 	var spazioFoto = document.getElementById("spazioFotoGrande");
	 	if(document.getElementById("divFotoGrande")){
			distruggiLoadMenu();
		}
		
		divFotoGrande = document.createElement('div');
		spazioFoto.appendChild(divFotoGrande);			
		divFotoGrande.setAttribute('id',"divFotoGrande");
		divFotoGrande.style.visible ="hidden";
		
		action = "script/visualizzaRifinitureInterni.php?id="+ id +"&cat="+ cat +"&width=620";
		httpImmaginiGrandi.open('get', action);  
		httpImmaginiGrandi.onreadystatechange = cambiaImgRisposta3;  
		httpImmaginiGrandi.send(null);  
		
		
	}  
	 
	function cambiaImgRisposta2() { 
	
		var fotoGrande = document.getElementById("fotoGrande");
		var divFotoGrande = document.getElementById("divFotoGrande");
		var spazioFoto = document.getElementById("spazioFotoGrande");
		
		if(httpImmaginiGrandi.readyState < 4){	
			divFotoGrande.style.top = "249px";
			divFotoGrande.style.left = "0px";
			
			divFotoGrande.innerHTML= "... Caricamento ...<br><img src='image/loader.gif' alt='loader'>";
			divFotoGrande.style.visible ="visible";
		}
		else if(httpImmaginiGrandi.readyState == 4)
		{
			if(httpImmaginiGrandi.status == 200)
			{	
				
				document.getElementById("fotoGrande").src = action ;
				document.getElementById("fotoGrande").onclick = function (){ allargaFoto2( idP , catP ) };
				document.getElementById("fotoGrande").onLoad = distruggiLoadMenu();
				
			}
			else
			{			
			}
		}
	   
	}
	
	function cambiaImgRisposta3() { 
	
		var fotoGrande = document.getElementById("fotoGrande");
		var divFotoGrande = document.getElementById("divFotoGrande");
		var spazioFoto = document.getElementById("spazioFotoGrande");
		
		if(httpImmaginiGrandi.readyState < 4){	
			divFotoGrande.style.top = "249px";
			divFotoGrande.style.left = "0px";
			
			divFotoGrande.innerHTML= "... Caricamento ...<br><img src='image/loader.gif' alt='loader'>";
			divFotoGrande.style.visible ="visible";
		}
		else if(httpImmaginiGrandi.readyState == 4)
		{
			if(httpImmaginiGrandi.status == 200)
			{	
				
				document.getElementById("fotoGrande").src = action ;
				document.getElementById("fotoGrande").onclick = function (){ allargaFoto3( idP , catP ) };
				document.getElementById("fotoGrande").onLoad = distruggiLoadMenu();
				
			}
			else
			{			
			}
		}
	   
	}
	
/**********************************************************************************************************************/

	
	
	function allargaFoto2( id , cat ){
	  	globalId = id;
		globalCat = cat;
		if(document.getElementById("conteinerLoad")){
			document.getElementsByTagName("body")[0].removeChild(document.getElementById("conteinerLoad"));
			conteinerLoad = "";
		}
		
		conteinerLoad = document.createElement('div');
		document.getElementsByTagName("body")[0].appendChild(conteinerLoad);			
		conteinerLoad.setAttribute('id',"conteinerLoad");	
		
		foto = document.createElement('div');
		conteinerLoad.appendChild(foto);			
		foto.setAttribute('id',"foto");
		
		sfondoDiv = document.createElement('div');
		conteinerLoad.appendChild(sfondoDiv);			
		sfondoDiv.setAttribute('id',"sfondoDiv");
		
		fraseFoto = document.createElement('div');
		conteinerLoad.appendChild(fraseFoto);			
		fraseFoto.setAttribute('id',"fraseFoto");
	   	
		
		/* setto l'altezza di sfondo */
		if(screenH > 768){
			sfondoDiv.style.height=screenH+"px";
			
		}else{
			sfondoDiv.style.height=screenH+((768-screenH)/2)+"px";
		}
		sfondoDiv.style.width=screenW+"px";
		
		fotoRisp = 2;
	   var action = "script/visualizzaFaidate.php?id="+id+"&cat="+cat+"&width=620";
	   httpFoto.open('get', action);  
	   httpFoto.onreadystatechange = allargaFotoRisp;  
	   httpFoto.send(null);  
	   		
	}  
	
	function allargaFoto3( id , cat ){
	 	 globalId = id;
		globalCat = cat;
		if(document.getElementById("conteinerLoad")){
			document.getElementsByTagName("body")[0].removeChild(document.getElementById("conteinerLoad"));
			conteinerLoad = "";
		}
		
		conteinerLoad = document.createElement('div');
		document.getElementsByTagName("body")[0].appendChild(conteinerLoad);			
		conteinerLoad.setAttribute('id',"conteinerLoad");	
		
		foto = document.createElement('div');
		conteinerLoad.appendChild(foto);			
		foto.setAttribute('id',"foto");
		
		sfondoDiv = document.createElement('div');
		conteinerLoad.appendChild(sfondoDiv);			
		sfondoDiv.setAttribute('id',"sfondoDiv");
		
		fraseFoto = document.createElement('div');
		conteinerLoad.appendChild(fraseFoto);			
		fraseFoto.setAttribute('id',"fraseFoto");
	   	
		
		/* setto l'altezza di sfondo */
		if(screenH > 768){
			sfondoDiv.style.height=screenH+"px";
			
		}else{
			sfondoDiv.style.height=screenH+((768-screenH)/2)+"px";
		}
		sfondoDiv.style.width=screenW+"px";
		
		fotoRisp = 3;
	   var action = "script/visualizzaRifinitureInterni.php?id="+id+"&cat="+cat+"&width=620";
	   httpFoto.open('get', action);  
	   httpFoto.onreadystatechange = allargaFotoRisp;  
	   httpFoto.send(null);  
	   		
	}  
	
