    var head = document.getElementsByTagName('head')[0];
var url = window.location.href;
if (url.indexOf("reserve") != -1) {
    if (head) {
        var scriptStyles = document.createElement("link");
        scriptStyles.rel = "stylesheet";
        scriptStyles.type = "text/css";
        scriptStyles.href = "/css/datepicker.css";
        head.appendChild(scriptStyles);
    }
}
else {
    if (head) {
        var scriptStyles = document.createElement("link");
        scriptStyles.rel = "stylesheet";
        scriptStyles.type = "text/css";
        scriptStyles.href = "/css/datepicker_small.css";
        head.appendChild(scriptStyles);
    }
}


// Show-Hide Dropdown Menu
 // Show-Hide Dropdown Menu 
function showlayer(layer) {
    var objLayer = document.getElementById(layer);
    objLayer.isOn = true;
    var myLayer = objLayer.style.display;
    if (myLayer == "none") {
        document.getElementById(layer).style.display = "block";
    }
}

$(document).ready(function() {
    $('#photos').galleryView({
        filmstrip_size: 4,
        frame_width: 50,
        frame_height: 50,
        background_color: 'transparent',
        nav_theme: 'dark',
        border: 'none',
        transition_interval: 0,
        caption_text_color: 'white'
    });
    

//    $('#calendarStep-Tab').click(function() { doBackToCalendarStep(); event.stopPropagation(); });
//    $('#chooseRoomStep-Tab').click(function() { doBackToChooseRoomStep(); event.stopPropagation(); });
//    $('#confirmRoomStep-Tab').click(function() { doBackToConfirmRoomStep(); event.stopPropagation(); });
});

function resizeImages(imageCssClass, maxHeight, maxWidth)
{
    $('.' + imageCssClass + ' img').each(function() {
        //var maxWidth = 140; // Max width for the image
        //var maxHeight = 140;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height

        // Check if the current width is larger than the max
        if (width > maxWidth) {
            ratio = maxWidth / width;   // get ratio for scaling image
            // $(this).css("width", maxWidth); // Set new width
            // $(this).css("height", Math.ceil(height * ratio));  // Scale height based on ratio
            $(this).removeAttr('width');
            $(this).attr("width", maxWidth); // Set new width
            $(this).removeAttr('height');
            $(this).attr("height", Math.ceil(height * ratio));  // Scale height based on ratio            
            height =Math.ceil(height * ratio);    // Reset height to match scaled image
            width = Math.ceil(width * ratio);    // Reset width to match scaled image
        }

        // Check if current height is larger than max
        if (height > maxHeight) {
            ratio = maxHeight / height; // get ratio for scaling image
            //$(this).css("height", maxHeight);   // Set new height
            //$(this).css("width", Math.ceil(width * ratio));    // Scale width based on ratio
            $(this).removeAttr('height');
            $(this).attr("height", maxHeight);   // Set new height
            $(this).removeAttr('width');
            $(this).attr("width", Math.ceil(width * ratio));    // Scale width based on ratio
            width = Math.ceil(width * ratio);    // Reset width to match scaled image
        }

        

    });
}



function setToolTip(evt, elem, text) {

    document.getElementById("toolTipChooseRoom").style.display = "none";
    $('#toolTipDiv').text(text);

    var xArrow = $('#toolTipDiv').width();
    var xyElem = getPos(elem);
    var offsetx = $('#toolTipDiv').width() - 50;

    if (document.getElementById("FirstTool").value == "1") {

        $("#toolTipDiv").animate({ "left": xyElem.x - offsetx - 25 }, "fast");
        $("#toolTipDiv2").animate({ "left": xyElem.x - offsetx - 25 + xArrow }, "fast");
    }
    else {
        document.getElementById("FirstTool").value = "1";

        $("#toolTipDiv").animate({ "left": xyElem.x - offsetx - 25 }, "fast");
        $("#toolTipDiv2").animate({ "left": xyElem.x - offsetx - 25 + xArrow }, "fast");
    }

    document.getElementById("toolTipDiv").style.display = "block";
    document.getElementById("toolTipDiv2").style.display = "block";
}

function getPos(el) {
    // yay readability
    for (var lx = 0, ly = 0;
         el != null;
         lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent);
    return { x: lx, y: ly };
}

function hideToolTip() {
    document.getElementById("toolTipChooseRoom").style.display = "none";
    document.getElementById("toolTipDiv").style.display = "none";
    document.getElementById("toolTipDiv2").style.display = "none";
}
var isRoomStripOn = false;
function hideToolTipChoose() {
    isRoomStripOn = true;
    setTimeout('hideToolTipChooseTimed()', 100);
}

function hideToolTipChooseTimed() {
    if (isRoomStripOn) {
        document.getElementById("toolTipChooseRoom").style.display = "none";
    }
}

function showToolTipChoose() {
    isRoomStripOn = false;
    setTimeout('showToolTipChooseTimed()', 100);
}

function showToolTipChooseTimed() {
    if (!isRoomStripOn) {
        document.getElementById("toolTipChooseRoom").style.display = "block";
    }
}

function hidelayer(layer) {
    var objLayer = document.getElementById(layer);
    objLayer.isOn = false;
    setTimeout("timedHideLayer('" + layer + "')", 100);
}

function timedHideLayer(layer) {
    var objLayer = document.getElementById(layer);
    if (!objLayer.isOn) {
        objLayer.style.display = "none";
    }
}

function setBackGround(image) {
    $("#imgBackground").attr("src", image);
}

function showFeatureTabs(layer) {
    showFeatureTabs(layer, '');
}

function showFeatureTabs(layer, idScroll) {
    var tabs1 = document.getElementById("tabs-1");
    var tabs2 = document.getElementById("tabs-2");
    var tabs3 = document.getElementById("tabs-3");
    var tabs4 = document.getElementById("tabs-4");
    var tabsC = document.getElementById(layer);

    if (tabs1 != null) {
        //tabs1.parentNode.style.display = "none";
        tabs1.style.display = "none";
    }

    if (tabs2 != null) {
        //tabs2.parentNode.style.display = "none";
        tabs2.style.display = "none";
    }

    if (tabs3 != null) {
        //tabs3.parentNode.style.display = "none";
        tabs3.style.display = "none";
    }

    if (tabs4 != null) {
        //tabs4.parentNode.style.display = "none";
        tabs4.style.display = "none";
    }

    if (tabsC != null) {
        //tabsC.parentNode.style.display = "block";
        tabsC.style.display = "block";
    }

    if (idScroll != '') {
        if ($('#' + idScroll) != null) {
            $('#' + idScroll).jScrollPane({ scrollbarWidth: 20, scrollbarMargin: 10 });
            $('#' + idScroll).jScrollPane();
        }
    }
}

function showFeatureTabsOver(obj, tabDetailName) {
    if (document.getElementById(tabDetailName).style.display == 'none') {
        obj.style.backgroundColor = "#CCC";
    }
}
function showFeatureTabsOut(obj, tabDetailName) {
    obj.style.backgroundColor = "";
}

//Set the btnHotels (check availability) function 
$(function() {
    $('#btnHotels').click(doQuickBooking);
});

//Send to the reserve page with the parameters. Show the second page of the reserve.
function doQuickBooking() {
    var errorMessage = "";
    //document.getElementById("errorDateCurrent").style.display = "none";
    //document.getElementById("errorDate").style.display = "none";
    var ddHotelsValue = document.getElementById("ddHotels").value;
    var ddAdultsValue = document.getElementById("ddAdults").value;

    txtCheckId = document.getElementById("txtChekIn").value;
    txtCheckOut = document.getElementById("txtChekOut").value;

    var startDate = new Date(txtCheckId);
    var endDate = new Date(txtCheckOut);
    var now = new Date();
    //now = new Date(now.getMonth() + "/" + now.getDate() + "/" + now.getFullYear());
    if (ddHotelsValue != "") {
        if (calcJulian(startDate) < calcJulian(endDate)) {
            if (calcJulian(startDate) >= calcJulian(now)) {
                document.getElementById("errorDate").style.display = "none";
                datePartsCheckIn = txtCheckId.split('/');
                datePartsCheckOut = txtCheckOut.split('/');

                propCode = document.getElementById("ddHotels").value;

                window.location.href = "/reserve?" + "showPop=1&" + "propCode=" + propCode + "&startDate=" + datePartsCheckIn[0] + datePartsCheckIn[1] + datePartsCheckIn[2] + "&endDate=" + datePartsCheckOut[0] + datePartsCheckOut[1] + datePartsCheckOut[2] + "&adults=" + ddAdultsValue;
            }
            else {
                //document.getElementById("errorDate").style.display = "block";
                errorMessage += "- The Check-in date needs to be for the current date or a date in the future.\r\n";
            }
        }
        else {
            //document.getElementById("errorDate").style.display = "block";
            errorMessage += "- The Check-out date needs to be for the current date or a date in the future.\r\n";
        }
    }
    else {
        errorMessage += "- Please choose a hotel\r\n";
    }
    if (errorMessage != "") {
        alert(errorMessage);
    }
}




