var textHeader,textFooter,bothDatesRequired=true,unsuccessfulCallback=false;function HandleMonthYearChanged(hotelID,year,month,inst,obj){$("#progressProperty").show();var guestCountInt=$("select[name=NumGuests]").val();guestCountInt=guestCountInt==null?1:guestCountInt;var today=new Date,input={hotelID:hotelID,year:year,month:month,monthsToCheck:2,guestCount:guestCountInt,roomCount:1};$.ajax({type:"POST",url:availabilityWebServiceUrl,data:input,dataType:"json",success:function(result){jQuery.data($("#"+inst.id)[0],"calendarAvailability",result);$("#"+inst.id).datepicker("refresh");$("#progressProperty").hide()},error:function(){unsuccessfulCallback=true;jQuery.data($("#"+inst.id)[0],"calendarAvailability",null);$("#"+inst.id).datepicker("refresh");$("#progressProperty").hide()}});if(obj!=null&&inst!=null)(inst.selectedDay!=inst.currentDay||inst.selectedMonth!=inst.currentMonth||inst.selectedYear!=inst.currentYear)&&(inst.selectedDay==today.getDate()&&inst.selectedMonth==today.getMonth()&&inst.selectedYear==today.getFullYear())&&$("#"+inst.id).datepicker("setDate",new Date)}function HandleBeforeShowDay(date,obj){var availabilityCalendar=jQuery.data($("#"+obj.id)[0],"calendarAvailability");if(obj.id=="DepartureDate")if(date<=$("#ArrivalDate").datepicker("getDate"))return [false,"",""];if(availabilityCalendar!=null)for(var i=0;i<availabilityCalendar.length;i++){var jsonDate=new Date(parseInt(availabilityCalendar[i].Date.substr(6)));if(jsonDate.getFullYear()==date.getFullYear()&&jsonDate.getMonth()==date.getMonth()&&jsonDate.getDate()==date.getDate()){var stateCode=String.fromCharCode(availabilityCalendar[i].State);switch(stateCode){case "O":return [true,"availableDate"];break;case "C":return [true,"unAvailableDate"];break;case "R":return [true,"restrictedDate"]}}}if(unsuccessfulCallback)return [true,""];return [false,"",""]}function HandleBeforeShow(hotelId,input,inst){var today=new Date;textHeader=$("#"+inst.id).datepicker("option","textHeader");if(textHeader==undefined)textHeader="";var divCalendarDOM=$("#ui-datepicker-div").get(0);if(!$.browser.msie)divCalendarDOM.addEventListener("DOMSubtreeModified",AddHeaderAndFooter,false);else divCalendarDOM.onpropertychange=AddHeaderAndFooter;var selectedDate=$("#"+inst.id).datepicker("getDate");HandleMonthYearChanged(hotelId,selectedDate.getFullYear(),selectedDate.getMonth()+1,input,null);if($.browser.msie&&parseInt($.browser.version,10)<7){$("#ui-datepicker-div").bgiframe();$("#bookNow").find("select.short").hide()}$("#progressProperty").hide()}function AddHeaderAndFooter(){var header='<div class="ui-datepicker-div-header"><div class="ui-datepicker-header-text">'+textHeader+'</div><div class="ui-datepicker-header-button"/></div>',footer='<div class="ui-datepicker-notes"><image src="'+urlNotesImage+'" /></div><div class="ui-datepicker-notes notes-text-footer">'+textFooterCalendar+"</div>",progressBar='<div id="progressProperty" style="pading: 10px; text-align: center;display:block; margin-left:auto; margin-right:auto;clear:both;"><h4 class="h4"><img src="'+urlProgressBarImage+'" />'+searchingText+"</h4></div>",divButton=$("#ui-datepicker-div > div.ui-datepicker-buttonpane"),divHeader=$("#ui-datepicker-div.ui-datepicker > div.ui-datepicker-div-header"),divGroup=$("#ui-datepicker-div.ui-datepicker > div.ui-datepicker-row-break"),buttonToday=$("#ui-datepicker-div").find("div.ui-datepicker-buttonpane").find(".ui-datepicker-current");if(divHeader.length==0){$("#ui-datepicker-div > div.ui-datepicker-group-first").before(header);$(".ui-datepicker-header-button").click(function(){$(this).parent().parent().css("display","none")})}$("#ui-datepicker-div.ui-datepicker").find("div.ui-datepicker-notes").length==0&&divButton.length==1&&divButton.after(footer);$("#progressProperty").length==0&&divGroup.length==1&&divGroup.before(progressBar);$(".ui-datepicker-next").attr("title",nextArrowText);$(".ui-datepicker-prev").attr("title",previousArrowText)}function DisplayArrivalDate(){$(document).ready(function(){$("#ArrivalDate").datepicker("show")})}function HandleOnClose(){$.browser.msie&&parseInt($.browser.version,10)<7&&$("#bookNow").find("select.short").show()};
