	var ggselda= "";
	var mmselda= "";
	var yyselda= "";
	var ggsela= "";
	var mmsela= "";
	var yysela= "";
	var date = "&ggselda=" + ggselda;
	date=date + "&mmselda=" + mmselda;
	date=date + "&yyselda=" + yyselda;
	date=date + "&ggsela=" + ggsela;
	date=date + "&mmsela=" + mmsela;
	date=date + "&yysela=" + yysela;
	date=date + "&npers=2&nstanze=1&nrag=0&nbebe=0";

function onclickGoSelMode(hotel,hotelkey,lingua,portale)
	{
	
		//la variabile lingua deve essere o IT o GB
		if(lingua == "uk" || lingua == "UK")
		{
			lingua = "GB";
		}
		//indica l'indirizzo della pagina
		var host="https://crs.hotelnet.biz/CRS/wbenew/Selection.aspx"
		var ind;
		ind = host + "?hotel=" + hotel + "&lingua=" + lingua + "&portale=" + portale;
		
		window.open(ind ,"Selezione","toolbar=no,location=no,scrollbars=yes,resizable=yes");
	}


function onclickGoSelModeExt(hotel,hotelkey,lingua,portale,dal,al,persone,camere)
	{

		//la variabile lingua deve essere o IT o GB
		if(lingua == "uk" || lingua == "UK")
		{
			lingua = "GB";
		}
		//indica l'indirizzo della pagina
		var host="https://crs.hotelnet.biz/CRS/wbenew/PreSelection.aspx"
		//Indica l'hotel che si vuol gestire
		//Gestione macrozone e micro zone
		var macro = "0";
		var micro = "0";
		//Comune e provincia di selezione
		var comune = "0";
		var prov = "0";
		//Cordinate GPS
		var lon = "00-00-00";
		var lat = "00-00-00";
		var raggio = 0;
		var w = 750;
		var h = 580;	

		//alert(dal);
		//alert(al);

		var dalS = new String(dal);
		var alS = new String(al);

		var dalH = dalS.split("/");
		var alH = alS.split("/");


		var ind;
		ind = host + "?hotel=" + hotel + "&hotelkey=" + hotelkey; 
		ind = ind + "&lingua=" + lingua;
		ind = ind + "&portale=" + portale;
		ind = ind + "&arrivo=" + dalH[2] + "-" + dalH[1].lpad("0", 2) + "-" + dalH[0].lpad("0", 2) + "&partenza=" + alH[2] + "-" + alH[1].lpad("0", 2) + "-" + alH[0].lpad("0", 2) + "&camere=" + camere;
		//window.alert(date);
		//return ind;		
		//alert(ind);
	
		window.open(ind ,"Selezione","toolbar=no,location=no,scrollbars=yes,resizable=yes");	
	}


var dictionary = [];
dictionary["IT"] = { "Arrival": "Arrivo", "Nights": "Notti", "Rooms": "Camere", "Room": "Camera", "Adults": "Adulti", "Children": "Bambini", "AgeChild": "Eta bimbo", "Book": "Prenota ora", "InsNum": "Inserire un valore numerico" };
dictionary["GB"] = { "Arrival": "Arrival", "Nights": "Nights", "Rooms": "Rooms", "Room": "Room", "Adults": "Adults", "Children": "Children", "AgeChild": "Age child", "Book": "Book now", "InsNum": "Please insert a numeric value" };
dictionary["FR"] = { "Arrival": "Date d'arrivée", "Nights": "Nuitées", "Rooms": "Chambres", "Room": "Chambre", "Adults": "Adultes", "Children": "Enfants", "AgeChild": "Age", "Book": "Rechercher", "InsNum": "SVP inserez un chiffre" };
dictionary["DE"] = { "Arrival": "Anreisedatum", "Nights": "Naechte", "Rooms": "Zimmer", "Room": "Zimmer", "Adults": "Erwachsene", "Children": "Kinder", "AgeChild": "Alter", "Book": "Buchen", "InsNum": "Geben Sie bitte einen numerischen Wert" };