//Get hotels, is used to call the web-service
function getHotelsFromQuickBooking() {
    $(document).ready(function() {
	
		try { pageTracker._trackEvent('Reserve', 'GetHotelsQuickBooking'); } catch (err) { }
		try { pageTracker._trackPageview('/Reserve/GetHotelsQuickBooking'); } catch (err) { }
		

		
        var roomsRatePlanCode = "";
        var showPop = getParameterByName("showPop");

        document.getElementById("backDiv").style.display = "none";
		
		if (document.getElementById("btnClear") != null)
			document.getElementById("btnClear").style.display = "block";
		
        document.getElementById("backDivEmpty").style.display = "block";

		blockUpcomingSteps("calendarStep");
		
        $('#hotelsList').empty();
		
		var htmlTMP = "<div class=\"transparency\"></div><div id=\"scrollRoom\"><span style='color:white;display:block;padding:130px 0 4px 145px;font-family:Century Gothic, Trebuchet MS, Verdana, Sans-Serif;font-size:14px;text-transform:uppercase;'>Loading...</span><img style='margin-left:135px;' src=\"/images/progressbar.gif\"></div></div>";

        $('#hotelsList').append(htmlTMP);

        if (showPop == 1) {

            document.getElementById("backDiv").style.display = "block";
			
			if (document.getElementById("btnClear") != null)
				document.getElementById("btnClear").style.display = "none";
			
            document.getElementById("backDivEmpty").style.display = "none";
            document.getElementById("btnCheckAvail").style.display = "none";

	   var startDate = getParameterByName("startDate");
            var endDate = getParameterByName("endDate");
            propCode = getParameterByName("propCode");
            adultsNum = getParameterByName("adults");

            //            adultsNum = "2";



            if (paramsValid(startDate, endDate, propCode, adultsNum)) {

                //show the div and get the data from web service


                document.getElementById("calendarStep").style.display = "none";
                document.getElementById("confirmRoomStep").style.display = "none";
                document.getElementById("chooseRoomStep").style.display = "block";

                backDivId = "calendarStep";

                document.getElementById("calendarStep-Tab").className = "completed";
                document.getElementById("confirmRoomStep-Tab").className = "";
                document.getElementById("chooseRoomStep-Tab").className = "active";

                document.getElementById("txtChekInCheck").value = (startDate.substring(0, 2) + '/' + startDate.substring(2, 4) + '/' + startDate.substring(4, 8));
                document.getElementById("txtChekOutCheck").value = (endDate.substring(0, 2) + '/' + endDate.substring(2, 4) + '/' + endDate.substring(4, 8));

                document.getElementById("ddlRoomsNum").value = adultsNum;

                //disble the text boxes
                $('#txtPromCode').attr("disabled", true);
                $('#txtIATA').attr("disabled", true);
                $('#txtChekInCheck').attr("disabled", true);
                $('#txtChekOutCheck').attr("disabled", true);
                $('#ddlRoomsNum').attr("disabled", true);

                txtCheckId = document.getElementById("txtChekInCheck").value;
                txtCheckOut = document.getElementById("txtChekOutCheck").value;

                datePartsCheckIn = txtCheckId.split('/');
                datePartsCheckOut = txtCheckOut.split('/');

                rooms = document.getElementById("ddlRoomsNum").value;
                iataNum = document.getElementById("txtIATA").value;


                //set the dropdown
                var ddHotels = document.getElementById('ddHotels');
                for (var i = 0; i < ddHotels.options.length; i++) {
                    if (ddHotels.options[i].value == propCode) {
                        ddHotels.options[i].selected = true;
                    }
                }

                $('#ddHotels').attr("disabled", true);

                var ratePlanCode = document.getElementById("txtPromCode").value;
                var forcePromoResult = "false";

                if (ratePlanCode != "")
                    forcePromoResult = "true";

                if (ratePlanCode == "")
                    ratePlanCode = "LV0";

                if (getParameterByName("RatePlan") != '') {
                    ratePlanCode = getParameterByName("RatePlan");
                    document.getElementById("txtPromCode").value = ratePlanCode;
                    $('#txtPromCode').attr("disabled", true);
                }

                paramArray = ["propCode", propCode, "ratePlanCode", ratePlanCode, "startDate", datePartsCheckIn[2] + datePartsCheckIn[0] + datePartsCheckIn[1], "endDate", datePartsCheckOut[2] + datePartsCheckOut[0] + datePartsCheckOut[1], "numAdults", adultsNum, "iataNum", iataNum, "forcePromoResult", forcePromoResult];

                var paramList = '';
                if (paramArray.length > 0) {
                    for (var i = 0; i < paramArray.length; i += 2) {
                        if (paramList.length > 0) paramList += ',';
                        paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
                    }
                }
                paramList = '{' + paramList + '}';

                str = window.location.href;

                var url = '';
                if (str.indexOf("localhost") > 0)
                    url = "http://localhost:51568/NeetbookerService.asmx/AvailabititySearch";
                else
                    url = "/NeetBookerService/NeetbookerService.asmx/AvailabititySearch";

                $.ajax({
                    type: "POST",
                    url: url,
                    data: paramList,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(response) {
                        var rooms = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                        $('#hotelsList').empty();

                        //IF we have hotels to show
                        if (rooms.length != 0) {
                            for (var i = 0; i < rooms.length; i++) {

                                var html = "";
                                html = html + '<div class="room-row">';
                                html = html + '	<div class="transparency"></div>';
                                html = html + '	<div class="child">';
                                html = html + '		<div class="data">';
                                html = html + '			<img width="84" height="84" src="' + rooms[i].imagePath + '" />';
                                html = html + '			<h2><span>' + rooms[i].Desc + '</span></h2>';
                                html = html + '			<span class="gray">AVG. RATE/NIGHT:</span>';
                                html = html + '			<span class="white" id="average_' + rooms[i].Code + '_' + rooms[i].RatePlanCode + '">' + rooms[i].CurrencySymbol + rooms[i].Rate + '</span>';
                                //Cancel Policy and Plan Message
                                var cancelMessage = "";
                                var ratePlanMessage = "";
                                if (rooms[i].CancelPolicy != null && (rooms[i].CancelPolicy.ShortMessage + "" != "")) {
                                    cancelMessage = rooms[i].CancelPolicy.ShortMessage;
                                }

                                if (rooms[i].RatePlan != null && (rooms[i].RatePlan.ShortMessage + "" != "")) {
                                    html = html + '			<br />';
                                    html = html + '			<span class="rateplanMessage">' + rooms[i].RatePlan.ShortMessage + '</span>';
                                    if (rooms[i].RatePlan.LongMessage + "" != "") {
                                        ratePlanMessage = rooms[i].RatePlan.LongMessage;
                                    }
                                }
                                if (cancelMessage != "" || ratePlanMessage != "") {
                                    html = html + '			<a style="text-decoration:underline;" href="#" onclick="javascript:showPopUp(\'' + cancelMessage + '\', \'' + ratePlanMessage + '\');return false;">Learn More</a>';
                                }
                                //Cancel Policy and Plan Message

                                html = html + '			<input id="btnRoomSelect" type="button" value="SELECT ROOM" onclick="doShowRoomDetails(\'' + rooms[i].Code + '\', \'' + rooms[i].RatePlanCode + '\');"  style="margin-top:-20px;cursor: pointer;" /></br>';
                                html = html + '         <span></span>';
                                html = html + '		</div>';
                                html = html + '	</div>';
                                html = html + '</div>';

                                $('#hotelsList').append(html);
                            }
                        }
                        else {
                            //No hotels to show
                            var html = "";
                            html = html + '<div class="transparency"></div>';
                            html = html + '<div class="room-row">';
                            html = html + '	<div class="child">';
                            html = html + '		<div class="data" align="center" style="margin-top: 100px;">';
                            html = html + '			<h2>There are no rooms available for your selection.</h2>';
                            html = html + '		</div>';
                            html = html + '	</div>';
                            html = html + '</div>';

                            $('#hotelsList').append(html);
                        }
                        $('#scrollRooms').jScrollPane();
                    },
                    error: function(msg) {
                    $('#hotelsList').empty();
                    $('#hotelsList').append("<span style='color:white'>The system cannot process the request at this moment, please try again.</span>");
                    }
                });
            }
        }
    });
}


