setInterval("posiziona('boxlight',0,0)",100);
Sezione='';
function validateEmail(email) {
	var objRegExp  = '^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+(\.)+([a-zA-Z0-9]{2,})+$';
   	return RegExp(objRegExp).test(email);
}
//---------------------------------------------------------------------------------------------
function assegnaXMLHttpRequest() {
	
	var
	 XHR = null,
	 
	 browserUtente = navigator.userAgent.toUpperCase();
	
	 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
	  XHR = new XMLHttpRequest();
	 else if(
	  window.ActiveXObject &&
	  browserUtente.indexOf("MSIE 4") < 0
	 ) {
	 
	  if(browserUtente.indexOf("MSIE 5") < 0)
	   XHR = new ActiveXObject("Msxml2.XMLHTTP");
	
	  else
	   XHR = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	
	 return XHR;
}
//---------------------------------------------------------------------------------------------
function RichiediPermesso(id){
	openLightBox('boxlight');
	Attesa();
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/LightBox-ask-permesso.php?id="+id, true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='';
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="480px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
function Login(){
	openLightBox('boxlight');
	Attesa();
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-login.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='';
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
function Login2(email,password){
	openLightBox('boxlight');
	Attesa();
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-login2.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='email='+email+'&password='+password;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
				if(ajax.responseText=='') location.href=location.href;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function Registrazione(){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-registrazione.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='sezione='+Sezione;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="480px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
function Registrazione2(Email,Nickname,Nome,Cognome,Citta,Telefono,privacy,Sezione){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-registrazione2.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati ='email='+Email+"&";
		dati+='nickname='+Nickname+"&";
		dati+='nome='+Nome+"&";
		dati+='cognome='+Cognome+"&";
		dati+='citta='+Citta+"&";
		dati+='telefono='+Telefono+"&";
		dati+='privacy='+privacy+"&";
		dati+='sezione='+Sezione;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="480px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function RicordaPassword(){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-ricordapassword.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='';
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
function RicordaPassword2(email){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/ricordapassword.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='email='+email;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="482px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function Attesa(){
	openLightBox('boxlight');
	document.getElementById('boxlight').style.width="300px";
	loadingtext ='<label style="width:300px"><img src="http://www.perugia.com/img_layout/lbl-loading.gif" alt="Esito della richiesta di iscrizione" class="float-left" /></label>';
	loadingtext+='<p style="width:290px;text-align:center;padding-top:20px;"><b>Attendere</b>, verifica dati in corso...<br />';
	loadingtext+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="200" height="30" title="Caricamento">';
	loadingtext+='<param name="movie" value="http://www.perugia.com/preload.swf" />';
	loadingtext+='<param name="quality" value="high" />';
	loadingtext+='<embed src="http://www.perugia.com/preload.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="200" height="30"></embed>';
	loadingtext+='</object>';
	loadingtext+='</p>';
	document.getElementById('boxlight').innerHTML=loadingtext;
	return false;
}
//---------------------------------------------------------------------------------------------
function ContattaImmobile($id){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-contattoimmobile.php?id="+$id, true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='sezione='+Sezione;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function ContattaLavoro($id){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-contattolavoro.php?id="+$id, true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='sezione='+Sezione;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function ContattaBacheca($id){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-contattobacheca.php?id="+$id, true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='sezione='+Sezione;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function InviaContatto(idimmobile,messaggio,sezione,email){
	if(!email) {
		alert('E\' necessario inserire un indirizzo email valido.');
		return false;	
	}
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/box-sendmessaggio.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati='idimmobile='+idimmobile;
		dati+='&messaggio='+messaggio;
		dati+='&email='+email;
		dati+='&sezione='+sezione;
		
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="300px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function lasciaCommento($sezione,$id_ref){
if (document.getElementById('videobox'))document.getElementById('videobox').style.display='none';

Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/pgcomlasciacommento.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati ='sezione='+$sezione;
		dati+='&id_ref='+$id_ref;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="480px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------
function lasciaCommento2($commento,$sezione,$id_ref){
	Attesa();
	openLightBox('boxlight');
	var ajax = assegnaXMLHttpRequest();
	if(ajax) {
		ajax.open("post", "http://www.perugia.com/inc/pgcomlasciacommento2.php", true);
		ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("connection", "close");
		dati ='sezione='+$sezione;
		dati+='&commento='+$commento;
		dati+='&id_ref='+$id_ref;
		ajax.send(dati);
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 4){
				document.getElementById('boxlight').style.width="480px";
				document.getElementById('boxlight').innerHTML=ajax.responseText;
			}
		}
	 }
	 return false;
}
//---------------------------------------------------------------------------------------------