//Zoom Immagine
/*
###########################################
# variabili globali (CONFIGURABILI) 	  #
###########################################
*/

// La larghezza della div con lo zoom
var larghezzaDiv = 350;
// La larghezza dello schermo
var larghezzaSchermo; 

//altezza dello scroll dell'elemento
var scrOfY = 0;

var imgPath = '../images/';

function impostaPosizione(){
	if (window.innerWidth){ 
		larghezzaSchermo = window.innerWidth
	} 
	if (document.body.clientWidth){ 
		larghezzaSchermo = document.body.clientWidth; 
	}
	if	(document.all)//IE
	{
		document.all.divImmaginePopup.style.left =  (larghezzaSchermo-larghezzaDiv)/6 + 'px';	
		divImmaginePopup.style.top = getScrollXY() + 70 + 'px';
		
	}
	else if (document.getElementById)//NS
	{
		temp = document.getElementById('divImmaginePopup');
		temp.style.left =  (larghezzaSchermo-larghezzaDiv)/6 + 'px';
		temp.style.top = getScrollXY() + 70 + 'px';
	}
}

function mostraImmagine(immagine) {
	if	(document.all)//IE
	{
		document.all.immaginePopup.src = imgPath + immagine;
		document.all.divImmaginePopup.style.visibility = 'visible';
	}
	else if (document.getElementById)//NS
	{
		temp1 = document.getElementById('immaginePopup');
		temp1.src = imgPath + immagine;
		temp1 = "";
		
		temp2 = document.getElementById('divImmaginePopup');
		temp2.style.visibility = 'visible';
		temp2 = "";
	}
}

function openPopup(immagine){
	
	impostaPosizione();
	mostraImmagine(immagine);
	
}

function chiudiPopup(){
	if	(document.all)//IE
	{
		try
		{
			low(immaginePopup);
		}
		catch(er){}
		
		document.all.divImmaginePopup.style.visibility = 'hidden';
	}
	else if (document.getElementById)//NS
	{
		temp = document.getElementById('divImmaginePopup');
		temp.style.visibility = 'hidden';
		temp = "";
	}
}

function getScrollXY() {
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}


//
window.onresize = function() {
	impostaPosizione();
};