//funzioni javascript

/*questa funzione serve per far aprire le immagini un nuova finestra
indirizzo =url
titolo=titolo della finestra
larg= la larghezza della finestra in px
altezza= l'altezza della finestra in px
coordinate_x=la coordine x in px in cui la finestra si apre , si riferisce all'agolo sinistro della finestra
coordinate_y=la coordine y in px in cui la finestra si apre , si riferisce all'agolo sinistro della finestra
esempio di utlizzo: <a href="javascript:apri('http://www.vulcanoidee.it', 'vulcano', '600', '400', '100', '300')">apri</a>:
*/

function PopupCentrata(pagina) {
   var w = 800;
   var h = 600;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open(pagina,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }

function apri(indirizzo, titolo,esiste){
	if (!esiste) 
		alert("Questa immagine non ha un equivalente piu grande");
	else{	
		w=window.open(indirizzo, titolo,"scroolbar=yes,status=no,width=760,height=760,outerWidth=760,outerHeight=760,top=0,left=0,screeny=0,screenx=0");
		w.focus();
	}
}

function chiudi(iddiv){
	
	node = document.getElementById(iddiv);
	objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
	node.setAttribute('class','invisibile');
	node.setAttribute('className','invisibile');
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		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
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}


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



