
function RunFlashSede()
	{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="200">\n');
        document.write('<param name="movie" value="/img/once/sede.swf">\n');
        document.write('<param name="quality" value="high">\n');
        document.write('<embed src="/img/once/sede.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="200"></embed></object>\n');
	}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function zoom(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function apri(rifpage) {
	if (rifpage =="cantieri;0") {
		window.open("/pages/cantieri_list.asp?Rifpage="+rifpage, "_self");
	}
	else 
		if (rifpage =="vacanze;0") {
			window.open("/pages/vacanze_list.asp?Rifpage="+rifpage, "_self");
		}
		else
			window.open("/pages/corporate/scopri_primalux.asp?Rifpage="+rifpage, "_self");
}

function apri_scheda(rifpage) {
  window.open("/pages/immobili_view.asp?Rif="+rifpage, "_self");
}

function apri_cantiere(rifpage) {
  window.open("/pages/cantieri_view.asp?Rif="+rifpage, "_self");
}

function apri_vacanze(rifpage) {
  window.open("/pages/vacanze_view.asp?Rif="+rifpage, "_self");
}

function apri_agenzia(rifpage) {
	window.open("/pages/agenzie/view.asp?RifPage=view;"+rifpage, "_self");
}

function apri_info(rifpage) {
  window.open(rifpage, '_blank', "scrollbars=yes,resizable=no,width=500,height=520,status=no,location=no,toolbar=no,top=250,left=250");
}

function apri_info_small(rifpage) {
  window.open(rifpage, '_blank', "scrollbars=no,resizable=no,width=550,height=250,status=no,location=no,toolbar=no,top=250,left=250");
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function AggiornaCerca(pagina, type){
	document.localita_italiane.type_contratto.value = type;
	document.localita_italiane.submit();
}

function AggiornaCercaAjax(pagina, type){
	document.localita_italiane.type_contratto.value = type;
	document.localita_italiane.submit();
}

function aprichiudi( targetId, targetIdClose ){
  if (document.getElementById){
    target = document.getElementById( targetId );
	targetClose = document.getElementById( targetIdClose );
      if (target.style.display == "none"){
	  	targetClose.style.display = "none"
        target.style.display = "block";
      } else {
        target.style.display = "none";       
      }
   }
 } 



// form naviga per le regioni
function aggiorna_regione(){
	document.localita_italiane.provincie.value = "--";
	document.localita_italiane.comuni.value = "--";
	document.localita_italiane.submit();
	}
	
function aggiorna_provincia(){
	document.localita_italiane.comuni.value = "--";
	document.localita_italiane.submit();
	}
	
function aggiorna_comune(){
	//document.localita_italiane.provincie.value = "";
	document.localita_italiane.submit();
	}
	
function submit_finale(){
	var check;
	check="true";
	if (check=="true") {
	if ((document.localita_italiane.regioni.value=="--")||(document.localita_italiane.provincie.value=="--")) {
				alert("Almeno regione e provincia devono essere selezionati!");
				check="false";				
			}			
	}
	
	if (check=="true") {	
				document.localita_italiane.action="/pages/immobili_list.asp";
				document.localita_italiane.submit();				
	}
}

function submit_finaleAjax(){
	
				document.localita_italiane.action="/pages/immobili_list.asp";
				document.localita_italiane.submit();				

}


// form naviga per le regioni RICHIESTA
function RichiestaAggiorna_regione(){
	document.luca.Richiestaprovincie.value = "";
	document.luca.Richiestacomuni.value = "";
	document.luca.submit();
	}
	
function RichiestaAggiorna_provincia(){
	document.luca.Richiestacomuni.value = "";
	document.luca.submit();
	}
	
function RichiestaAggiorna_comune(){
	//document.luca.Richiestaprovincie.value = "";
	document.luca.submit();
	}
	

	
	
//validazioni form
function validate_puntovendita() {
  validity = true; // assume valid
  
  if (!check_empty(document.puntovendita.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.puntovendita.elements["cognome"].focus(); return false;}
  
  if (!check_empty(document.puntovendita.eta.value))
        { validity = false; alert('Et&agrave; &egrave; obbligatoria'); document.puntovendita.elements["eta"].focus(); return false;}
		
   if (!check_empty(document.puntovendita.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.puntovendita.elements["tel"].focus(); return false;}
 
  if (!check_email(document.puntovendita.mail.value))
         { validity = false; alert('Indirizzo e-mail non valido'); document.puntovendita.elements["mail"].focus(); return false;}	
  
  
    if (validity)
		return validity;
}


function validate_curriculum() {
  validity = true; // assume valid
  
  if (!check_empty(document.curriculum.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.curriculum.elements["cognome"].focus(); return false;}

  if (!check_empty(document.curriculum.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.curriculum.elements["tel"].focus(); return false;}
 
  if (!check_email(document.curriculum.mail.value))
         { validity = false; alert('Indirizzo e-mail non valido'); document.curriculum.elements["mail"].focus(); return false;}	
  
  
    if (validity)
		return validity;
}

function validate_proponi() {
  validity = true; // assume valid
  
  if (!check_empty(document.proponi.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.proponi.elements["cognome"].focus(); return false;}
   
   if (!check_empty(document.proponi.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.proponi.elements["tel"].focus(); return false;}
  
  if (!check_email(document.proponi.mail.value))
         { validity = false; alert('Indirizzo e-mail non valido'); document.proponi.elements["mail"].focus(); return false;}	
  
    if (!check_empty(document.proponi.comune.value))
        { validity = false; alert('Il comune &egrave; obbligatorio'); document.proponi.elements["comune"].focus(); return false;}
  
    if (validity)
		return validity;
}

function validate_richiesta() {
  validity = true; // assume valid
  
  if (!check_empty(document.richiesta.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.richiesta.elements["cognome"].focus(); return false;}
   
   if (!check_empty(document.richiesta.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.richiesta.elements["tel"].focus(); return false;}
  
    if (validity)
		return validity;
}

function validate_appuntamento() {
  validity = true; // assume valid
  
  if (!check_empty(document.appuntamento.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.appuntamento.elements["cognome"].focus(); return false;}
   
   if (!check_empty(document.appuntamento.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.appuntamento.elements["tel"].focus(); return false;}
  
    if (validity)
		return validity;
}

function validate_info() {
  validity = true; // assume valid
  
  if (!check_empty(document.info.cognome.value))
        { validity = false; alert('Il cognome &egrave; obbligatorio'); document.info.elements["cognome"].focus(); return false;}
   
   if (!check_empty(document.info.tel.value))
        { validity = false; alert('Il telefono &egrave; obbligatorio'); document.info.elements["tel"].focus(); return false;}

  if (!check_email(document.info.mail.value))
         { validity = false; alert('Indirizzo e-mail non valido'); document.info.elements["mail"].focus(); return false;}	
  
    if (validity)
		return validity;
}

function validate_friend() {
  validity = true; // assume valid
  
  if (!check_empty(document.info.mittente_nome.value))
        { validity = false; alert('Il tuo nome &egrave; obbligatorio'); document.info.elements["mittente_nome"].focus(); return false;}
   
   if (!check_email(document.info.mittente_mail.value))
        { validity = false; alert('La tua mail non &egrave; valida'); document.info.elements["mittente_mail"].focus(); return false;}

  if (!check_empty(document.info.destinatario_nome.value))
        { validity = false; alert('Il nome del tuo amico &egrave; obbligatorio'); document.info.elements["destinatario_nome"].focus(); return false;}
   
   if (!check_email(document.info.destinatario_mail.value))
        { validity = false; alert('La tua mail del tuo amico non &egrave; valida'); document.info.elements["destinatario_mail"].focus(); return false;}

  
    if (validity)
		return validity;
}



function check_empty(text) {
  return (text.length > 0); // returns false if empty 
}

function check_email(address) {
  if ((address == "")
    || (address.indexOf ('@') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}
//div automation

//Animated Collapsible DIV- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated June 27th, 07'. Added ability for a DIV to be initially expanded.

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength){ //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
	}
	else{ //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Please wait until document has fully loaded then click again")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------

animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value, days){
	if (typeof days!="undefined"){ //if set persistent cookie
		var expireDate = new Date()
		var expstring=expireDate.setDate(expireDate.getDate()+days)
		document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()
	}
	else //else if this is a session only cookie
		document.cookie = name+"="+value
}	