//Get the params (query string) from the URL
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}

//Check if the params is correct
function paramsValid(startDate, endDate, propCode, adultsNum) {
    var result = true;

    if (adultsNum == '' || adultsNum == '0')
        result = false;
    else {
        if (propCode == '')
            result = false;
        else {
            if (startDate == '' || endDate == '')
                result = false;
        }
    }

    return result;
}

$(function() {
    $('#btnCheckAvail').click(function() { doCheckAvailability(); } );
});

$(function() {
	if (document.getElementById("btnClear") != null)
		$('#btnClear').click(doClearReserve);
});




var backDivId = "";

function doClearReserve() {
    $('#calendarView').DatePickerClear();
    $('#txtChekInCheck').val("");
    $('#txtChekOutCheck').val("");
    $('#txtIATA').val("");
    $('#ddlRoomsNum').val("1");
    
    if(!$('#txtPromCode').attr("disabled"))
    {
    	$('#txtPromCode').val("");
    }
    if(!$('#ddHotels').attr("disabled"))
    {
    	$('#ddHotels').val("");
    }
}

function doCheckAvailability() {
	
	try { pageTracker._trackEvent('Reserve', 'CheckAvailability'); } catch (err) { }
	try { pageTracker._trackPageview('/Reserve/CheckAvailability'); } catch (err) { }
	
    var ddHotelsValue = document.getElementById("ddHotels").value;
    txtCheckId = document.getElementById("txtChekInCheck").value;
    txtCheckOut = document.getElementById("txtChekOutCheck").value;

    var startDate = new Date(txtCheckId);
    var endDate = new Date(txtCheckOut);
    var now = new Date();

    if (ddHotelsValue != "") {
        if (calcJulian(startDate) < calcJulian(endDate)) {
            if (calcJulian(startDate) >= calcJulian(now)) {
                {

                    $('#hotelsList').empty();
                    var htmlTMP = "<div class=\"transparency\"></div><div id=\"scrollRoom\"><span style='color:white;display:block;padding:130px 0 4px 145px;font-family:Century Gothic, Trebuchet MS, Verdana, Sans-Serif;font-size:14px;text-transform:uppercase;'>Loading...</span><img style='margin-left:135px;' src=\"/images/progressbar.gif\"></div></div>";
                    $('#hotelsList').append(htmlTMP); //show loading

                    //disble the text boxes
                    $('#txtPromCode').attr("disabled", true);
                    $('#txtIATA').attr("disabled", true);
                    $('#txtChekInCheck').attr("disabled", true);
                    $('#txtChekOutCheck').attr("disabled", true);
                    $('#ddHotels').attr("disabled", true);
                    $('#ddlRoomsNum').attr("disabled", true);

                    document.getElementById("calendarStep").style.display = "none";
                    document.getElementById("confirmRoomStep").style.display = "none";
                    document.getElementById("chooseRoomStep").style.display = "block";
                    document.getElementById("backDiv").style.display = "block";
					
					if (document.getElementById("btnClear") != null)
						document.getElementById("btnClear").style.display = "none";
						
                    document.getElementById("backDivEmpty").style.display = "none";
                    document.getElementById("btnCheckAvail").style.display = "none";

                    document.getElementById("calendarStep-Tab").className = "completed";
                    document.getElementById("confirmRoomStep-Tab").className = "";
                    document.getElementById("chooseRoomStep-Tab").className = "active";

                    backDivId = "calendarStep";
					blockUpcomingSteps("chooseRoomStep");

                    datePartsCheckIn = txtCheckId.split('/');
                    datePartsCheckOut = txtCheckOut.split('/');

                    propCode = document.getElementById("ddHotels").value;
                    iataNum = document.getElementById("txtIATA").value;
                    adultsNum = document.getElementById("ddlRoomsNum").value;


                    var forcePromoResult = "false";
                    var ratePlanCode = document.getElementById("txtPromCode").value;

                    if (ratePlanCode != "")
                        forcePromoResult = "true";

                    if (ratePlanCode == "")
                        ratePlanCode = "LV0";

                    if (getParameterByName("RatePlan") != '') {
                        ratePlanCode = getParameterByName("RatePlan");
                        document.getElementById("txtPromCode").value = ratePlanCode;
                        $('#txtPromCode').attr("disabled", true);
                    }

                    paramArray = ["propCode", propCode, "ratePlanCode", ratePlanCode, "startDate", datePartsCheckIn[2] + datePartsCheckIn[0] + datePartsCheckIn[1], "endDate", datePartsCheckOut[2] + datePartsCheckOut[0] + datePartsCheckOut[1], "numAdults", adultsNum, "iataNum", iataNum, "forcePromoResult", forcePromoResult];

                    var paramList = '';
                    if (paramArray.length > 0) {
                        for (var i = 0; i < paramArray.length; i += 2) {
                            if (paramList.length > 0) paramList += ',';
                            paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
                        }
                    }
                    paramList = '{' + paramList + '}';

                    str = window.location.href;

                    var url = '';
                    if (str.indexOf("localhost") > 0)
                        url = "http://localhost:51569/NeetBookerService/NeetbookerService.asmx/AvailabititySearch";
                    else
                        url = "/NeetBookerService/NeetbookerService.asmx/AvailabititySearch";

                    //url = "/NeetBookerService/NeetbookerService.asmx/AvailabititySearch";

                    $.ajax({
                        type: "POST",
                        url: url,
                        data: paramList,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function(response) {
                            var rooms = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                            $('#hotelsList').empty();

                            getHTLMHotelList(rooms);

                            $('#scrollRooms').jScrollPane();
                        },
                        error: function(msg) {
                            $('#hotelsList').empty();
                            $('#hotelsList').append("<span style='color:white'>The system cannot process the request at this moment, please try again.</span>");
                        }
                    });
                }
            }
            else {
                alert("The Check-in date needs to be for the current date or a date in the future.");
            }
        }
        else {
            alert("The Check-out date needs to be for the current date or a date in the future.");
        }
    }
    else {
        alert("Choose a hotel please.");
    }
}


