﻿function flash(nome){
    document.getElementById("flash").innerHTML=flash_string
}
function menu_over(obj){
//   if(obj.src.indexOf("_up")<0)
    obj.src=obj.src.replace(".png","_up.png").replace(".gif","_up.gif");
}
function menu_out(obj){
    obj.src=obj.src.replace("_up.png",".png").replace("_up.gif",".gif");;
}
/*  OUR VILLAS  */
function CambioData_ov() {
    if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.IsDate()) {
        if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.IsDate()) {
            if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.GetData() <= CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData()) {
                CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.SelData(dt2dtstr(aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 7)));
                visMsg(false);
            }
            else {
                if (((CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.GetData() - CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData()) / 86400000) > 28) {
                    CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.SelData(dt2dtstr(aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 27)))
                    visMsg(true)
                }
            }
        }
        CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.DataMinima = aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 7)
    }
}

function aggiungiGiorni(data, numeroGiorni) {
    var millisecondi = 3600000 * 24 * numeroGiorni
    data.setTime(data.getTime() + millisecondi)
    return data
}
function visMsg(vis) {
    var liv = document.getElementById("msgMax")
    if (vis)
        liv.style.display = "block"
    else
        liv.style.display = "none"
}
function hidemax() {
    document.getElementById('divMassimaData').style.display = 'none';
}
function moreOptions() {
    if ((document.getElementById("tabMore").style.display == "none") || (document.getElementById("tabMore").style.display == "")) {
        document.getElementById("tabMore").style.display = "block"
    }
    else {
        document.getElementById("tabMore").style.display = "none"
    }
}

function txtNome_focus(obj, testo) {
    if (obj.value == testo)
        obj.value = "";
}
function txtNome_blur(obj, testo) {
    if (obj.value == "")
        obj.value = testo;
}

/*  NEWSLETTER  */
function enter_mail(txt) {
    if (txt.value == newsletter_text) {
        txt.value = ""
    }
}
function exit_mail(txt) {
    if (txt.value == "") {
        txt.valueOf = newsletter_text
    }
}

/*  PREFERITI   */
var testo_preferiti = "I miei alloggi preferiti ([0])"
function AddPreferiti(Nome, Valore, strIdLink, strNome, strLinkDettaglio, reload) {
    var vecchioValore = LeggiPreferiti(Nome)
    var strCookie = ""
    if (vecchioValore.indexOf("=") > -1)
        if (!PresenteInPreferiti(vecchioValore, Valore))
            strCookie = vecchioValore + escape("," + Valore);
        else {
            /*if(window.confirm(presentePreferiti)){
            DelPreferiti(Nome,Valore)			 
            document.location=document.location
            }*/
            //alert(aggiuntoPreferiti)
            return
        }
    else
        strCookie = Nome + "=" + escape(Valore);
    strCookie = strCookie.replace(Nome + "=%2C", Nome + "=")
    var Scadenza = new Date()
    Scadenza.setMonth(Scadenza.getMonth() + 1); // fra un mese
    strCookie += "; expires=" + Scadenza.toGMTString() + "; path=/";
    document.cookie = strCookie;
    if (strLinkDettaglio != "")
        AggiornaPreferiti(Nome, strIdLink, strNome, strLinkDettaglio, Valore)
    else
        alert(aggiuntoPreferiti)
    //if(reload)
    //alert(aggiuntoPreferiti)
}
function SvuotaPreferiti() {
    document.cookie = "ListaPreferiti=";
    AggiornaPreferiti("ListaPreferiti")
}
function DelPreferiti(Nome, Valore) {
    var vecchioValore = LeggiPreferiti(Nome)
    var strCookie = ""
    if (vecchioValore.indexOf("=") > -1)
        if (PresenteInPreferiti(vecchioValore, Valore)) {
            var cookie = unescape(vecchioValore).toString()
            var array = cookie.split(",")
            for (var i = 0; i < array.length; i++) {
                if (array[i].replace(Nome + "=", "") != Valore)
                    strCookie += "%2C" + array[i].replace(Nome + "=", "")
            }
        }
        else {
            //alert("non presente")
            return
        }
    else
        strCookie = ""
    //strCookie = Nome + "=" + escape(Valore);
    if (strCookie != "")
        strCookie = strCookie.substring(3, strCookie.length)
    var Scadenza = new Date()
    Scadenza.setMonth(Scadenza.getMonth() + 1); // fra un mese
    strCookie = Nome + "=" + strCookie
    strCookie += "; expires=" + Scadenza.toGMTString();
    document.cookie = strCookie;
    AggiornaPreferiti(Nome)
    document.location = document.location
    //AggiornaPreferiti(Nome,"")

}

