if (typeof (FB_useGoogleAnalytics) == "undefined") {
    var FB_useGoogleAnalytics = false
}
var FB_book_image = new Image();
FB_book_image.src = FBRESA + "trans.gif";
var FB_code_interface = "";
var FB_profil = "";

function hhotelProfil(b, a) {
    FB_code_interface = b;
    FB_profil = a
}
function start() {
    var a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    thisform = document.idForm;
    build_year_select(thisform);
    MD = new Date();
    nday = MD.getDate();
    aday = MD.getDay();
    amois = MD.getMonth();
    ayear = takeYear(MD);
    cur_year = ayear;
    nday += FB_nb_day_delay;
    if (nday > a[amois]) {
        nday -= a[amois];
        amois++;
        if (amois > 11) {
            ayear++;
            amois = 0
        }
    }
    indexDay = nday - 1;
    indexMois = amois;
    indexYear = ayear - cur_year;
    if (indexDay < 0 || indexDay > 30) {
        indexDay = 0
    }
    if (indexMois < 0 || indexMois > 11) {
        indexMois = 0
    }
    if (indexYear < 0 || indexYear > 1) {
        indexDay = 0
    }
    thisform.fromday.selectedIndex = indexDay;
    thisform.frommonth.selectedIndex = indexMois;
    thisform.fromyear.selectedIndex = indexYear;
    update_departure()
}
function generateSession() {
    var c = new Date();
    var b = c.getSeconds();
    f = Math.floor(Math.random() * 1000000000) + "";
    var a = "" + b + f;
    return a
}
function transferGAdata(c, b) {
    var a = FBRESA + "ga.phtml?clusterName=" + b + "&id=" + c;
    pageTracker._initData();
    new Image().src = pageTracker._getLinkerUrl(a);
    pageTracker._trackPageview("/FastBooking/ClicBook")
}
function fbOpenWindow(c, b, e, d, a) {
    if (FB_useGoogleAnalytics) {
        sessId = generateSession();
        hhotelProfil("GoogleAnalytics", escape("SESSION=" + sessId))
    }
    if (FB_profil != "") {
        b += "&code=" + FB_code_interface;
        b += "&profil=" + FB_profil
    }
    window.open(b, e, "toolbar=no,width=" + d + ",height=" + a + ",menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
    if (FB_useGoogleAnalytics) {
        transferGAdata(sessId, c)
    }
}
function hhotelPTC(d, b, c, e, a) {
    hhotelResa(d, b, c, "", "", e, a, "", "")
}
function hhotelPromo(b, a, c) {
    hhotelResa(b, a, "DYNPROMO", "", "", "", "", c, "")
}
function hhotelOnePromo(d, b, c, e, a) {
    hhotelResa(d, b, c, "", "", e, a, "", "style=DIRECTPROMO")
}
function hhotelNegociated(d, b, c, e, a) {
    hhotelResa(d, b, c, "", "", e, a, "", "negociated=1")
}
function hhotelResaDirect(d, b, c, a, g, e) {
    hhotelResa(d, b, c, a, e, g, "", "", "style=DIRECT")
}
function hhotelSearchGroup(a, c, d, b, e) {
    hhotelSearch(a, c, d, b, e, "", "")
}
function hhotelSearchPartner(a, b, c, e, d) {
    if (e != "") {
        args = "&from=" + e
    } else {
        args = ""
    }
    hhotelSearch(a, b, c, "", d, "", args)
}
function hhotelSearchPriceDate(a, d, b, g, e) {
    var c = "";
    if (e != "") {
        c = "FirstDate=" + e
    }
    hhotelSearch(a, "", d, b, g, "", c)
}
function hhotelSearchPriceDateTrack(a, c, e, j, b, h, g) {
    var d = "";
    if (j != "") {
        d = "from=" + j
    }
    if (g != "") {
        d += "&FirstDate=" + g
    }
    hhotelSearch(a, c, e, b, h, "", d)
}
function hhotelSearchPromo(a, b, c) {
    hhotelSearch(a, b, "", "", "", c, "")
}
function hhotelSearchExtra(a, c, g, j, e, h, b) {
    var d = "Extrafield=" + escape(e) + ";" + h + ";" + b;
    if (j != "") {
        d += "&from=" + j
    }
    hhotelSearch(a, c, g, "", "", "", d)
}
function hhotelcancel(c, b) {
    var a = FBRESA + "cancel.phtml?state=77&Hotelnames=" + c;
    if (b != "") {
        a += "&langue=" + b
    }
    fbOpenWindow(c, a, "reservation", 400, 350)
}
function hhotelExtract(c, b) {
    var a = FBRESA + "getresa.phtml?Hotelnames=" + c + "&langue=" + b;
    fbOpenWindow(c, a, "getresa", 700, 300);
    return false
}
function hhotelcheckrates(c, b) {
    var a = FBRESA + "crs.phtml?clusterName=" + c;
    if (b != "") {
        a += "&langue=" + b
    }
    a += "&checkPromo=1";
    fbOpenWindow(c, a, "search", 800, 550)
}
function hhotelResaMSP(d, m, h, e, j, b, l, c, g, k, a) {
    if (k != "") {
        g += "&mastercluster=" + k
    }
    if (a != "") {
        g += "&cartID=" + a
    }
    hhotelResa(d, m, h, e, j, b, l, c, g)
}
function hhotelSearchMSP(h, j, c, k, e, b, d, g, a) {
    if (g != "") {
        d += "&mastercluster=" + g
    }
    if (a != "") {
        d += "&cartID=" + a
    }
    hhotelSearch(h, j, c, k, e, b, d)
}
function hhotelResa(c, l, g, d, h, a, j, b, e) {
    var k = FBRESA + "preresa.phtml?Hotelnames=" + c;
    if (l != "") {
        k += "&langue=" + l
    }
    if (d != "") {
        k += "&FirstRoomName=" + d;
        if (g == "") {
            g = "DIRECT"
        }
    }
    if (h != "") {
        k += "&FirstDate=" + h;
        if (g == "") {
            g = "DIRECT"
        }
    }
    if (g != "") {
        k += "&FSTBKNGCode=" + g
    }
    if (a != "") {
        k += "&FSTBKNGTrackLink=" + a
    }
    if (j != "") {
        k += "&clustername=" + j
    }
    if (b != "") {
        k += "&theme=" + b
    }
    if (e != "" && (e.indexOf("=") != -1)) {
        k += "&" + e
    }
    k += "&HTTP_REFERER=" + escape(document.location.href);
    fbOpenWindow(c, k, "reservation", 400, 350)
}
function hhotelSearch(a, d, g, b, j, h, e) {
    var c = FBRESA + "crs.phtml?clusterName=" + a;
    if (d != "") {
        c += "&langue=" + d
    }
    if (g != "") {
        c += "&FSTBKNGCode=" + g
    }
    if (b != "") {
        c += "&nights=" + b
    }
    if (j != "") {
        c += "&title=" + escape(j)
    }
    if (h != "") {
        c += "&theme=" + h
    }
    if (e != "" && (e.indexOf("=") != -1)) {
        c += "&" + e
    }
    fbOpenWindow(a, c, "search", 800, 550)
}
function hhotelSearchMultCode(a, c, d, g, e) {
    var b = FBRESA + "crs.phtml?clusterName=" + a;
    if (c != "") {
        b += "&langue=" + c
    }
    if (d != "") {
        b += "&AccessCode=" + d
    }
    if (g != "") {
        b += "&title=" + escape(g)
    }
    if (e != "") {
        b += "&FSTBKNGTrackLink=" + e
    }
    b += "&crossSelling=NO";
    fbOpenWindow(a, b, "search", 800, 550)
}
function hhotelSearchCrossSell(a, c, e, d) {
    var b = FBRESA + "crs.phtml?clusterName=" + a;
    if (c != "") {
        b += "&langue=" + c
    }
    if (e != "") {
        b += "&FSTBKNGTrackLink=" + e
    }
    if (d != "") {
        b += "&crossSelling=" + d
    }
    fbOpenWindow(a, b, "search", 800, 550)
}
function hhotelDispopriceFHP(b, j, a, d, c, g, k, e) {
    var h = FBRESA + "dispoprice.phtml?clusterName=" + b + "&Hotelnames=" + b;
    if (j != "") {
        h += "&langue=" + j
    }
    if (a != "") {
        h += "&FSTBKNGTrackLink=" + a
    }
    if (d != "") {
        h += "&fromyear=" + d
    }
    if (c != "") {
        h += "&frommonth=" + c
    }
    if (g != "") {
        h += "&fromday=" + g
    }
    if (k != "") {
        h += "&nbdays=" + k
    }
    if (e != "") {
        h += "&CurrencyLabel=" + e
    }
    h += "&showPromotions=3";
    fbOpenWindow(b, h, "reservation", 750, 600)
}

function xmlhttpPost(strURL, queryString)
{
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
    {
        if (self.xmlHttpReq.readyState == 4)
        {
            // updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(queryString);
}

function notifySH(myForm)
{
    var word = null;
    for(i=0; i<myForm.elements.length; i++)
    {
        //alert(myForm.elements[i].name + '=' + myForm.elements[i].value);
        word = word + myForm.elements[i].name + "=" + myForm.elements[i].value + "&";
    }
    
    xmlhttpPost("http://www.salleshotels.com/index_corp.php", word);
}

function hhotelDispoprice(a) {
    notifySH(a);
    hhotelFormValidation(a, 0)
}
function hhotelFormValidation(d, c) {
    if (c == 1 && d.AccessCode.value == "") {
        alert("You must type in your code ID");
        return (false)
    }
    d.action = FBRESA + "dispoprice.phtml";
    if (FB_useGoogleAnalytics) {
        sessId = generateSession();
        profilValue = escape("SESSION=" + sessId + "&CODE=GoogleAnalytics");
        if ((typeof d.profil) == "undefined") {
            var b = document.createElement("input");
            b.setAttribute("type", "hidden");
            b.setAttribute("name", "profil");
            b.setAttribute("value", profilValue);
            d.appendChild(b)
        } else {
            d.profil.value = profilValue
        }
    }
    window.open("", "dispoprice", "toolbar=no,width=800,height=550,menubar=no,scrollbars=yes,resizable=yes");
    d.submit();
    if (FB_useGoogleAnalytics) {
        var a = "";
        if ((typeof d.AccountName) != "undefined" && d.AccountName.value != "") {
            a = d.AccountName.value
        } else {
            a = d.Clusternames.value
        }
        transferGAdata(sessId, a)
    }
    return (true)
}
function hhotelFormUpdateHotelnames(a) {
    menuNum = a.HotelList.selectedIndex;
    if (menuNum == null) {
        return
    }
    a.Hotelnames.value = a.HotelList.options[menuNum].value
}
function hhotelFormCancel(b) {
    var a = b.Hotelnames.value;
    var c = typeof b.langue;
    var d;
    if (c == "undefined") {
        d = ""
    } else {
        d = b.langue.value
    }
    if (a == null || a == "All" || a == "") {
        alert("Please select a hotel first");
        return (false)
    }
    return hhotelcancel(a, d)
}
function hhotelFormExtract(b) {
    var a = b.Hotelnames.value;
    var c = typeof b.langue;
    var d;
    if (c == "undefined") {
        d = ""
    } else {
        d = b.langue.value
    }
    if (a == null || a == "All" || a == "") {
        alert("Please select a hotel first");
        return (false)
    }
    return hhotelExtract(a, d)
}
function hhotelShowLang(a) {
    hhotelShowLang__(this.document, a)
}
function hhotelShowLangOpener(a) {
    hhotelShowLang__(window.opener.document, a);
    window.close()
}
function hhotelShowLang__(b, c) {
    b.idForm.langue.value = c;
    var d = hhotelLang2Img(c);
    if (d != "") {
        var a = b.selLgFlag;
        if (a != null) {
            b.selLgFlag.src = "fastbooking/flags/" + d + ".gif"
        }
        var a = b.selLgTxt;
        if (a != null) {
            b.selLgTxt.src = "fastbooking/flags/" + d + "lg.gif"
        }
    }
}
var FBLangCode = new Array("uk", "france", "germany", "spain", "portuguese", "italy", "nether", "russian", "dansk", "svensk", "islensk", "norsk", "turk", "hungria", "greek", "arab", "china", "coreen", "japan", "croate", "czech", "poland");
var FBLangImg = new Array("grandbret", "france", "germany", "spain", "portuguese", "italy", "nether", "russia", "denmark", "sweeden", "iceland", "norway", "turkey", "hungary", "greek", "arab", "china", "coreen", "japan", "croate", "czech", "poland");

function hhotelLang2Img(a) {
    for (i = 0; i < FBLangCode.length; i++) {
        if (FBLangCode[i] == a) {
            break
        }
    }
    return FBLangImg[i]
}
function hhotelLangSelector() {
    window.open("fastbooking/flags/langSelector.html", "", "width=330,height=180")
}
var langcodes = new Array("en", "uk", "fr", "france", "de", "germany", "es", "spain ", "pt", "portuguese", "it", "italy", "nl", "nether", "ja", "japan ", "ko", "coreen", "zh", "china", "ar", "arab", "ru", "russian", "tr", "turk", "el", "greek", "hu", "hungria", "da", "dansk", "sv", "svensk", "is", "islensk", "no", "norsk", "hr", "croate", "cs", "czech", "pl", "poland", "iw", "hebrew");

function selectLang() {
    if (navigator.appName == "Microsoft Internet Explorer") {
        UL = navigator.userLanguage.substring(0, 2)
    } else {
        if (navigator.appName == "Netscape") {
            UL = navigator.language
        } else {
            return
        }
    }
    for (i = 0; i < langcodes.length; i += 2) {
        if (UL == langcodes[i]) {
            break
        }
    }
    lang = (i < langcodes.length) ? langcodes[i + 1] : "uk";
    hhotelShowLang(lang)
}
function build_year_select(b) {
    var a = new Date();
    var c = takeYear(a);
    cur_y = new Option(c, c, true, true);
    b.fromyear.options[0] = cur_y;
    if (b.toyear != null) {
        cur_yb = new Option(c, c, true, true);
        b.toyear.options[0] = cur_yb
    }
    next_y = new Option(c + 1, c + 1, false, false);
    b.fromyear.options[1] = next_y;
    next_yb = new Option(c + 1, c + 1, false, false);
    if (b.toyear != null) {
        b.toyear.options[1] = next_yb
    }
}
function check_departure() {
    thisform = document.idForm;
    if (thisform.today == null) {
        return
    }
    var g = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var e = parseInt(thisform.fromday.value) + 1;
    var b = parseInt(thisform.frommonth.value);
    var a = parseInt(thisform.fromyear.value);
    if (e > g[b - 1]) {
        e = 1;
        b += 1;
        if (b > 12) {
            b = 1;
            a += 1
        }
    }
    var c = new Date();
    var d = takeYear(c);
    thisform.today.selectedIndex = e - 1;
    thisform.tomonth.selectedIndex = b - 1;
    thisform.toyear.selectedIndex = a - d
}
function update_departure() {
    thisform = document.idForm;
    if (thisform.today == null) {
        return
    }
    var e = parseInt(thisform.fromday.value) + 1;
    var b = parseInt(thisform.frommonth.value);
    var a = parseInt(thisform.fromyear.value);
    var c = parseInt(thisform.today.value) + 1;
    var d = parseInt(thisform.tomonth.value);
    var g = parseInt(thisform.toyear.value);
    if (g < a) {
        check_departure()
    } else {
        if (g == a) {
            if (d < b) {
                check_departure()
            } else {
                if (d == b) {
                    if (c <= e) {
                        check_departure()
                    }
                }
            }
        }
    }
}
function takeYear(a) {
    x = a.getYear();
    var b = x % 100;
    b += (b < 38) ? 2000 : 1900;
    return b
}
function popup(a) {
    fbOpenWindow("", a, "", 800, 550)
};