function createBookingForm(args) {

    var hotel, language, portal, rooms, open_type, crs_version

        if (arguments.length < 3) return false;

        hotel = arguments[0];
        language = arguments[1];
        portal = arguments[2];

        if (arguments.length > 3) {
            rooms = arguments[3];
        }
        else {
            rooms = "2";
        }

        // 0 = pop-up, 1 = redirect, 2 = frame
        if (arguments.length > 4) {
            open_type = arguments[4];
        }

		crs_version = "0";
		
        if (arguments.length > 5) {
            crs_version = arguments[5];
        }

        var d = new Date();
        year = d.getFullYear();

        var bookingPara = document.getElementById("bookingParagraph");
        bookingPara.innerHTML = "";
        var bookingForm = document.createElement("form");

        var arrivalDaySelect = document.createElement("select");
        arrivalDaySelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 31; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            if (i + 1 == d.getDate()) {
                theOption.setAttribute("selected", "true");
            }
            theOption.setAttribute("value", i + 1);
            arrivalDaySelect.appendChild(theOption);
        }

        var arrivalMonthSelect = document.createElement("select");
        arrivalMonthSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 12; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            if (i == d.getMonth()) {
                theOption.setAttribute("selected", "true");
            }
            theOption.setAttribute("value", i + 1);
            arrivalMonthSelect.appendChild(theOption);
        }

        var arrivalYearSelect = document.createElement("select");
        arrivalYearSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 2; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(year + i);
            theOption.appendChild(theText);
            theOption.setAttribute("value", year + i);
            arrivalYearSelect.appendChild(theOption);
        }

        arrivalText = document.createTextNode("{0}: ".format(dictionary[language]["Arrival"]));
        bookingForm.appendChild(arrivalText);
        bookingForm.appendChild(arrivalDaySelect);
        bookingForm.appendChild(arrivalMonthSelect);
        bookingForm.appendChild(arrivalYearSelect);

        parBreak = document.createElement("p");
        bookingForm.appendChild(parBreak);

        nightsText = document.createTextNode("{0}: ".format(dictionary[language]["Nights"]));
        bookingForm.appendChild(nightsText);

        var nightsSelect = document.createElement("select");
        nightsSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 30; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            theOption.setAttribute("value", i + 1);
            nightsSelect.appendChild(theOption);
        }
        bookingForm.appendChild(nightsSelect);


        roomText = document.createTextNode(" {0}: ".format(dictionary[language]["Rooms"]));
        bookingForm.appendChild(roomText);

        var roomSelect = document.createElement("select");
        roomSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < parseInt(rooms); i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            theOption.setAttribute("value", i + 1);
            roomSelect.appendChild(theOption);
        }

        var roomsForm = document.createElement("form");

        bookingForm.appendChild(roomSelect);

        bookingPara.appendChild(bookingForm);

        roomSelect.onchange = AddPeople;

        AddPeople();

        bookingPara.appendChild(roomsForm);

        var buttonForm = document.createElement("form");

        parPeople = document.createElement("p");
        buttonForm.appendChild(parPeople);

        bookingButton = document.createElement("BUTTON");
        bookingButton.setAttribute("class", "bookingButton");
        theText = document.createTextNode(dictionary[language]["Book"]);

        bookingButton.appendChild(theText);
        bookingButton.onclick = bookingButtonClick;

        buttonForm.appendChild(bookingButton);

        bookingPara.appendChild(buttonForm);



        function bookingButtonClick(e) {

            //la variabile lingua deve essere o IT o GB
            if (language == "uk" || language == "UK") {
                language = "GB";
            }
            //indica l'indirizzo della pagina
            var folder = (portal == "0000") ? "wbenew" : "portale";
            //var host = "http://localhost:4736/CRS/" + folder + "/PreSelection.aspx"
            var host = "";
			if(crs_version == "0")
			{
				host = "http://crs.hotelnet.biz/CRS/" + folder + "/PreSelection.aspx";
			}
			else
			{
				host = "http://crs.hotelnet.biz/CRS.Portal/channel/PreSelection.aspx";
			}
			
            var w = 750;
            var h = 580;

            var ind;
            var arrivalDate = new Date(arrivalYearSelect.options[arrivalYearSelect.selectedIndex].value, arrivalMonthSelect.selectedIndex, arrivalDaySelect.options[arrivalDaySelect.selectedIndex].value);
            var departureDate = new Date(arrivalYearSelect.options[arrivalYearSelect.selectedIndex].value, arrivalMonthSelect.selectedIndex, parseInt(arrivalDaySelect.options[arrivalDaySelect.selectedIndex].value) + parseInt(nightsSelect.options[nightsSelect.selectedIndex].value));

            var roomDetails = new String("!");

            for (k = 0; k < roomSelect.options[roomSelect.selectedIndex].value; k++) {
                adultSelect = document.getElementById("adultSelect-" + k);
                roomDetails += adultSelect.options[adultSelect.selectedIndex].value;
                childSelect = document.getElementById("childSelect-" + k);
                if (childSelect.options[childSelect.selectedIndex].value != "0") {
                    roomDetails += "-" + childSelect.options[childSelect.selectedIndex].value;

                    for (l = 0; l < childSelect.options[childSelect.selectedIndex].value; l++) {
                        var ageTextbox = document.getElementById("childTextbox-" + k + l);
                        if (isNaN(parseInt(ageTextbox.value))) {
                            alert(dictionary[language]["InsNum"]);
                            return false;
                        }
                        roomDetails += "-" + ageTextbox.value;
                    }
                }

                if (k != parseInt(roomSelect.options[roomSelect.selectedIndex].value) - 1) {
                    roomDetails += "*";
                }
            }

            ind = host + "?hotel=" + hotel;
            ind = ind + "&lingua=" + language;
            ind = ind + "&portale=" + portal;
            ind = ind + "&arrivo=" + arrivalDate.getFullYear() + "-" + padNum(arrivalDate.getMonth() + 1) + "-" + padNum(arrivalDate.getDate()) + "&partenza=" + departureDate.getFullYear() + "-" + padNum(departureDate.getMonth() + 1) + "-" + padNum(departureDate.getDate()) + "&camere=" + roomSelect.options[roomSelect.selectedIndex].value + roomDetails;
            //window.alert(date);
            //return ind;		
            //alert(ind);

            if (open_type == "1") {
                location.href = ind;
                return false;
            }
			else if (open_type == "2") {
				var bookingFrame = document.getElementById("bookingFrame");
				bookingFrame.src = ind;
				//alert(bookingFrame.offsetTop);
				window.scrollTo(0, 600)
                return false;
            }
            else {
                window.open(ind, "Selezione", "toolbar=yes,location=no,scrollbars=yes,resizable=yes");
            }
        }


        function AddPeople(e) {

            //debugger;

            if (roomsForm.hasChildNodes()) {
                while (roomsForm.childNodes.length >= 1) {
                    roomsForm.removeChild(roomsForm.firstChild);
                }
            }

            for (i = 0; i < parseInt(roomSelect.options[roomSelect.selectedIndex].value); i++) {

                parBreak = document.createElement("p");
                roomsForm.appendChild(parBreak);

                roomText = document.createTextNode("{0}: ".format(dictionary[language]["Room"]) + (parseInt(i) + 1));
                roomsForm.appendChild(roomText);

                parBreak = document.createElement("p");
                roomsForm.appendChild(parBreak);

                roomText = document.createTextNode("{0}: ".format(dictionary[language]["Adults"]));
                roomsForm.appendChild(roomText);

                var adultSelect = document.createElement("select");
                adultSelect.setAttribute("class", "bookingSelect");
                for (j = 0; j < 4; j++) {
                    theOption = document.createElement("OPTION");
                    theText = document.createTextNode(j + 1);
                    theOption.appendChild(theText);
                    theOption.setAttribute("value", j + 1);
					if(j == 1)
					{
						theOption.setAttribute("selected", true);
					}
                    adultSelect.appendChild(theOption);
                }
                adultSelect.setAttribute("id", "adultSelect-" + i);
                roomsForm.appendChild(adultSelect);

                roomText = document.createTextNode(" {0}: ".format(dictionary[language]["Children"]));
                roomsForm.appendChild(roomText);

                var childSelect = document.createElement("select");
                childSelect.setAttribute("class", "bookingSelect");
                for (j = 0; j < 3; j++) {
                    theOption = document.createElement("OPTION");
                    theText = document.createTextNode(j);
                    theOption.appendChild(theText);
                    theOption.setAttribute("value", j);
                    childSelect.appendChild(theOption);
                }

                childSelect.setAttribute("id", "childSelect-" + i);
                childSelect.onchange = function () { AddChildAges(this.getAttribute("id")); }
                roomsForm.appendChild(childSelect);

                var childAgeForm = document.createElement("form");
                childAgeForm.setAttribute("id", "childAgeForm-" + i)
                roomsForm.appendChild(childAgeForm);
            }

            function AddChildAges(id) {

                var s = new String(id);
                var i = s.split("-")[1];

                var myForm = document.getElementById("childAgeForm-" + i);
                if (myForm.hasChildNodes()) {
                    while (myForm.childNodes.length >= 1) {
                        myForm.removeChild(myForm.firstChild);
                    }
                }

                var myChildSelect = document.getElementById("childSelect-" + i);
                for (j = 0; j < parseInt(myChildSelect.options[myChildSelect.selectedIndex].value); j++) {
                    childAgeText = document.createTextNode(" {0}: ".format(dictionary[language]["AgeChild"]) + (parseInt(j) + 1) + " ");
                    myForm.appendChild(childAgeText);
                    var childAgeTextBox = document.createElement("input");
                    childAgeTextBox.setAttribute("class", "bookingTextBox");
                    childAgeTextBox.setAttribute("style", "width: 25px");
                    childAgeTextBox.setAttribute("id", "childTextbox-" + i + j)
                    myForm.appendChild(childAgeTextBox);
                }
            }
        }
    }
	
	