function LeggiPreferiti(Nome) {
    var strCookies = document.cookie
    if (strCookies.indexOf(Nome) > -1) {
        var tmp1 = strCookies.indexOf(Nome)
        var tmp2 = strCookies.indexOf(";", tmp1)
        if (tmp2 == -1)
            tmp2 = strCookies.length
        return strCookies.substring(tmp1, tmp2)
    }
    else {
        return ""
    }
}
function NumeroPreferiti(Nome) {
    var strCookies = document.cookie
    if (strCookies.indexOf(Nome) > -1) {
        var tmp1 = strCookies.indexOf(Nome)
        var tmp2 = strCookies.indexOf(";", tmp1)
        if (tmp2 == -1)
            tmp2 = strCookies.length
        if (((strCookies == Nome) || (strCookies == "")) || (strCookies.indexOf(Nome + ";") > -1) || (strCookies.indexOf(Nome + "=;") > -1))
            return 0
        else
            return strCookies.substring(tmp1, tmp2).split("%2C").length
    }
    else {
        return 0
    }
}
function AggiornaPreferiti(Nome, strIdLink, strNome, strLinkDettaglio, Valore) {
    var strCookies = document.cookie
    if (strCookies.indexOf(Nome) == -1) {
        alert(errorePreferiti)
    }
    else {
        //inserire qui il codice sul link dei preferiti
        //document.getElementById("ctl00_Menu_dx1_lnkPreferiti").innerHTML=("I miei alloggi preferiti ([0])").toString().replace("[0]","1")
        if (idLnkPreferiti == "")
            return;
        document.getElementById(idLnkPreferiti).innerHTML = testo_preferiti.toString().replace("[0]", NumeroPreferiti(Nome))
        if (NumeroPreferiti(Nome) > 0)
            document.getElementById(idLnkPreferiti).href = pathUrlPreferiti
        else
            document.getElementById(idLnkPreferiti).href = ""
        if (strNome) {
            var objLink = document.createElement("a");
            //objLink.setAttribute('href',pathLnkPreferiti+strLinkDettaglio);
            objLink.setAttribute('href', strLinkDettaglio);
            objLink.setAttribute('alt', strNome);

            var objImg = document.createElement("img");
            //objImg.setAttribute('src',pathImgPreferiti+"R"+Valore+"-Ap.jpg");
            objImg.setAttribute('src', pathImgPreferiti + strNome.replace(".", "").replace("'", "") + "-Ap.jpg");
            //objImg.setAttribute('onerror','alert(1);this.src=\''+pathImgPreferiti+'NoImgasa.png\';');		    
            //objImg.setAttribute('onerror','fotoMancante();');
            //objLink.setAttribute('alt',strNome);

            objLink.appendChild(objImg)

            document.getElementById("preferiti").appendChild(objLink);
        }
        else {
            document.getElementById("preferiti").innerHTML = "";
        }
    }
}
function PresenteInPreferiti(cookie, valore) {
    cookie = unescape(cookie)
    cookie = "," + cookie.substring(cookie.indexOf("=") + 1) + ","
    return (cookie.indexOf("," + valore + ",") > -1)
}

