



var request= null;



var yScroll;
var myWidth = 0, myHeight = 0;
var preferitiDiChi='';
var albumUtente='';


function spostaOmbra() {
	chiappaloscroll();
	document.getElementById('ombra').style.top=yScroll;

}

function chiappaloscroll(){

	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;
	}

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth -15;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 

}







function showpic(foto, descrizione){

descrizione=descrizione.replace("-ofortsopa-","'");
chiappaloscroll();

	document.getElementById('mascherafoto').style.top="50%";
	document.getElementById('mascherafoto').style.marginTop=yScroll-270+"px";

	if (myHeight<550) {
		document.getElementById('mascherafoto').style.top='20px';
		document.getElementById('mascherafoto').style.marginTop="0px";
	}

	document.getElementById('mascherafoto').style.display="block";

	document.getElementById('ombra').style.top=yScroll;
	document.getElementById('ombra').style.left="0px";
	document.getElementById('ombra').style.width=myWidth;
	document.getElementById('ombra').style.height=myHeight;

	document.getElementById('ombra').style.display="block";

	document.getElementById('mascherafoto').innerHTML="<table bgcolor=black width=100%><tR><td width=100% height=30 align=center style=\"color:white; font-family:verdana; font-size:12px;\">"+descrizione+"</td></tr><tr><td align=center width=100% height=520><a href=\"javascript:;\" onclick=\"chiudipic();\" title=\"clicca per chiudere\"><img src=../"+foto+" border=0 alt=\"clicca per chiudere\"></a></td></tR></table>";

	

}







function chiudipic(){

	document.getElementById('ombra').style.display="none";
	document.getElementById('mascherafoto').style.display="none";

}






function contenuto(ur){

	_url=ur;

    	document.getElementById('contenuto').innerHTML="";
	httpRequest("GET", _url, true, handleResponse);

}



function httpRequest(reqType, url, asynch, respHandle){
	if(window.XMLHttpRequest){
		request=new XMLHttpRequest();
	} else if (window.ActiveXObject){
		request= new ActiveXObject("Msxml2.XMLHTTP");
		if (! request){
			request=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	if(request){
		if(reqType.toLowerCase() != "post"){
			initReq(reqType, url, asynch, respHandle);
		} else {
			var args=arguments[4];
			if(args != null && args.length > 0){
				initReq(reqType, url, asynch, respHandle, args);
			}
		}
	} 
}



function initReq(reqType, url, bool, respHandle){
	try{
		request.onreadystatechange=respHandle;
		request.open(reqType, url, bool);
		if(reqType.toLowerCase()=="post"){
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			request.send(arguments[4]);
		} else {
			request.send(null);
		}

	} catch (errv) {
      	alert("L'applicazione non è al momento in grado di contattare il server"+ "\nDettagli dell'errore: "+errv.message);

		}

}




function handleResponse(){

	if (request.readyState==4){
		if (request.status==200){
			var mex=request.responseText;
      	document.getElementById('contenitore').style.display='block';
		
      	document.getElementById('contenuto').innerHTML=mex;
		} 
	}


}




function chiudi(){

     	document.getElementById('contenitore').style.display='none';

      document.getElementById('contenuto').innerHTML="";



}





function apriHL(l){

	url="popup.php?lang=ita&f="+l; window.open(url,'foto','width=550, height=550');

}

	function leggiHL(v){

		t="h"+v;
		ta="h"+v+"a";

		document.getElementById(t).style.display="block";
		document.getElementById(ta).style.display="none";

		if (t=="h4"){document.getElementById('h4b').style.display="block";}
	}

	function chiudiHL(v){

		t="h"+v;
		ta="h"+v+"a";

		document.getElementById(t).style.display="none";
		document.getElementById(ta).style.display="block";

		if (t=="h4"){document.getElementById('h4b').style.display="none";}
	}




function apriPR(l, lang){

l=l.replace("s", "");
l=l.replace(".jpg", "");
url="popup-stampa.php?s=f"+l+"&lang="+lang; 
window.open(url,'stampa','width=550, height=600, scrollbars=yes');

}





function apriForm(lan){


	document.getElementById('divForm').style.display='block';

	accatiemme="<table width=100% height=100% cellpadding=0 cellspacing=0 style=\"border:1px solid black; background-color:white;\">";
	accatiemme=accatiemme+"<tr><td align=center valign=center class=testo>";

	if (lan=="ita") {accatiemme=accatiemme+"<br><b>Scrivi un messaggio</b><br>";}
	else {accatiemme=accatiemme+"<br><b>Send a message</b><br>";}

	accatiemme=accatiemme+"<form name=sendamessage method=post>";
	accatiemme=accatiemme+"<table><tr><td class=tavola3D>";

	if (lan=="ita") {accatiemme=accatiemme+"Nome";}
	else {accatiemme=accatiemme+"Name";}

	accatiemme=accatiemme+"</td><td class=tavola3D><input type=text size=30 maxlenght=30 name=autore></td></tr>";
	accatiemme=accatiemme+"<tr><td class=tavola3D>Email</td>";
	accatiemme=accatiemme+"<td class=tavola3D><input type=text size=30 name=email></td></tr>";
	accatiemme=accatiemme+"<tr><td class=tavola3D>";

	if (lan=="ita") {accatiemme=accatiemme+"Messaggio";}
	else {accatiemme=accatiemme+"Message";}


	accatiemme=accatiemme+"</td><td class=tavola3D><textarea cols=40 rows=8 name=messaggio></textarea></td></tr>";
	accatiemme=accatiemme+"<tr><td class=tavola3D colspan=2 align=center><input type=hidden name=lang value="+lan+">";

	if (lan=="ita") {
	accatiemme=accatiemme+"<input type=button value=invia onclick=\"javascript:inviaForm();\" class=tavola3D>";
	accatiemme=accatiemme+"<input type=button value=annulla class=tavola3D onclick=\"javascript:document.getElementById('divForm').style.display='none';\">";

}

else {
	accatiemme=accatiemme+"<input type=button value=send onclick=\"javascript:inviaForm();\" class=tavola3D>";
	accatiemme=accatiemme+"<input type=button value=cancel class=tavola3D onclick=\"javascript:document.getElementById('divForm').style.display='none';\">";

}

	accatiemme=accatiemme+"</td></tr></table></form>";
	document.getElementById('divForm').innerHTML=accatiemme;
	
}




function inviaForm(){

	autore=document.sendamessage.autore.value;
	email=document.sendamessage.email.value;
	lang=document.sendamessage.lang.value;
	messaggio=document.sendamessage.messaggio.value;

	messaggio=messaggio.replace(/\r\n/g,"<br>");
	messaggio=messaggio.replace(/\r/g,"<br>");
	messaggio=messaggio.replace(/\n/g,"<br>");


	messaggio=encodeURIComponent(messaggio);

	_url="guestbook.php";
	_data="insert=a7&autore="+autore+"&messaggio="+messaggio+"&email="+email+"&lang="+lang;
	httpRequest("POST", _url, true, handleResponse, _data);

}