function getHTLMHotelList(rooms) {

	try { pageTracker._trackEvent('Reserve', 'RoomList'); } catch (err) { }
	try { pageTracker._trackPageview('/Reserve/RoomList'); } catch (err) { }
	
    var roomsRatePlanCode = "";
    //this is just for book now
    var bookNow = getParameterByName("BookNow");
    var hotelRoomCode = getParameterByName("RoomCode");

    //this is just for exclusives
    var fromExclusives = getParameterByName("FromExclusives");
    var hotelRoomCodeList = getParameterByName("RoomCodeList");
    var roomList = hotelRoomCodeList.split(',');
    var displayedText = 0;

    //Check if i have rooms to show
    if (rooms.length != 0) {
        for (var i = 0; i < rooms.length; i++) {
            var html = "";
            //check for the book now option if this was the selcted hotel
            if (bookNow == 1) {
                if (rooms[i].Code == hotelRoomCode) {
                    displayedText++;
                    html = html + '<div class="room-row">';
                    html = html + '	<div class="transparency"></div>';
                    html = html + '	<div class="child">';
                    html = html + '		<div class="data">';
                    html = html + '			<img width="84" height="84" src="' + rooms[i].imagePath + '" />';
                    html = html + '			<h2><span>' + rooms[i].Desc + '</span></h2>';
                    html = html + '			<span class="gray">AVG. RATE/NIGHT:</span>';
                    html = html + '			<span class="white" id="average_' + rooms[i].Code + '_' + rooms[i].RatePlan + '">' + rooms[i].CurrencySymbol + rooms[i].Rate + '</span>';
                    //Cancel Policy and Plan Message
                    var cancelMessage = "";
                    var ratePlanMessage = "";
                    if (rooms[i].CancelPolicy != null && (rooms[i].CancelPolicy.ShortMessage + "" != "")) {
                        cancelMessage = rooms[i].CancelPolicy.ShortMessage;
                    }

                    if (rooms[i].RatePlan != null && (rooms[i].RatePlan.ShortMessage + "" != "")) {
                        html = html + '			<br />';
                        html = html + '			<span class="rateplanMessage">' + rooms[i].RatePlan.ShortMessage + '</span>';
                        if (rooms[i].RatePlan.LongMessage + "" != "") {
                            ratePlanMessage = rooms[i].RatePlan.LongMessage;
                        }
                    }

                    if (cancelMessage != "" || ratePlanMessage != "") {
                        html = html + '			<a style="text-decoration:underline;" href="#" onclick="javascript:showPopUp(\'' + cancelMessage + '\', \'' + ratePlanMessage + '\');return false;">Learn More</a>';
                    }
                    //Cancel Policy and Plan Message

                    html = html + '			<input id="btnRoomSelect" type="button" value="SELECT ROOM" onclick="doShowRoomDetails(\'' + rooms[i].Code + '\', \'' + rooms[i].RatePlanCode + '\');" style="margin-top:-20px;cursor: pointer;" /></br>';
                    html = html + '         <span></span>';
                    html = html + '		</div>';
                    html = html + '	</div>';
                    html = html + '</div>';
                }
            }
            else {
                //if this is from exclusives
                if (fromExclusives == 1) {
                    if (isHotelInList(rooms[i].Code, roomList)) {
                        displayedText++;
                        html = html + '<div class="room-row">';
                        html = html + '	<div class="transparency"></div>';
                        html = html + '	<div class="child">';
                        html = html + '		<div class="data">';
                        html = html + '			<img width="84" height="84" src="' + rooms[i].imagePath + '" />';
                        html = html + '			<h2><span>' + rooms[i].Desc + '</span></h2>';
                        html = html + '			<span class="gray">AVG. RATE/NIGHT:</span>';
                        html = html + '			<span class="white" id="average_' + rooms[i].Code + '_' + rooms[i].RatePlanCode + '">' + rooms[i].CurrencySymbol + rooms[i].Rate + '</span>';
                        //Cancel Policy and Plan Message
                        var cancelMessage = "";
                        var ratePlanMessage = "";
                        if (rooms[i].CancelPolicy != null && (rooms[i].CancelPolicy.ShortMessage + "" != "")) {
                            cancelMessage = rooms[i].CancelPolicy.ShortMessage;
                        }

                        if (rooms[i].RatePlan != null && (rooms[i].RatePlan.ShortMessage + "" != "")) {
                            html = html + '			<br />';
                            html = html + '			<span class="rateplanMessage">' + rooms[i].RatePlan.ShortMessage + '</span>';
                            if (rooms[i].RatePlan.LongMessage + "" != "") {
                                ratePlanMessage = rooms[i].RatePlan.LongMessage;
                            }
                        }

                        if (cancelMessage != "" || ratePlanMessage != "") {
                            html = html + '			<a style="text-decoration:underline;" href="#" onclick="javascript:showPopUp(\'' + cancelMessage + '\', \'' + ratePlanMessage + '\');return false;">Learn More</a>';
                        }
                        //Cancel Policy and Plan Message

                        html = html + '			<input id="btnRoomSelect" type="button" value="SELECT ROOM" onclick="doShowRoomDetails(\'' + rooms[i].Code + '\', \'' + rooms[i].RatePlanCode + '\');" style="margin-top:-20px;cursor: pointer;" /></br>';
                        html = html + '         <span></span>';
                        html = html + '		</div>';
                        html = html + '	</div>';
                        html = html + '</div>';
                    }
                }
                else {
                    displayedText++;
                    html = html + '<div class="room-row">';
                    html = html + '	<div class="transparency"></div>';
                    html = html + '	<div class="child">';
                    html = html + '		<div class="data">';
                    html = html + '			<img width="84" height="84" src="' + rooms[i].imagePath + '" />';
                    html = html + '			<h2><span>' + rooms[i].Desc + '</span></h2>';
                    html = html + '			<span class="gray">AVG. RATE/NIGHT:</span>';
                    html = html + '			<span class="white" id="average_' + rooms[i].Code + '_' + rooms[i].RatePlanCode + '">' + rooms[i].CurrencySymbol + rooms[i].Rate + '</span>';
                    //Cancel Policy and Plan Message
                    var cancelMessage = "";
                    var ratePlanMessage = "";
                    if (rooms[i].CancelPolicy != null && (rooms[i].CancelPolicy.ShortMessage + "" != "")) {
                        cancelMessage = rooms[i].CancelPolicy.ShortMessage;
                    }

                    if (rooms[i].RatePlan != null && (rooms[i].RatePlan.ShortMessage + "" != "")) {
                        html = html + '			<br />';
                        html = html + '			<span class="rateplanMessage">' + rooms[i].RatePlan.ShortMessage + '</span>';
                        if (rooms[i].RatePlan.LongMessage + "" != "") {
                            ratePlanMessage = rooms[i].RatePlan.LongMessage;
                        }
                    }

                    if (cancelMessage != "" || ratePlanMessage != "") {
                        html = html + '			<a style="text-decoration:underline;" href="#" onclick="javascript:showPopUp(\'' + cancelMessage + '\', \'' + ratePlanMessage + '\');return false;">Learn More</a>';
                    }
                    //Cancel Policy and Plan Message

                    html = html + '			<input id="btnRoomSelect" type="button" value="SELECT ROOM" onclick="doShowRoomDetails(\'' + rooms[i].Code + '\', \'' + rooms[i].RatePlanCode + '\');" style="margin-top:-20px; cursor: pointer;" /></br>';
                    html = html + '         <span></span>';
                    html = html + '		</div>';
                    html = html + '	</div>';
                    html = html + '</div>';
                }
            }

            $('#hotelsList').append(html);
        }
    }
    else {
        //No hotels to show
        displayedText++;
        var html = "";
        html = html + '<div class="transparency"></div>';
        html = html + '<div class="room-row">';
        html = html + '	<div class="child">';
        html = html + '		<div class="data" align="center" style="margin-top: 100px;">';
        html = html + '			<h2>There are no rooms available for your selection.</h2>';
        html = html + '		</div>';
        html = html + '	</div>';
        html = html + '</div>';

        $('#hotelsList').append(html);
    }

    if (displayedText == 0) {
        //No hotels to show
        html = html + '<div class="transparency"></div>';
        html = html + '<div class="room-row">';
        html = html + '	<div class="child">';
        html = html + '		<div class="data" align="center" style="margin-top: 100px;">';
        html = html + '			<h2>There are no rooms available for your selection.</h2>';
        html = html + '		</div>';
        html = html + '	</div>';
        html = html + '</div>';
        $('#hotelsList').append(html);
    }

}

function isHotelInList(roomCode, hotelList) {
    isList = false;
    for (var i = 0; i < hotelList.length; i++) {
        if (roomCode == hotelList[i]) {
            isList = true;
            break;
        }
    }
    return isList;
}

function doBackToCalendarStep() {

    doBackGeneral('calendarStep');
    document.getElementById("backDiv").style.display = "none";

    if (document.getElementById("btnClear") != null)
        document.getElementById("btnClear").style.display = "block";

    //document.getElementById("btnSelectRoom").style.display = "none";
    document.getElementById("btnCheckAvail").style.display = "block";

    $('#txtChekInCheck').removeAttr("disabled");
    $('#txtChekOutCheck').removeAttr("disabled");
    $('#txtIATA').removeAttr("disabled");
    $('#txtPromCode').removeAttr("disabled");
    $('#ddHotels').removeAttr("disabled");
    $('#ddlRoomsNum').removeAttr("disabled");

    var date = [$('#txtChekInCheck')[0].value, $('#txtChekOutCheck')[0].value];

    $('#calendarView').DatePickerSetDate(date, true);
    backDivId = "";
    blockUpcomingSteps('calendarStep');

 }

 function doBackToChooseRoomStep() {
     doBackGeneral('chooseRoomStep');
     backDivId = "calendarStep";
     blockUpcomingSteps('chooseRoomStep');
}

function doBackToConfirmRoomStep() {
    doBackGeneral('confirmRoomStep');
    backDivId = "chooseRoomStep";
    blockUpcomingSteps('confirmRoomStep');
 }

 function doBackGeneral( backId) {
     if (backId != "") {
         document.getElementById("calendarStep").style.display = "none";
         document.getElementById("chooseRoomStep").style.display = "none";
         document.getElementById("confirmRoomStep").style.display = "none";

         document.getElementById("calendarStep-Tab").className = "";
         document.getElementById("confirmRoomStep-Tab").className = "";
         document.getElementById("chooseRoomStep-Tab").className = "";

         document.getElementById(backId).style.display = "block";
         document.getElementById(backId + "-Tab").className = "active";
     }
}