function InviaPreferiti() {
    var w = 400;
    var h = 250;
    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    var winInvia = window.open("invia_preferiti" + lingua_codice_path + ".aspx?id=" + unescape(LeggiPreferiti("ListaPreferiti").replace('ListaPreferiti=', '')), "Preferiti", "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l)
}

/* CALENDARIO   */
//	var CAL_Mesi = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
//		"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];
//	var CAL_Giorni = ["D", "L", "M", "M", "G", "V", "S"];
//	var CAL_GiornoStart = 1; // day week starts from (normally 0 or 1)
var CAL_explorer = true;
if (navigator.appName == "Netscape")
    CAL_explorer = false

function CAL_PrendiOggetto(id) {
    if (CAL_explorer)
        return document.all(id)
    else
        return document.getElementById(id)
}

function PU_getCalendario(Id) {
    var Obj = new CAL_Calendario(Id)
    return Obj
}

function CAL_Calendario(Id) {
    this.Id = Id
    this.Mesi = CAL_Mesi
    this.Giorni = CAL_Giorni
    this.GiornoStart = CAL_GiornoStart
    this.ImageFolder = CAL_ImageFolder
    this.ImageNextToolTip = CAL_ImageNextToolTip
    this.ImagePrevToolTip = CAL_ImagePrevToolTip
    this.ComboDaNascondere = eval("CAL_ComboDaNascondere_" + Id)
    this.ComboDaNascondereConMsg = eval("CAL_ComboDaNascondereConMsg_" + Id)
    this.DataMinima = eval("CAL_DataMinima_" + Id)
    this.DataMassima = eval("CAL_DataMassima_" + Id)
    this.JSCambioData = eval("CAL_JSCambioData_" + Id)
    this.JSApertura = eval("CAL_JSApertura_" + Id)
    this.StringaNulla = eval("CAL_StringaNulla_" + Id)
    //	document.body.onclick="CAL_Obj_" + Id +".Close();"
    //	document.body.onclick="alert();"
    // Oggetti

    // Metodi
    this.Open = CAL_Open
    this.Close = CAL_Close
    this.Focus = CAL_Focus
    this.Blur = CAL_Blur
    this.SelData = CAL_SelData
    this.Validate = CAL_Valida
    this.IsDate = CAL_DataValida
    this.GetData = CAL_GetData
    this.SetDataMinima = CAL_SetDataMinima
    this.SetDataMassima = CAL_SetDataMassima
    //	this.Hide=PU_Hide

}

// Metodi
function CAL_SelData(data, saltaVerifica) {
    CAL_PrendiOggetto(this.Id + "_CAL_txtData").value = data
    CAL_PrendiOggetto(this.Id + "_Msg").style.display = "none"
    if ((this.JSCambioData != "") && (!saltaVerifica))
        eval(this.JSCambioData)
    this.Close();
}
function CAL_GetData() {
    var testo = CAL_PrendiOggetto(this.Id + "_CAL_txtData").value
    if (testo.length == 10) {
        // con il parseInt a volte torna mese sbagliato ma srve per verificare che la data non sia nulla (con eval va in errore)
        var data = new Date(parseInt(testo.substring(6, 10)), parseInt(testo.substring(3, 5)) - 1, parseInt(testo.substring(0, 2)))
        if (isNaN(data))
            return null
        else
            return new Date(parseInt(testo.substring(6, 10)), eval(testo.substring(3, 5)) - 1, eval(testo.substring(0, 2)))
    }
    else
        return null
}
function CAL_SetDataMinima(data) {
    this.DataMinima = data
    data.setHours(0, 0, 0, 0)
}
function CAL_SetDataMassima(data) {
    this.DataMassima = data
    //this.DataMassima.setHours(23,59,59,99)
    this.DataMassima.setTime(this.DataMassima.getTime() + 1000 * 60 * 60 * 24)
}
function CAL_Close(disabledEvent) {
    CAL_PrendiOggetto(this.Id + "_Mese").innerHTML = ""
    CAL_PrendiOggetto(this.Id + "_Mese").style.display = "none"
    if (!disabledEvent) {
        CAL_VisCombo("visible", this.ComboDaNascondere);
        CAL_VisCombo("visible", this.ComboDaNascondereConMsg);
    }
}
function CAL_Open(str_datetime, evento) {
    CAL_PrendiOggetto(this.Id + "_Mese").style.display = ""
    if (this.JSApertura != "")
        eval(this.JSApertura)
    /*	if(evento!=null){
    var X
    var Y
    if(explorer){
    X=evento.x-95
    Y=evento.y+10
    //			alert(document.body.scrollTop)
    //pageYOffset
    }
    else{
    X=evento.layerX-95
    Y=evento.layerY+10
    }
    PrendiOggetto(this.Id+"_Mese").style.top=Y.toString()+"px"
    PrendiOggetto(this.Id+"_Mese").style.left=X.toString()+"px"
    }
    */
    if (str_datetime == "")
        str_datetime = CAL_PrendiOggetto(this.Id + "_CAL_txtData").value
    var dt_datetime = (str_datetime == null || str_datetime == "" ? new Date() : str2dt(str_datetime, this));
    var MeseOri = dt_datetime.getMonth()
    dt_datetime = CAL_ProssimaDataValida(dt_datetime, this.DataMinima, this.DataMassima)
    // Aggiunto: se salta di 2 mesi ritorno indietro di 1 a meno che la cosa dipenda dal cambio anno   */
    if ((dt_datetime.getMonth() - 1) == MeseOri) {
        dt_datetime.setMonth(dt_datetime.getMonth() - 1)
        dt_datetime = CAL_ProssimaDataValida(dt_datetime, this.DataMinima, this.DataMassima)
    }
    var dt_prev_month = new Date(dt_datetime);
    dt_prev_month.setMonth(dt_datetime.getMonth() - 1);
    var dt_next_month = new Date(dt_datetime);
    dt_next_month.setMonth(dt_datetime.getMonth() + 1);

    var dt_firstday = new Date(dt_datetime);
    dt_firstday.setDate(1);
    //	dt_firstday.setDate(1-(7+dt_firstday.getDay()-this.GiornoStart)%7);
    dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - this.GiornoStart + 1) % 7);
    var dt_lastday = new Date(dt_next_month);
    dt_lastday.setDate(0);

    //---------PARTE SCRITTURA HTML-----------------
    //---------ONUNLOAD------------
    /*	var stringaOnUnload=""
    if(funzioneOnUnload!="")
    stringaOnUnload="onunload=\"window.opener."+funzioneOnUnload+"\"";*/
    //------------------------------
    var str_buffer = new String(
    //		"<body "+ stringaOnUnload+" topmargin='1' leftmargin='1' bgcolor=\"White\">\n"+
		"<table class=\"CAL_table\" onclick=\"event.cancelBubble=true\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"  >\n" +
		"<tr><td class=\"CAL_TabContenitore\">\n" +
		"<table class=\"CAL_TabToolbar_table\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"  height=\"6%\">\n" +
		"<tr>\n	<td align=\"left\" class=\"CAL_TabToolbar\">" +
    /* originale con ora
    str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
    */
    //		"'"+ dt2dtstr(dt_prev_month)+"',null);\">"+
    //		str_target+"', '"+ dt2dtstr(dt_prev_month)+"', '"+funzioneOnUnload+"');\">"+

    //		"<img src=\"Calendario\\prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		"<img style=\"cursor:pointer;cursor:hand\" src=\"" + this.ImageFolder + "prev.gif\" border=\"0\"" +
		" alt=\"" + this.ImagePrevToolTip + "\" onclick=\"javascript:CAL_Obj_" + this.Id + ".Open('" + dt2dtstr(dt_prev_month) + "',null);\"></td>\n" +
		"	<td class=\"CAL_Mese\" colspan=\"5\">" +
		this.Mesi[dt_datetime.getMonth()] + " " + dt_datetime.getFullYear() + "</td>\n" +
		"	<td align=\"right\" class=\"CAL_TabToolbar\">" +
    /* originale con ora
    +str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
    */
    //		+"'"+dt2dtstr(dt_next_month)+"',null);\">"+
    //		+str_target+"', '"+dt2dtstr(dt_next_month)+"', '"+funzioneOnUnload+"');\">"+

    //		"<img src=\"Calendario\\next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		"<img style=\"cursor:pointer;cursor:hand\" src=\"" + this.ImageFolder + "next.gif\" border=\"0\"" +
		" alt=\"" + this.ImageNextToolTip + "\" onclick=\"CAL_Obj_" + this.Id + ".Open('" + dt2dtstr(dt_next_month) + "',null);\"></td>\n</tr>\n"
	);
    str_buffer += "</table>\n" +
	"<table class=\"CAL_table_int\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"  height=\"90%\">\n"
    var dt_current_day = new Date(dt_firstday);
    // print weekdays titles
    str_buffer += "<tr>\n";
    for (var n = 0; n < 7; n++)
        str_buffer += "	<td class=\"CAL_GGSettimana\">" +
		this.Giorni[(this.GiornoStart + n - 1) % 7] + "</td>\n";
    // print calendar table
    str_buffer += "</tr>\n";
    while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
        // print row heder
        str_buffer += "<tr>\n";
        for (var n_current_wday = 0; n_current_wday < 7; n_current_wday++) {
            var ClasseLink = "CAL_GLink"
            if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth()) {
                // print current date
                str_buffer += "	<td class=\"CAL_GSel\">";
                ClasseLink = "CAL_GSel"
            }
            //				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
            // weekend days
            else if (dt_current_day.getDay() == 6)
            // Solo Sabato
                str_buffer += "	<td class=\"CAL_GWeekEnd\">";
            else
            // print working days of current month
                str_buffer += "	<td class=\"CAL_G\">";

            if (dt_current_day.getMonth() == dt_datetime.getMonth())
            // print days of current month
            /* ORIGINALE CON ORARIO
            str_buffer += "<a href=\"javascript:window.opener."+str_target+
            ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
            "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
            */
                if (CAL_Selezionabile(dt_current_day, this.DataMinima, this.DataMassima))
                    str_buffer += "<a href=\"javascript:CAL_Obj_" + this.Id + ".SelData(" +
						"'" + dt2dtstr(dt_current_day) + "');\" class=\"" + ClasseLink + "\">"
                else
                    str_buffer += "<a class=\"CAL_GNoLink\" onclick=\"alert('" + CAL_LinguaMsgSabato + "');\">"

                //+"<font color=\"black\" face=\"verdana, tahoma\" style=\"TEXT-DECORATION: none;FONT-SIZE:12px\">";

                else
                // print days of other months
                /* ORIGINALE CON ORARIO
                str_buffer += "<a href=\"javascript:window.opener."+str_target+
                ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
                "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
                str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
                dt_current_day.setDate(dt_current_day.getDate()+1);
                */
                    if (CAL_Selezionabile(dt_current_day, this.DataMinima, this.DataMassima))
                        str_buffer += "<a href=\"javascript:CAL_Obj_" + this.Id + ".SelData(" +
						"'" + dt2dtstr(dt_current_day) + "');\" class=\"CAL_GLinkOut\">"
                    else
                        str_buffer += "<a class=\"CAL_GNoLink\">"

                    //					+"<font color=\"gray\" face=\"verdana, tahoma\" style=\"TEXT-DECORATION: none;FONT-SIZE:12px\">";
                    str_buffer += dt_current_day.getDate() + "<!/font></a></td>\n";
                    dt_current_day.setDate(dt_current_day.getDate() + 1);
                }
                // print row footer
                str_buffer += "</tr>\n";
            }
            // print calendar footer
            // --Bottone Oggi
            /* ORIGINALE CON ORARIO
            str_buffer +=
            "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
            "<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
            "Orario: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
            "\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
            "</table>\n" +
            "</tr>\n</td>\n</table>\n" +
            "</body>\n" +
            "</html>\n";
            */

            //		str_buffer +="<tr><td>\n<input type=button value='Today'></td></tr>"
            /* VECCHIO*/
            str_buffer +=
		"<tr>\n<td align=\"center\" class=\"CAL_TabToolbarChiudi\" colspan=\"7\">" +
		"<a href=\"javascript:CAL_Obj_" + this.Id + ".Close();\" id=\"chiudi\">" + CAL_LinguaMsgChiudi + "</a></td></tr>" +
		"</table>\n"

            // Aggiungo descrizione non selezionabilità nei mesi di Luglio e Agosto
            //	str_buffer += "<tr><td>Nei Mesi di Luglio e Agosto è possibile arrivare e partire solo di Sabato</td></tr>";
            //		if((dt_datetime.getMonth()==6)||(dt_datetime.getMonth()==7)){
            /* Mostra il messaggio di data massima  */
            if (meseMessaggio(dt_datetime)) {
                str_buffer += "<tr><td class=\"CAL_Msg\">" + CAL_LinguaMsgSabato + "</td></tr>"
                CAL_VisCombo("hidden", this.ComboDaNascondereConMsg)
            }
            else
                CAL_VisCombo("visible", this.ComboDaNascondereConMsg)
            str_buffer += "</tr>\n</td>\n</table>\n"
            /*	str_buffer +=
            "</table>\n" +	
            "</tr>\n</td>\n" +
            "<tr><td align=center>\n"+
            "<input type=\"button\" style=\"cursor:hand; font-family:'tahoma, verdana'; font-size:10px ;border-right: #DBEAF5 1px solid; border-top: #DBEAF5 1px solid; border-left: #DBEAF5 1px solid; border-bottom: #DBEAF5 1px solid; background-color: #4682B4; color: white\" value=\"Oggi\" onclick=\"window.opener.Oggi('"+str_target+"','"+funzioneOnUnload+"',"+X+","+Y+");\">"+
            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
            "<select style=\"display:none\" name=\"cmbAnno\" id=\"cmbAnno\" onchange=\"window.opener.Anno('"+str_target+"','"+str_datetime+"','"+funzioneOnUnload+"','"+X+"','"+Y+"',this.options[this.selectedIndex].value);\" style=\"font-family:'tahoma, verdana'; font-size:10px\"><option value=0>[Vai all'anno]</select></td>"+
            "</tr>\n" +
            "</table>\n" +
            "<script language=javascript>\n"+
            "var Oggi=new Date();\n"+
            "var Anno=Oggi.getFullYear();\n"+
            "var testo;\n"+
            "if(navigator.appName=='Netscape') var combo=document.getElementById('cmbAnno');\n"+
            "else var combo=document.all('cmbAnno');\n"+
            "for(i=0;i<70;i++){\n"+
            "testo=Anno-i;\n"+
            "opzione=new Option(testo,testo);\n"+
            "combo.options[combo.length]=opzione;\n"+
            "}\n"+
            "</script>\n"+
            "</body>\n"+
            "</html>\n";

            var larghezza=200
            var altezza=220
            if(navigator.appName=="Netscape"){
            larghezza=217
            altezza=240
            }
            var vWinCal = window.open("", "Calendar", 
            "width="+larghezza+",height="+altezza+",status=no,resizable=yes,top="+Y+",left="+X);
            vWinCal.opener = self;
            vWinCal.focus()

            var calc_doc = vWinCal.document;
            calc_doc.write (str_buffer);
            calc_doc.close();*/
            CAL_VisCombo("hidden", this.ComboDaNascondere);
            CAL_PrendiOggetto(this.Id + "_Mese").innerHTML = str_buffer
            CAL_PrendiOggetto(this.Id + "_Mese").style.zIndex = "1";

            if (evento)
                evento.cancelBubble = true;
        }
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt(str_datetime, objCalendario) {
    /*	ORIGINALE PER IL FORMATO CON L'ORA E I SEPARATORI -
    var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
    */
    var re_date = /^(\d+)\/(\d+)\/(\d+)/;
    if (!re_date.exec(str_datetime)) {
        //		return alert(CAL_LinguaDataNonValida + " " + str_datetime);
        if ((str_datetime != objCalendario.StringaNulla) && (str_datetime != ""))
            alert(CAL_LinguaDataNonValida + " " + str_datetime);
        return new Date()
    }
    return (new Date(RegExp.$3, RegExp.$2 - 1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr(dt_datetime) {

    /* ORIGINALE
    return (new String (
    dt_datetime.getDate()+"/"+(dt_datetime.getMonth()+1)+"/"+dt_datetime.getFullYear()+" "));
    */
    var giorno = new String(dt_datetime.getDate())
    if (giorno.length == 1)
        giorno = "0" + giorno
    var mese = new String(dt_datetime.getMonth() + 1)
    if (mese.length == 1)
        mese = "0" + mese
    return (new String(
	giorno + "/" + mese + "/" + dt_datetime.getFullYear()));
}
        function CAL_ValKey(evento, txt) {
            // Abilito i numeri e il carattere "/"
            var tasto
            if (CAL_explorer)
                tasto = evento.keyCode
            else
                tasto = evento.which
            if (!(((tasto > 47) && (tasto < 58)) || (tasto == 47)))
                if (CAL_explorer)
                    evento.keyCode = null;
                else
                    return false
                else {
                    if (txt.value == this.StringaNulla)
                        txt.value = ""	//sul primo inserimento cancello il formato
                    else
                        if (((txt.value.length == 2) || (txt.value.length == 5)) && (tasto != 47))
                            txt.value = txt.value + "/"
                    }
                    if (txt.value.length > 9)
                        if (CAL_explorer)
                            evento.keyCode = null;
                        else
                            return false
                        return false

                    }

                    function CAL_VisCombo(visibilita, listaCombo) {
                        /*	var coll
                        if(explorer)
                        coll=document.all.tags("select")
                        else
                        coll=document.getElementsByTagName("select")
                        for(i=0;i<coll.length;i++){
                        coll[i].style.visibility=visibilita
                        }*/
                        var arrayCombo = listaCombo.split(",")
                        for (i = 0; i < arrayCombo.length; i++)
                            if (arrayCombo[i] != "")
                                CAL_PrendiOggetto(arrayCombo[i]).style.visibility = visibilita
                        }
                        function CAL_Valida() {
                            var txtData = CAL_PrendiOggetto(this.Id + "_CAL_txtData")
                            var lblMsg = CAL_PrendiOggetto(this.Id + "_Msg")
                            if (txtData.value != "") {
                                var Data = str2dt(txtData.value, this)
                                if (CAL_Selezionabile(Data, this.DataMinima, this.DataMassima)) {
                                    txtData.value = dt2dtstr(Data)
                                    lblMsg.innerHTML = ""
                                    lblMsg.style.display = "none"
                                    CAL_VisCombo("visible", this.ComboDaNascondere)
                                }
                                else {
                                    /* mostra il messaggio a dx */
                                    /*			if(Data>=this.DataMinima){
                                    lblMsg.innerHTML=CAL_LinguaMsgSabato
                                    lblMsg.style.display=""
                                    CAL_VisCombo("hidden",this.ComboDaNascondere)
                                    }*/
                                    txtData.value = dt2dtstr(CAL_ProssimaDataValida(Data, this.DataMinima, this.DataMassima))
                                    //txtData.value=dt2dtstr(new Date())
                                }
                            }
                            else {
                                if (this.StringaNulla)
                                    if (CAL_AccettaDataNulla)
                                        txtData.value = this.StringaNulla
                                    else
                                        txtData.value = dt2dtstr(CAL_ProssimaDataValida(new Date(), this.DataMinima, this.DataMassima))
                            }
                            if (this.JSCambioData != "")
                                eval(this.JSCambioData)
                        }
                        function CAL_DataValida() {
                            var txtData = CAL_PrendiOggetto(this.Id + "_CAL_txtData")
                            return (!((txtData.value == "") || (txtData.value == this.StringaNulla)))
                        }
                        function CAL_ProssimaDataValida(Data, DataMinima, DataMassima) {
                            while (!CAL_Selezionabile(Data, DataMinima, DataMassima)) {
                                Data.setDate(Data.getDate() + 1)
                                if (DataMassima != null)
                                    if (Data > DataMassima)
                                        return DataMassima
                                }
                                return Data;
                            }
                            function CAL_Focus() {
                                var txtData = CAL_PrendiOggetto(this.Id + "_CAL_txtData")
                                if (txtData.value == this.StringaNulla)
                                    txtData.value = ""
                            }
                            function CAL_Blur() {
                                var txtData = CAL_PrendiOggetto(this.Id + "_CAL_txtData")
                                if (txtData.value == "")
                                    txtData.value = this.StringaNulla
                            }

                            function CAL_Selezionabile(Data, CAL_DataMinima, CAL_DataMassima) {
                                // Nei mesi di Luglio e Agosto si può scegliere solo il Sabato
                                if (Data.getDay() != 6)
                                    return false
                                if (Data < CAL_DataMinima)
                                    return false;
                                if (Data > CAL_DataMassima) {
                                    CAL_DataMassimaSelezioneta()
                                    return false;
                                }
                                //	if(Data>=new Date()) Se la decommendo il calendario parte da Oggi
                                return true
                            }

                            function CAL_DataMassimaSelezioneta() {
                                //document.getElementById("divMassimaData").style.display=""
                            }

                            function meseMessaggio(data) {
                                return false
                            }



/* RESULTS  */
function CambioData_res() {
    if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.IsDate()) {
        if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.IsDate()) {
            if (CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.GetData() <= CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData()) {
                CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.SelData(dt2dtstr(aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 7)));
                visMsg(false);
            }
            else {
                if (((CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.GetData() - CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData()) / 86400000) > 28) {
                    CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.SelData(dt2dtstr(aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 27)))
                    visMsg(true)
                }
            }
        }
        CAL_Obj_ctl00_ContentPlaceHolder1_calDataPartenza.DataMinima = aggiungiGiorni(CAL_Obj_ctl00_ContentPlaceHolder1_calDataArrivo.GetData(), 7)
    }
}
function moreOptions() {
    var tabMore = document.getElementById("tabMore")
    if (tabMore == null)
        var tabMore = document.getElementById("ContentPlaceHolder1_tabMore")
    if (tabMore == null)
        var tabMore = document.getElementById("ctl00_ContentPlaceHolder1_tabMore")

    if (tabMore == null)
        return;
    if ((tabMore.style.display == "none") || (tabMore.style.display == "")) {
        tabMore.style.display = "block"
    }
    else {
        tabMore.style.display = "none"
    }
}