function createHorizontalBookingForm(args) {

    var hotel, language, portal, rooms, open_type, crs_version

        if (arguments.length < 3) return false;

        hotel = arguments[0];
        language = arguments[1];
        portal = arguments[2];

        if (arguments.length > 3) {
            rooms = arguments[3];
        }
        else {
            rooms = "2";
        }

        // 0 = pop-up, 1 = redirect, 2 = frame
        if (arguments.length > 4) {
            open_type = arguments[4];
        }

		crs_version = "0";
		
        if (arguments.length > 5) {
            crs_version = arguments[5];
        }

        var d = new Date();
        year = d.getFullYear();

        var bookingPara = document.getElementById("bookingParagraph");
        bookingPara.innerHTML = "";
        var bookingForm = document.createElement("form");

        var arrivalDaySelect = document.createElement("select");
        arrivalDaySelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 31; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            if (i + 1 == d.getDate()) {
                theOption.setAttribute("selected", "true");
            }
            theOption.setAttribute("value", i + 1);
            arrivalDaySelect.appendChild(theOption);
        }

        var arrivalMonthSelect = document.createElement("select");
        arrivalMonthSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 12; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            if (i == d.getMonth()) {
                theOption.setAttribute("selected", "true");
            }
            theOption.setAttribute("value", i + 1);
            arrivalMonthSelect.appendChild(theOption);
        }

        var arrivalYearSelect = document.createElement("select");
        arrivalYearSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 2; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(year + i);
            theOption.appendChild(theText);
            theOption.setAttribute("value", year + i);
            arrivalYearSelect.appendChild(theOption);
        }

        arrivalText = document.createTextNode("{0}: ".format(dictionary[language]["Arrival"]));
		
		var arrivalSpan = document.createElement("span");
		
        arrivalSpan.appendChild(arrivalText);
        arrivalSpan.appendChild(arrivalDaySelect);
        arrivalSpan.appendChild(arrivalMonthSelect);
        arrivalSpan.appendChild(arrivalYearSelect);
		
		bookingForm.appendChild(arrivalSpan);

        // parBreak = document.createElement("p");
        // bookingForm.appendChild(parBreak);

		var nightsSpan = document.createElement("span");
		
        nightsText = document.createTextNode("{0}: ".format(dictionary[language]["Nights"]));
        nightsSpan.appendChild(nightsText);

        var nightsSelect = document.createElement("select");
        nightsSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < 30; i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            theOption.setAttribute("value", i + 1);
            nightsSelect.appendChild(theOption);
        }
        nightsSpan.appendChild(nightsSelect);

		bookingForm.appendChild(nightsSpan);

		var roomsSpan = document.createElement("span");
		
        roomText = document.createTextNode(" {0}: ".format(dictionary[language]["Rooms"]));
        roomsSpan.appendChild(roomText);

        var roomSelect = document.createElement("select");
        roomSelect.setAttribute("class", "bookingSelect");
        for (i = 0; i < parseInt(rooms); i++) {
            theOption = document.createElement("OPTION");
            theText = document.createTextNode(i + 1);
            theOption.appendChild(theText);
            theOption.setAttribute("value", i + 1);
            roomSelect.appendChild(theOption);
        }
		
        roomsSpan.appendChild(roomSelect);
		
		if(parseInt(rooms) == 1)
		{
			roomsSpan.style.display = "none";
		}

		bookingForm.appendChild(roomsSpan);

        var roomsForm = document.createElement("span");


        roomSelect.onchange = AddPeople;

        AddPeople();

        bookingForm.appendChild(roomsForm);

        var buttonForm = document.createElement("span");

        // parPeople = document.createElement("p");
        // buttonForm.appendChild(parPeople);

        bookingButton = document.createElement("BUTTON");
        bookingButton.setAttribute("class", "bookingButton");
        theText = document.createTextNode(dictionary[language]["Book"]);

        bookingButton.appendChild(theText);
        bookingButton.onclick = bookingButtonClick;

        buttonForm.appendChild(bookingButton);

        bookingForm.appendChild(buttonForm);

        bookingPara.appendChild(bookingForm);


        function bookingButtonClick(e) {

            //la variabile lingua deve essere o IT o GB
            if (language == "uk" || language == "UK") {
                language = "GB";
            }
            //indica l'indirizzo della pagina
            var folder = (portal == "0000") ? "wbenew" : "portale";
            //var host = "http://localhost:4736/CRS/" + folder + "/PreSelection.aspx"
            var host = "";
			if(crs_version == "0")
			{
				host = "http://crs.hotelnet.biz/CRS/" + folder + "/PreSelection.aspx";
			}
			else
			{
				host = "http://crs.hotelnet.biz/CRS.Portal/channel/PreSelection.aspx";
			}
			
            var w = 750;
            var h = 580;

            var ind;
            var arrivalDate = new Date(arrivalYearSelect.options[arrivalYearSelect.selectedIndex].value, arrivalMonthSelect.selectedIndex, arrivalDaySelect.options[arrivalDaySelect.selectedIndex].value);
            var departureDate = new Date(arrivalYearSelect.options[arrivalYearSelect.selectedIndex].value, arrivalMonthSelect.selectedIndex, parseInt(arrivalDaySelect.options[arrivalDaySelect.selectedIndex].value) + parseInt(nightsSelect.options[nightsSelect.selectedIndex].value));

            var roomDetails = new String("!");

            for (k = 0; k < roomSelect.options[roomSelect.selectedIndex].value; k++) {
                adultSelect = document.getElementById("adultSelect-" + k);
                roomDetails += adultSelect.options[adultSelect.selectedIndex].value;
                childSelect = document.getElementById("childSelect-" + k);
                if (childSelect.options[childSelect.selectedIndex].value != "0") {
                    roomDetails += "-" + childSelect.options[childSelect.selectedIndex].value;

                    for (l = 0; l < childSelect.options[childSelect.selectedIndex].value; l++) {
                        var ageTextbox = document.getElementById("childTextbox-" + k + l);
                        if (isNaN(parseInt(ageTextbox.value))) {
                            alert(dictionary[language]["InsNum"]);
                            return false;
                        }
                        roomDetails += "-" + ageTextbox.value;
                    }
                }

                if (k != parseInt(roomSelect.options[roomSelect.selectedIndex].value) - 1) {
                    roomDetails += "*";
                }
            }

            ind = host + "?hotel=" + hotel;
            ind = ind + "&lingua=" + language;
            ind = ind + "&portale=" + portal;
            ind = ind + "&arrivo=" + arrivalDate.getFullYear() + "-" + padNum(arrivalDate.getMonth() + 1) + "-" + padNum(arrivalDate.getDate()) + "&partenza=" + departureDate.getFullYear() + "-" + padNum(departureDate.getMonth() + 1) + "-" + padNum(departureDate.getDate()) + "&camere=" + roomSelect.options[roomSelect.selectedIndex].value + roomDetails;
            //window.alert(date);
            //return ind;		
            //alert(ind);

            if (open_type == "1") {
                location.href = ind;
                return false;
            }
			else if (open_type == "2") {
				var bookingFrame = document.getElementById("bookingFrame");
				bookingFrame.src = ind;
				//alert(bookingFrame.offsetTop);
				window.scrollTo(0, 600)
                return false;
            }
            else {
                window.open(ind, "Selezione", "toolbar=yes,location=no,scrollbars=yes,resizable=yes");
            }
        }


        function AddPeople(e) {

            //debugger;

            if (roomsForm.hasChildNodes()) {
                while (roomsForm.childNodes.length >= 1) {
                    roomsForm.removeChild(roomsForm.firstChild);
                }
            }

            for (i = 0; i < parseInt(roomSelect.options[roomSelect.selectedIndex].value); i++) {

				if(parseInt(rooms) != 1)
				{
				    roomText = document.createTextNode("{0}: ".format(dictionary[language]["Room"]) + (parseInt(i) + 1) + " ");
					roomsForm.appendChild(roomText);
				}

                // parBreak = document.createElement("p");
                // roomsForm.appendChild(parBreak);

                roomText = document.createTextNode("{0}: ".format(dictionary[language]["Adults"]));
                roomsForm.appendChild(roomText);

                var adultSelect = document.createElement("select");
                adultSelect.setAttribute("class", "bookingSelect");
                for (j = 0; j < 4; j++) {
                    theOption = document.createElement("OPTION");
                    theText = document.createTextNode(j + 1);
                    theOption.appendChild(theText);
                    theOption.setAttribute("value", j + 1);
					if(j == 1)
					{
						theOption.setAttribute("selected", true);
					}
                    adultSelect.appendChild(theOption);
                }
                adultSelect.setAttribute("id", "adultSelect-" + i);
                roomsForm.appendChild(adultSelect);

                roomText = document.createTextNode(" {0}: ".format(dictionary[language]["Children"]));
                roomsForm.appendChild(roomText);

                var childSelect = document.createElement("select");
                childSelect.setAttribute("class", "bookingSelect");
                for (j = 0; j < 3; j++) {
                    theOption = document.createElement("OPTION");
                    theText = document.createTextNode(j);
                    theOption.appendChild(theText);
                    theOption.setAttribute("value", j);
                    childSelect.appendChild(theOption);
                }

                childSelect.setAttribute("id", "childSelect-" + i);
                childSelect.onchange = function () { AddChildAges(this.getAttribute("id")); }
                roomsForm.appendChild(childSelect);

                var childAgeForm = document.createElement("span");
                childAgeForm.setAttribute("id", "childAgeForm-" + i)
                roomsForm.appendChild(childAgeForm);
				
				// parBreak = document.createElement("p");
                // roomsForm.appendChild(parBreak);
            }

            function AddChildAges(id) {

                var s = new String(id);
                var i = s.split("-")[1];

                var myForm = document.getElementById("childAgeForm-" + i);
                if (myForm.hasChildNodes()) {
                    while (myForm.childNodes.length >= 1) {
                        myForm.removeChild(myForm.firstChild);
                    }
                }

                var myChildSelect = document.getElementById("childSelect-" + i);
                for (j = 0; j < parseInt(myChildSelect.options[myChildSelect.selectedIndex].value); j++) {
                    childAgeText = document.createTextNode(" {0}: ".format(dictionary[language]["AgeChild"]) + (parseInt(j) + 1) + " ");
                    myForm.appendChild(childAgeText);
                    var childAgeTextBox = document.createElement("input");
                    childAgeTextBox.setAttribute("class", "bookingTextBox");
                    childAgeTextBox.setAttribute("style", "width: 25px");
                    childAgeTextBox.setAttribute("id", "childTextbox-" + i + j)
                    myForm.appendChild(childAgeTextBox);
                }
            }
        }
    }

