function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

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

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;
						  }
						  
		
		
		var giafatto=false	;
		var oldx
		var oldy;
		var xx=280;
		var yy=160;
		var myImage;

function preload(){
	
 if(myImage.complete) {
 xx=myImage.width/2;
 yy=myImage.height/2;
 }
 else{
  setTimeout("preload()",100);
}
}

function mostra(ogg){
	ob=document.getElementById('fo')
	os=$(ob);
	
// 	xx=280;
// 	yy=160;
	//var foto=String(ogg.getAttribute('rel'));
	var foto=String(ogg.getAttribute('href'));
	//foto=urlsito+'galleria/'+foto
	
	myImage = new Image();
	myImage.src=foto;
	
	var tit =String(ogg.getAttribute('title'));
	var alt=String(ogg.getAttribute('rel'));
	
	var objOverlay = document.createElement('img');
		objOverlay.setAttribute('id','foimg');
		objOverlay.setAttribute('src',myImage.src);
		objOverlay.setAttribute('alt',alt);
		objOverlay.setAttribute('title',alt);
		ob.appendChild(objOverlay);
	//ob.innerHTML='<img id="foimg"  alt="'+tit+'" title=\"'+tit+'\"/>';
	
// 	obimg=document.getElementById('foimg');
//  	obimg.src=myImage.src;

	if(giafatto){
			chiudi();
			return;
		}
	arrayPageScroll = getPageScroll();	
	page=getPageSize() ;
	pageX=page[0];
	pageY=page[1];//altezza pagina
	pageH=page[3];//alteza finestra browser
	
		myImage.onload=function(){
			//if(myImage.complete){//non funzia su ie6
			xx=myImage.width/2;
			yy=myImage.height/2;
			
			a=2*xx;
			b=2*yy + 50;
			oldy=pageY/2;
			oldx=pageX/2;
		
			ob.style.display='none';
			Nxx=oldx-xx
			
		
			var apertura = arrayPageScroll[1] + (pageH / 13);
			ob.style.top=apertura+'px';
			ob.style.left=Math.round(Nxx)+'px';
			ob.style.width=Math.round(a)+'px';
			ob.style.height=Math.round(b)+'px';	
			
			ob.innerHTML+='<p class="par2">'+tit+'</p>';
			ob.innerHTML+='<p id="par" onclick="chiudi();">Chiudi</p>';
			//ob.innerHTML+='<p class="par2"><strong>'+tit+'</strong></p>';
			
			new Effect.Grow('fo',{duration:0.5});
			
			
			giafatto=true;
			delete xx;
			delete yy;
			//}
		} //fine oload
	}//fine mostra
		
		function chiudi(){
			giafatto=false;
			new Effect.Fade('fo')
			ob=document.getElementById('fo');
			ob.innerHTML="";
			}
			
			///////////////////////////		
			

			