function txtNome_focus(obj, testo) {
    if (obj.value == testo)
        obj.value = "";
}
function txtNome_blur(obj, testo) {
    if (obj.value == "")
        obj.value = testo;
}
function book_focus(obj, stringa) {
    if (obj.value == stringa)
        obj.value = ""
}
function book_blur(obj, stringa) {
    if (obj.value == "")
        obj.value = stringa
}
function ricerca() {
    document.getElementById("ctl00_ContentPlaceHolder1_hidLastMinute").value = "si";
}

/* STRUTTURA DETTAGLIO  */
function check(id, lang, pax, age) {
    var w = 400;
    var h = 330;
    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    var winCheck = window.open("check_availibilities.aspx?id=" + id + "&lang=" + lang + "&pax=" + pax + "&ref=" + escape(document.location.pathname) + age, "check", "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
    winCheck.focus();
}

function slideshow(id, lang, age, scroll) {
    var w = 704;
    var h = 750;
    var s = "no"
    if (screen.height < 801) {
        s = "yes";
    }
    else {
        if (scroll) {
            //s = "yes"
            if (screen.height > 959)
                h = 810
            else
                s = "yes"
        }
    }

    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    var winSlide = window.open("slideshow.aspx?id=" + id + "&lang=" + lang + "&" + age, "slideshow", "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=" + s + ",location=no");
    winSlide.focus();
}
function mappa(id, lang, age) {
    var w = 702;
    var h = 750;
    var s = "no"
    if (screen.height < 801) {
        s = "yes";
    }

    var l = Math.floor((screen.width - w) / 2);
    var t = Math.floor((screen.height - h) / 2);
    //    var winMappa=window.open("map.aspx?id="+id+"&lang="+lang+"&"+age,"mappa","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars="+s+",location=no");
    var winMappa = window.open("http://www.salogivillas.com/map.aspx?id=" + id + "&lang=" + lang + "&" + age, "mappa", "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=" + s + ",location=no");
    winMappa.focus();
}
function modArea(path, cmb) {
    if (cmb.selectedIndex > 0) {
        var cod = cmb.options[cmb.selectedIndex].value.split("|");
        document.location = path + cod[1]
    }
}
function modStruttura(cmb) {
    if (cmb.selectedIndex > 0) {
        document.location = cmb.options[cmb.selectedIndex].value
    }
}
/* GALLERY  */
function gallery_det(path, big,id) {
    document.getElementById(big).src = path;
    document.getElementById(big).title = document.getElementById(id).title
    document.getElementById(big).alt = document.getElementById(id).alt
}
/*  TIPS    */
function tips_over(id_td) {
    document.getElementById(id_td).className = "tips_over"
}
function tips_out(id_td) {
    document.getElementById(id_td).className = ""
}