function showOffers(hotelCode, hotelKey, channelCode, channelKey, languageCode) {
        //alert(languageCode);
        $.getJSON("http://webservice.hotelnet.biz/ws/soa/ajax/webservice.asmx/GetOffers?parameters='" + hotelCode + "-" + channelCode + "-" + languageCode + "'&callback=?&format=json", function (data) {
        //$.getJSON("http://localhost:52957/SOAWebServices/ajax/webservice.asmx/GetOffers?parameters='" + hotelCode + "-" + channelCode + "-" + languageCode + "'&callback=?&format=json", function (data) {
            //alert(data.d);
            var products = eval('(' + data.d + ')');
            var offersDiv = document.getElementById('offersDiv');

            for (var i = 0; i < products.length; i++) {
			
				var offerDiv = document.createElement('div');
				offerDiv.setAttribute('class', 'Offer');	
                var name = products[i].Name;
                //alert(products[i].Link);
                if (products[i].HotelName != "") {
                    name = products[i].HotelName + " - " + name;
                }
                var description = products[i].Description;
                var namediv = document.createElement('p');
                namediv.innerHTML = name;
                namediv.setAttribute('class', 'OfferName');				
                offerDiv.appendChild(namediv);
                var desdiv = document.createElement('p');
                desdiv.innerHTML = description + ' <br><br><a href="' + products[i].Link + '" class="OffersLink" target="BLANK">' + dictionary[languageCode]["Book"] + '</a>';
                desdiv.setAttribute('class', 'OfferDescription');
				offerDiv.appendChild(desdiv);
				
				offersDiv.appendChild(offerDiv);
            }
			
			if(typeof shapeOffers == 'function') {
				shapeOffers();
			}
			
        });
	
    }

    
    String.prototype.format = function () {
        var pattern = /\{\d+\}/g;
        var args = arguments;
        return this.replace(pattern, function (capture) { return args[capture.match(/\d+/)]; });
    }

	function getHost() {
    var url = new String(window.location);
    var urlparts = url.split('/');
    var host = urlparts[2];
    alert(host);
}
	
function padNum(inNum) {
    var outNum = inNum.toString();
    while (outNum.length < 2) {
        outNum = "0" + outNum;
    }
    return outNum;
}

String.prototype.lpad = function(padString, length) {
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
}