function blockUpcomingSteps(backId) 
{ 
	switch (backId) {
        case ("calendarStep"):
            {
                $('#calendarStep-Tab').unbind('click');
				$('#calendarStep-Tab').css("cursor", "default");
                $('#chooseRoomStep-Tab').unbind('click');
				$('#chooseRoomStep-Tab').css("cursor", "default");
                $('#confirmRoomStep-Tab').unbind('click');
				$('#confirmRoomStep-Tab').css("cursor", "default");

                break;
            }
        case ("chooseRoomStep"):
            {
                $('#calendarStep-Tab').click(function() { doBackToCalendarStep(); });
				$('#calendarStep-Tab').css("cursor", "pointer");
                $('#chooseRoomStep-Tab').unbind('click');
				$('#chooseRoomStep-Tab').css("cursor", "default");
                $('#confirmRoomStep-Tab').unbind('click');
				$('#confirmRoomStep-Tab').css("cursor", "default");
              
                break;
            }
        case ("confirmRoomStep"):
            {
                $('#calendarStep-Tab').click(function() { doBackToCalendarStep(); event.stopPropagation(); });
				$('#calendarStep-Tab').css("cursor", "pointer");
                $('#chooseRoomStep-Tab').click(function() { doBackToChooseRoomStep(); event.stopPropagation(); });
				$('#chooseRoomStep-Tab').css("cursor", "pointer");
                $('#confirmRoomStep-Tab').unbind('click');
				$('#confirmRoomStep-Tab').css("cursor", "default");
               
                break;
            }
    }
            


}

function doBack(backId) {
    

    switch (backId) {
        case ("calendarStep"):
            {                
                doBackToCalendarStep();
                break;
            }
        case ("chooseRoomStep"):
            {
             
                doBackToChooseRoomStep();
                break;
            }
        case ("confirmRoomStep"):
            {
             
                doBackToConfirmRoomStep();
                break;
            }
    }
}

function doShowRoomDetails(roomCode, roomRate) {
	
	try { pageTracker._trackEvent('Reserve', 'RoomDetails'); } catch (err) { }
	try { pageTracker._trackPageview('/Reserve/RoomDetails'); } catch (err) { }
	
    document.getElementById("btnCheckAvail").style.display = "none";
    //document.getElementById("btnSelectRoom").style.display = "block";

    document.getElementById("backDiv").style.display = "block";
	
	if (document.getElementById("btnClear") != null)
		document.getElementById("btnClear").style.display = "none";
	
    document.getElementById("backDivEmpty").style.display = "none";
    document.getElementById("calendarStep").style.display = "none";
    document.getElementById("confirmRoomStep").style.display = "block";
    document.getElementById("chooseRoomStep").style.display = "none";

    document.getElementById("calendarStep-Tab").className = "completed";
    document.getElementById("confirmRoomStep-Tab").className = "active";
    document.getElementById("chooseRoomStep-Tab").className = "completed";

    var averageRate = $("#average_" + roomCode + "_" + roomRate).text();

    backDivId = "chooseRoomStep";
	
	blockUpcomingSteps("confirmRoomStep");
	
    $('#detailsRoomPlaceHolder').empty();
	
	var htmlTMP = "<div class=\"transparency\"></div><div id=\"scrollRoom\"><span style='color:white;display:block;padding:130px 0 4px 145px;font-family:Century Gothic, Trebuchet MS, Verdana, Sans-Serif;font-size:14px;text-transform:uppercase;'>Loading...</span><img style='margin-left:135px;' src=\"/images/progressbar.gif\"></div></div>";

    $('#detailsRoomPlaceHolder').append(htmlTMP);

    txtCheckId = document.getElementById("txtChekInCheck").value;
    txtCheckOut = document.getElementById("txtChekOutCheck").value;

    var startDate = new Date(txtCheckId);
    var endDate = new Date(txtCheckOut);

    datePartsCheckIn = txtCheckId.split('/');
    datePartsCheckOut = txtCheckOut.split('/');

    propCode = document.getElementById("ddHotels").value;
    iataNum = document.getElementById("txtIATA").value;
    adultsNum = document.getElementById("ddlRoomsNum").value;

    ratePlanCode = roomRate;

    if (getParameterByName("RatePlan") != '' && ratePlanCode == "")
        ratePlanCode = getParameterByName("RatePlan");

    paramArray = ["propCode", propCode, "ratePlanCode", ratePlanCode, "startDate", datePartsCheckIn[2] + datePartsCheckIn[0] + datePartsCheckIn[1], "endDate", datePartsCheckOut[2] + datePartsCheckOut[0] + datePartsCheckOut[1], "numAdults", adultsNum, "roomCode", roomCode, "iataNum", iataNum, "averageRate", averageRate];

    var paramList = '';
    if (paramArray.length > 0) {
        for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
            paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
        }
    }
    paramList = '{' + paramList + '}';

    if (str.indexOf("localhost") > 0)
        url = "http://localhost:51568/NeetbookerService.asmx/RoomDetails";
    else
        url = "/NeetBookerService/NeetbookerService.asmx/RoomDetails"


    $.ajax({
        type: "POST",
        url: url,
        data: paramList,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            var room = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
            $('#detailsRoomPlaceHolder').empty();
            //$('#imgBackground').css("background-image", "url(" + room.imagePath + ")");
            $('#imgBackground').attr("src", room.imagePath);

            days = dayDiff(startDate, endDate);
            var grandTotal = room.Rate * days;
            grandTotal = Math.round(grandTotal * 100 + ((grandTotal * 1000) % 10 > 4 ? 1 : 0)) / 100;
            var html = ""
            html = html + "	<div class=\"data\">";
            html = html + "		<img src=\"" + room.imagePath + "\" width=\"84\" height=\"84\" alt=\"\" align=\"left\" />";
            html = html + "		<h2><span>" + room.Desc + "</span></h2>";
            html = html + "		<span class=\"gray\">AVG. RATE/NIGHT:</span> <span class=\"white\">" + room.CurrencySymbol + room.Rate + "</span><br />";
            html = html + "		<span class=\"white-small\">GRAND TOTAL:</span> <span class=\"white\"><b>" + room.CurrencySymbol + grandTotal + "*</b></span><br /><span style='text-size: 8px'>(* Taxes not included)</span>";
            //html = html + "		<div class=\"brdr-chkbtn\">";
            //html = html + "			<div class=\"chk-btn\">ROOM DETAILS</div>";
            //html = html + "		</div>";
            html = html + "	</div>";
            html = html + "	<div class=\"brdr-chkbtn\">";
            html = html + "		<div id=\"divBookNow\" class=\"chk-btn\" onclick=\"doConfirmRoom('" + room.Code + "', '" + room.RatePlanCode + "');\">BOOK NOW</div>";
            html = html + "	</div>";
            html = html + "	<div class=\"room-conf\">";
            html = html + "		<h2>ROOM DETAILS</h2>";
            html = html + "		<p>" + room.Feature1 + "</p>";
            html = html + "	</div>";

            //$('#btnSelectRoom').click(function() { doConfirmRoom(room.Code); });
            $('#detailsRoomPlaceHolder').append(html);
            $('#scrollRoom').jScrollPane();

        },
        error: function(msg) {
            $('#detailsRoomPlaceHolder').empty();
            $('#detailsRoomPlaceHolder').append("<span style='color:white'>The system cannot process the request at this moment, please try again.</span>");
        }
    });
}

function doConfirmRoom(roomCode, roomRate) {
	
	try { pageTracker._trackEvent('Reserve', 'ConfirmRoom'); } catch (err) { }
	try { pageTracker._trackPageview('/Reserve/ConfirmRoom'); } catch (err) { }

    document.getElementById("border-box").style.display = "none";
    document.getElementById("netBookerDiv").style.display = "block";

    var adultsnum = document.getElementById("ddlRoomsNum").value;
    var beginDate = document.getElementById("txtChekInCheck").value;
    var endDate = document.getElementById("txtChekOutCheck").value;
    var propertyID = document.getElementById("ddHotels").value;
    var hotelName = document.getElementById("ddHotels").options[document.getElementById("ddHotels").selectedIndex].text;
    var hotelNameSTR = hotelName.toLowerCase().replace("-", "");
	
	blockUpcomingSteps("confirmRoomStep");
    
	var netBookURL = "";
    if (window.location.href.indexOf("digiknow") > 0 || window.location.href.indexOf("local") > 0) {
        switch (hotelNameSTR) {
            case "60 Thompson".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/60_thompson/new_york/us/hseoptx_thompson/hseoid_1650822.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "6 Columbus".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/6_columbus/new_york/us/hseoptx_thompson/hseoid_1650823.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Donovan House".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/donovan_house/washington_dc/us/hseoptx_thompson/hseoid_1650840.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Gild Hall".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/gild_hall/new_york/us/hseoptx_thompson/hseoid_1650835.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson Beverly Hills".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_beverly_hills/california/us/hseoptx_thompson/hseoid_1650838.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson LES".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_les/new_york/us/hseoptx_thompson/hseoid_1650848.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson Toronto".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_toronto/ontario/us/hseoptx_thompson/hseoid_1650839.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Sax Chicago".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/sax_hotel/illinois/us/hseoptx_thompson/hseoid_1650841.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Hollywood Roosevelt".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/hollywood_roosevelt_hotel/california/us/hseoptx_thompson/hseoid_1650837.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Smyth".toLowerCase():
                netBookURL = "https://uat.rvng.pegs.com/hotels/smyth_tribeca/new_york/us/hseoptx_thompson/hseoid_1650837.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
        }
    }
    else {
        switch (hotelNameSTR) {
            case "60 Thompson".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/60_thompson/new_york/us/hseoptx_thompson/hseoid_1650822.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/60_thompson/new_york/us/hseoptx_thompson/hseoid_5849760.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "6 Columbus".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/6_columbus/new_york/us/hseoptx_thompson/hseoid_1650823.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/6_columbus/new_york/us/hseoptx_thompson/hseoid_5849761.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Donovan House".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/donovan_house/washington_dc/us/hseoptx_thompson/hseoid_1650840.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/donovan_house/washington_dc/us/hseoptx_thompson/hseoid_5849765.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Gild Hall".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/gild_hall/new_york/us/hseoptx_thompson/hseoid_1650835.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/gild_hall/new_york/us/hseoptx_thompson/hseoid_5849763.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson Beverly Hills".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_beverly_hills/california/us/hseoptx_thompson/hseoid_1650838.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/thompson_beverly_hills/california/us/hseoptx_thompson/hseoid_5849767.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson LES".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_les/new_york/us/hseoptx_thompson/hseoid_1650848.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/thompson_les/new_york/us/hseoptx_thompson/hseoid_5849766.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Thompson Toronto".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/thompson_toronto/ontario/us/hseoptx_thompson/hseoid_1650839.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/thompson_toronto/ontario/us/hseoptx_thompson/hseoid_5849762.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Sax Chicago".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/sax_hotel/illinois/us/hseoptx_thompson/hseoid_1650841.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/sax_hotel/illinois/us/hseoptx_thompson/hseoid_5849764.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Hollywood Roosevelt".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/hollywood_roosevelt_hotel/california/us/hseoptx_thompson/hseoid_1650837.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/hollywood_roosevelt_hotel/california/us/hseoptx_thompson/hseoid_5849768.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
            case "Smyth".toLowerCase():
                //netBookURL = "https://uat.rvng.pegs.com/hotels/smyth_tribeca/new_york/us/hseoptx_thompson/hseoid_1650837.html?&usestyle=partner"
                netBookURL = "https://secure.netbookerng.com/hotels/smyth_tribeca/new_york/us/hseoptx_thompson/hseoid_5849777.html?&usestyle=partner&hassearch=false&mode=frame&processor=EXTERNAL&refurl=.thompsonhotels.com"
                break;
        }
    }
	
    //get IATA val
    var iataVal = document.getElementById("txtIATA").value;

    var iataURL = "";
    if (iataVal != "")
        iataURL = "&agentnumber=" + iataVal;

    var ratePlanCode = document.getElementById("txtPromCode").value;

    if (ratePlanCode == "")
        ratePlanCode = "LV0";

    if (getParameterByName("RatePlan") != '')
        ratePlanCode = getParameterByName("RatePlan");

    if (roomRate != "")
        ratePlanCode = roomRate;

    var url = netBookURL + "" + "&begindate=" + beginDate + "&enddate=" + endDate + "&itemcode=" + roomCode + '&ratecode=' + ratePlanCode + '&Autosearch=false' + iataURL + "&adults=" + adultsnum;

    document.getElementById("netBookerIFrame").src = url;
}

function goToHowCanWeHelpYou(goToPage) {
    var url = window.location.href;
    var urlV = url.split("/")
    url = "http://" + urlV[2] + "/" + urlV[3] + "/" + urlV[4] + "/" + urlV[5] + "/" + goToPage;
    //alert(url);
    window.location.href = url;
}

function goToReserces() {

    var url = "/reserve?HotelCode=" + "061650"
    //alert(url);
    window.location.href = url;
}

function replaceAllTextBreakLinesForHtmlBreakLines(str) {
    //return str.replace(/\r\n/g, '<br />').replace(/\n\r/g, '<br />').replace(/\n/g, '<br />');
    return str;
}
var orgBGImage = "";
function showMoreDetails(obj) {
    var imageDetail = obj.parentNode.parentNode.getElementsByTagName('img')[1];
    var collapsed = obj.parentNode.parentNode.getElementsByTagName('p')[0];
    var expanded = obj.parentNode.parentNode.getElementsByTagName('p')[1];
    var imgBackground = document.getElementById("imgBackground");
    var newBGImage = obj.parentNode.parentNode.getElementsByTagName('input')[0];

    if (orgBGImage == "") {
        orgBGImage = imgBackground.src;
    }

    if (expanded.style.display == "none") {
        //collapsed.style.display = "none";
        expanded.style.display = "inline";
        imageDetail.style.display = "inline"
        obj.innerHTML = "BACK";
        if (newBGImage.value != "") {
            imgBackground.src = newBGImage.value;
        }
    }
    else {
        collapsed.style.display = "inline";
        expanded.style.display = "none";
        imageDetail.style.display = "none"
        obj.innerHTML = "MORE DETAILS";
        imgBackground.src = orgBGImage;
    }

    $('#scroll-pane').jScrollPane();

}

function doBookNow() {

    $(document).ready(function() {
        var bookNow = getParameterByName("BookNow");

        if (bookNow == 1) {

            var HotelCode = getParameterByName("HotelCode");
            HotelCode = HotelCode.toLowerCase();

            //select a hotel by value
            var ddHotels = document.getElementById('ddHotels');
            for (var i = 0; i < ddHotels.options.length; i++) {
                if (ddHotels.options[i].value == HotelCode) {
                    ddHotels.options[i].selected = true;
                }
            }
            //disable the hotel selection dropdown
            $('#ddHotels').attr("disabled", true);

        }
    });
}


function doEclusivesBook() {

    $(document).ready(function() {

        //this is just for exclusives, other ways will be empty
        var fromExclusives = getParameterByName("FromExclusives");

        //if (fromExclusives == 1) {

        var HotelCode = getParameterByName("HotelCode");
        if (HotelCode != "") {
            HotelCode = HotelCode.toLowerCase();
            //select a hotel by value
            var ddHotels = document.getElementById('ddHotels');
            for (var i = 0; i < ddHotels.options.length; i++) {
                if (ddHotels.options[i].value == HotelCode) {
                    ddHotels.options[i].selected = true;
                }
            }
            //disable the hotel selection dropdown
            $('#ddHotels').attr("disabled", true);
        }

        var ratePlanCode = getParameterByName("RatePlan");
        if (ratePlanCode != "") {
            document.getElementById("txtPromCode").value = ratePlanCode;
            $('#txtPromCode').attr("disabled", true);
        }
        //}
    });
}

/*resizing functions*/

var divMain = null;
var divBackground = null;
var imgBackground = null;
var tdBody = null;
var divBody = null;
var tdScroll = null;

function checkWindowSize() {
    var windowWidth = 0;
    var windowHeight = 0;
    var windowMinWidth = 920;
    var windowMinHeight = 600;
    var windowNewWidth = 0;
    var windowNewHeight = 0;

    if (self.outerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    }
    else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    var needResizing = false;

    windowNewWidth = windowWidth;
    windowNewHeight = windowHeight;

    if (windowWidth < windowMinWidth) {
        windowNewWidth = windowMinWidth;
    }
    if (windowHeight < windowMinHeight) {
        windowNewHeight = windowMinHeight;
    }
    if (divMain != null && divBackground != null && imgBackground != null) {
        divMain.style.overflow = "hidden";
        divMain.style.width = windowNewWidth + 'px';
        divMain.style.height = windowNewHeight + 'px';
        divBackground.style.overflow = "hidden";
        divBackground.style.width = windowNewWidth + 'px';
        divBackground.style.height = windowNewHeight + 'px';

        if (tdBody != null) {
            tdBody.style.height = (windowNewHeight - 60 - 23) + 'px';
        }

        if (divBody != null) {
            divBody.style.height = (windowNewHeight - 60 - 23) + 'px';
        }

        if (tdScroll != null) {
            tdScroll.style.width = ((windowNewWidth - 60 - 23 - 200 - 175) + 'px');
            tdScroll.style.height = (windowNewHeight - 60 - 23) + 'px';
            if ($('#scroll') != null) {
                if (isSafari) {
                    //$('#scroll').css("width", (windowNewWidth - 60 - 23 -200 -175 + 23) + 'px');
                    $('#scroll').css("height", (windowNewHeight - 60 - 23) + 'px');
                }
                //setTimeout("$('#scroll').jScrollPane();", 8000);
				$('#scroll').jScrollPane();
            }
        }
        if (windowWidth > windowHeight) {
            imgBackground.style.width = "100%";
            imgBackground.style.height = "";
        }
        else {
            imgBackground.style.width = "";
            imgBackground.style.height = "100%";
        }


    }
}




$(document).ready(function() {
    //resizing init
    divMain = document.getElementById("divMain");
    divBackground = document.getElementById("divBackground");
    imgBackground = document.getElementById("imgBackground");
    tdBody = document.getElementById("tdBody");
    divBody = document.getElementById("body");
    tdScroll = document.getElementById("td-scroll");

    checkWindowSize();
    //resizing functions
    onresize = function() { checkWindowSize(); }
    /*resizing init*/

    //room photos init
    if ($('#roomphotos') != null) {
        $('#roomphotos').galleryView({
            filmstrip_size: 5,
            frame_width: 50,
            frame_height: 50,
            background_color: 'transparent',
            nav_theme: 'dark',
            border: 'none',
            transition_interval: 0,
            caption_text_color: 'white'
        });
    }

    if ($('#subroomphotos') != null) {
        $('#subroomphotos').galleryView({
            filmstrip_size: 4,
            frame_width: 35,
            frame_height: 25,
            background_color: 'transparent',
            nav_theme: 'dark',
            border: 'none',
            transition_interval: 0,

            caption_text_color: 'white'
        });
    }
    //room photos init

    //initiate custom scroll bars

    if ($('#tabs-container') != null) {
        $('#tabs-container').jScrollPane();
    }

    if (document.getElementById('menuoptions') != null) {
        document.getElementById('menuoptions').style.display = "none";
    }

    if ($('.scroll-pane') != null) {
        $('.scroll-pane').jScrollPane();
    }
    // initiate custom scroll bars


    var checkindate = new Date();
    checkindate = '' + (checkindate.getMonth() + 1) + '/' + (checkindate.getDate()) + '/' + checkindate.getFullYear() + '';

    var checkoutdate = new Date();
    checkoutdate = '' + (checkoutdate.getMonth() + 1) + '/' + (checkoutdate.getDate() + 1) + '/' + checkoutdate.getFullYear() + '';

    // set date picker init
    if ($(".dateCheckIn") != null) {
        $(".dateCheckIn").DatePicker({
            format: 'm/d/Y',
            date: [],
            current: '',
            calendars: 1,
            starts: 1,
            onChange: function(formated, dates) {
                $('#txtChekIn').val(formated);
                $('#txtChekIn').DatePickerHide();
                $('#imgChekIn').DatePickerHide();
                var newcheckoutdate = new Date(formated);
                newcheckoutdate = '' + (newcheckoutdate.getMonth() + 1) + '/' + (newcheckoutdate.getDate() + 1) + '/' + newcheckoutdate.getFullYear() + '';
                $(".dateCheckOut").DatePickerSetDate(newcheckoutdate, true);
            }
        });
        $(".dateCheckIn").DatePickerSetDate(checkindate, true);
    }
    if ($(".dateCheckOut") != null) {
        $(".dateCheckOut").DatePicker({
            format: 'm/d/Y',
            date: [],
            current: '',
            calendars: 1,
            starts: 1,
            onChange: function(formated, dates) {
                $('#txtChekOut').val(formated);
                $('#txtChekOut').DatePickerHide();
                $('#imgChekOut').DatePickerHide();
            }
        });
        $(".dateCheckOut").DatePickerSetDate(checkoutdate, true);
    }
    // set date picker init


    // set date picker init
    if ($('#calendarView') != null) {
        $('#calendarView').DatePicker({
            format: 'm/d/Y',
            flat: true,
            date: [],
            current: '',
            calendars: 1,
            mode: 'range',
            starts: 1,
            onChange: function(formated, dates) {
				if ($("#calendarToolTip")[0].innerHTML == "SELECT ARRIVAL DATE")
				{
					$("#calendarToolTip")[0].innerHTML = "SELECT DEPARTURE DATE";
				}
				else
				{
					hideCalendarToolTip();
				}
                if (formated[0] != formated[1]) {
                    $('#txtChekInCheck').val(formated[0]);
                    $('#txtChekOutCheck').val(formated[1]);
                }
                else {
                    $('#txtChekInCheck').val(formated[0]);
                    $('#txtChekOutCheck').val(formated[0]);
					
					
					
					initCalendarToolTip();
					
					showCalendarToolTip();
                }
            }
        });
		
		initCalendarToolTip();
    }
	
	
    //set date picker init

    //scroll init
    if ($('#scroll-pane') != null) {
        if ($('#tabs-1')[0] != null)
            $('#tabs-1')[0].innerHTML = replaceAllTextBreakLinesForHtmlBreakLines($('#tabs-1')[0].innerHTML);

        if ($('#tabs-2')[0] != null)
            $('#tabs-2')[0].innerHTML = replaceAllTextBreakLinesForHtmlBreakLines($('#tabs-2')[0].innerHTML);

        if ($('#tabs-3')[0] != null)
            $('#tabs-3')[0].innerHTML = replaceAllTextBreakLinesForHtmlBreakLines($('#tabs-3')[0].innerHTML);

        if ($('#tabs-4')[0] != null)
            $('#tabs-4')[0].innerHTML = replaceAllTextBreakLinesForHtmlBreakLines($('#tabs-4')[0].innerHTML);

        $('#scroll-pane').jScrollPane();
    }
    //scroll init

    if ($('#scroll') != null) {
        //$('#scroll').jScrollPane();
    }

    if ($('#blogScroll') != null) {
        $('#blogScroll').jScrollPane();
    }
	
	if ($("#ddHotels") != null)
	{
		$("#ddHotels").change(
			function ()
			{
				if ($("#ddHotels option:selected").attr("value") == "")
				{
					while ($("#ddHotels option:selected").attr("value") == "")
					{
						$("#ddHotels")[0].selectedIndex = $("#ddHotels")[0].selectedIndex + 1;
					}
				}
			}
		);
	}

});

function showMagazineCover(link, image) {
    var aMagazineCover = document.getElementById("aMagazineCover");
    var imgMagazineCover = document.getElementById("imgMagazineCover");

    aMagazineCover.href = link;
    imgMagazineCover.src = image;
}


function calcJulian(isDate) {

    gregDate = new Date(isDate);
    year = gregDate.getFullYear();
    month = gregDate.getMonth() + 1;
    day = gregDate.getDate();
    A = Math.floor((7 * (year + Math.floor((month + 9) / 12))) / 4);
    B = day + Math.floor((275 * month) / 9)
    isJulian = (367 * year) - A + B + 1721014;
    return isJulian;
}

function dayDiff(date1, date2) {
    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms)

    // Convert back to days and return
    return Math.round(difference_ms / ONE_DAY)

}

function whiteBarOver(obj) {
    if (obj.isOver == null) {
        //$(objName).css("opacity", 0.75);
        //$(objName).css("top", "8px");
        obj.opacity = "0.75";
    }

    obj.isOver = true;
    var objName = '#whiteT-' + obj.id;
    setTimeout("whiteBarOverTO('" + objName + "', '" + obj.id + "')", 50);
}

function whiteBarOverTO(objName, objParent) {
    //if (document.getElementById(objParent).isOver && $(objName).css("opacity") != "1")
    if (document.getElementById(objParent).isOver && document.getElementById(objParent).opacity != "1") {
        $(objName).animate({ opacity: 1, top: "12px" }, 250);
        document.getElementById(objParent).opacity = "1";
    }
}

function whiteBarOut(obj) {
    obj.isOver = false;
    var objName = '#whiteT-' + obj.id;
    setTimeout("whiteBarOutTO('" + objName + "', '" + obj.id + "')", 250);
}

function whiteBarOutTO(objName, objParent) {
    if (!document.getElementById(objParent).isOver && document.getElementById(objParent).opacity == "1") {
        $(objName).animate({ opacity: 0.75, top: "8px" }, 250);
        document.getElementById(objParent).opacity = "0.75";
    }
    else if (!document.getElementById(objParent).isOver && $(objName).css("opacity") != "0.75") {
        setTimeout("whiteBarOutTO('" + objName + "', '" + objParent + "')", 250);
    }
}

if ($('#black-box') != null) {
    $('.about-content').jScrollPane();
}


$(function() {
    if ($('#scroll') != null) {
        //$('#scroll').jScrollPane();
    }
});
function footerOver(obj) {
    obj.style.backgroundColor = "#666666";
}
function footerOut(obj) {
    obj.style.backgroundColor = "";
}
function showPopUp(cancelMessage, ratePlanMessage) {

    //title: gothic
    //description verdana

    var IE = /*@cc_on!@*/false;
    var divBackground = document.createElement("div");
    var divFront = document.createElement("div");

    divBackground.id = "divBackgroundPopUp";
    ////    dkSetStyle(divBackground, "font-family: Century Gothic, Trebuchet MS, Verdana, Sans-Serif; width: 410px; height: 260px; position: absolute; top: 200px; background-color: rgb(204, 204, 204); z-index: 10001; margin-right: 60%; margin-left: 40%;");
    divBackground.style.fontFamily = "Century Gothic, Trebuchet MS, Verdana, Sans-Serif;";
    divBackground.style.color = "#ffffff";
    divBackground.style.width = "100%";
    divBackground.style.height = "100%";
    divBackground.style.top = "0px";
    divBackground.style.left = "0px";
    divBackground.style.backgroundColor = "#000000";
    divBackground.style.zIndex = "10001";
    divBackground.style.marginLeft = "0";
    divBackground.style.marginRight = "0";
    divBackground.style.position = "absolute";


    // setAttribute("style", "font-family: Century Gothic, Trebuchet MS, Verdana, Sans-Serif; width: 400px; height: 250px; position: absolute; top: 300px; background-color: rgb(204, 204, 204); z-index: 10001; margin-right: 60%; margin-left: 40%;");

    //  divFront.setAttribute("style", "font-family: Century Gothic, Trebuchet MS, Verdana, Sans-Serif; width: 400px; height: 250px; position: absolute; top: 200px; background-color: rgb(204, 204, 204); z-index: 10001; margin-right: 60%; margin-left: 40%;");
    //  dkSetStyle(divFront, "font-family: Century Gothic, Trebuchet MS, Verdana, Sans-Serif; width: 400px; height: 250px; position: absolute; top: 300px; background-color: rgb(204, 204, 204); z-index: 10001; margin-right: 60%; margin-left: 40%;");

    divFront.id = "divFrontPopUp";
    divFront.style.fontFamily = "Century Gothic, Trebuchet MS, Verdana, Sans-Serif;";
    divFront.style.color = "#ffffff";
    divFront.style.width = "350px";
    divFront.style.height = "300px";
    //    divFront.style.top = "200px";
    divFront.style.backgroundColor = "#000000";
    divFront.style.zIndex = "10002";
    divFront.style.border = "1px solid White";
    if (!IE)
    { divFront.style.marginLeft = "40%"; }
    //    divFront.style.marginRight = "60%";
    divFront.style.position = "relative";
    divFront.style.paddingLeft = "10px";
    divFront.style.paddingRight = "10px";

    var divContent = document.createElement("div");
    divContent.id = "divPopUpContent";

    if (ratePlanMessage != "" && ratePlanMessage != "null") {
        var divRatePlanTitle = document.createElement("div");
        divRatePlanTitle.id = "divRatePlanTitle";
        divRatePlanTitle.style.fontFamily = "Century Gothic, Trebuchet MS, Verdana, Sans-Serif;";
        divRatePlanTitle.style.fontSize = "11pt";
        divRatePlanTitle.style.fontWeight = "bold";
        divRatePlanTitle.innerHTML = "<br/><br/>RATE DESCRIPTION";

        var divRatePlan = document.createElement("div");
        divRatePlan.id = "divRatePlan";
        divRatePlan.style.fontFamily = "Verdana, Sans-Serif;";
        divRatePlan.style.fontSize = "8pt";
        divRatePlan.style.paddingLeft = "40px";
        divRatePlan.style.paddingRight = "40px";
        divRatePlan.style.textAlign = "left";
        divRatePlan.style.lineHeight = "15pt";
        divRatePlan.innerHTML = "<br/>" + ratePlanMessage;

        if (cancelMessage == "" && cancelMessage != "null")
            divRatePlan.innerHTML += "<br/><br/><div align='center'><b><a class='chk-btn btnBack' href=\"javascript:\" onclick=\"hidePopUp();\">Close</a></b></div>";
            
        divContent.appendChild(divRatePlanTitle);
        divContent.appendChild(divRatePlan);
    }

    if (cancelMessage != "" && cancelMessage != "null") {
        var divCancelTitle = document.createElement("div");
        divCancelTitle.id = "divCancelTitle";
        divCancelTitle.style.fontFamily = "Century Gothic, Trebuchet MS, Verdana, Sans-Serif;";
        divCancelTitle.style.fontSize = "11pt";
        divCancelTitle.style.fontWeight = "bold";
        divCancelTitle.innerHTML = "<br/><br/>CANCELLATION POLICY";

        var divCancel = document.createElement("div");
        divCancel.id = "divCancelTitle";
        divCancel.style.fontFamily = "Verdana, Sans-Serif;";
        divCancel.style.fontSize = "8pt";
        divCancel.style.paddingLeft = "40px";
        divCancel.style.paddingRight = "40px";
        divCancel.style.textAlign = "left";
        divCancel.style.lineHeight = "15pt";
        divCancel.innerHTML = "<br/>" + cancelMessage + "<br/><br/><div align='center'><b><a class='chk-btn btnBack' href=\"javascript:\" onclick=\"hidePopUp();\">Close</a></b></div>";
        divContent.appendChild(divCancelTitle);
        divContent.appendChild(divCancel);
    }

    //    divFront.innerHTML = "<br/><br/><div align='center'><b><a class='chk-btn btnBack' href=\"javascript:\" onclick=\"hidePopUp();\">Close</a></b></div>";

    //    divFront.innerHTML =  "<br/><br/>" + cancelMessage + "<br/><br/><div align='center'><b><a class='chk-btn btnBack' href=\"javascript:\" onclick=\"hidePopUp();\">Close</a></b></div>";

    document.body.appendChild(divBackground);
    divFront.appendChild(divContent);
    document.body.appendChild(divFront);
    $('#divFrontPopUp').height($("#divPopUpContent").outerHeight() + 20);

    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#divFrontPopUp").height();
    var popupWidth = $("#divFrontPopUp").width();

    $("#divFrontPopUp").css({ "top": windowHeight / 2 - popupHeight / 2
    });
}

function hidePopUp() {
    var divBackground = document.getElementById("divBackgroundPopUp");
    var divBackParent = divBackground.parentNode;
    divBackParent.removeChild(divBackground);

    var divFront = document.getElementById("divFrontPopUp");
    var divFrontParent = divFront.parentNode;
    divFrontParent.removeChild(divFront);
}


//Calendar Tool Tip
var calendarToolTipTimer = null;
function initCalendarToolTip()
{
	$(".datepickerDays tr td a").mouseover(
			function () 
			{ 
				showCalendarToolTip();
			}
		);
	$(".datepickerDays tr td a").mouseout(
			function () 
			{ 
				hideCalendarToolTip();
			}
		);
	if ($("#calendarToolTip")[0] == null)
	{
		$(document.body).prepend("<div id=\"calendarToolTip\" style=\"position: absolute !important;\">SELECT ARRIVAL DATE</div>");
	}
	$(document).bind('mousemove',
		function(e)
		{ 
			if ($("#calendarToolTip") != null)
			{
				$("#calendarToolTip").css("top", (e.pageY + 32) + "px");
				$("#calendarToolTip").css("left", (e.pageX + 32) + "px");
			}
		}
	);
}
function showCalendarToolTip()
{
	if (calendarToolTipTimer != null) { clearTimeout(calendarToolTipTimer); calendarToolTipTimer = null; }
	$("#calendarToolTip").css("display", "inline");
}
function hideCalendarToolTip()
{
	if (calendarToolTipTimer != null) { clearTimeout(calendarToolTipTimer); calendarToolTipTimer = null; }
	calendarToolTipTimer = setTimeout('$("#calendarToolTip").css("display", "none");', 200);
}
function showBlogArchive(obj)
{
	var obj = $(obj.parentNode.parentNode).children('ul');
	if (obj.css('display') == 'none')
	{
		obj.css('display', 'inline');
	}
	else
	{
		obj.css('display', 'none');
	}
}