if(outrig===undefined){var outrig={}}outrig.book=function(){var k=3;var e=null;var n=null;var r=null;var q=null;var m=undefined;var j={checkIn:".book-checkin-fld",checkOut:".book-checkout-fld",destination:".book-dest-fld",property:".book-prop-fld",propertiesList:".book-prop-list-fld"};var c="";var h={};jQuery.each(j,function(s,t){h[s]=jQuery(t);c+=t+", "});var p=jQuery(c);h.submit=jQuery(".book-submit-btn");h.dpTrigger=jQuery(".con-book .datepicker-ico img, .con-book-full .datepicker-ico img");h.numAdults=jQuery(".book-adults-fld");h.numChildren=jQuery(".book-children-fld");h.numRooms=jQuery(".book-rooms-fld");h.totalGuests=jQuery(".book-total-guests-val");if(jQuery(".booking_widget_mode").val()!="mini"){}else{h.destination.hide();h.property.hide()}h.checkIn.datepicker({numberOfMonths:2,changeMonth:true,closeText:"Close",showOtherMonths:true,minDate:0,maxDate:"+1y"});h.checkOut.datepicker({numberOfMonths:2,changeMonth:true,closeText:"Close",showOtherMonths:true,minDate:1,maxDate:"+1y +1d"});h.checkIn.datepicker().change(function(){b(this)}).datepicker("setDate",new Date());h.checkIn.click(function(){a=h.checkIn});h.checkOut.click(function(){a=h.checkOut});h.checkOut.datepicker().change(function(){b(this)}).datepicker("setDate","+"+k);h.destination.change(function(){f(h.destination,h.property)});p.change(function(){i()});var a=h.checkIn;h.dpTrigger.click(function(){a.datepicker("show")});var o=jQuery(":selected",h.property).text();if(typeof(jsonDestination)!="undefined"){e=jsonDestination}if(typeof(jsonMinimumData)!="undefined"){n=jsonMinimumData;f(h.destination,h.property)}if(typeof(jsonReservation)!="undefined"){n=jsonReservation;f(h.destination,h.property);h.checkIn.datepicker("setDate",new Date(parseInt(n.CheckInDate.substr(6))));h.checkOut.datepicker("setDate",new Date(parseInt(n.CheckOutDate.substr(6))))}var i=function(){};var l=function(s){h.totalGuests.html("&nbsp;"+(parseInt(h.numAdults.val())+parseInt(h.numChildren.val()))*parseInt(h.numRooms.val()))};var b=function(w){if(h.checkIn.val()!=""&&h.checkOut.val()!=""){var u=new Date(h.checkIn.val());var x=new Date(h.checkOut.val());if(jQuery(w).attr("name")==h.checkIn.attr("name")){if(x<=u){var s=h.checkIn.datepicker("getDate");h.checkOut.datepicker("setDate",new Date(s.setDate(s.getDate()+k)))}jQuery(j.checkIn).stop(true,true);var v;if(jQuery.browser.msie&&jQuery.browser.version.indexOf("6")==0){v=setTimeout("jQuery('"+j.checkOut+"').datepicker('show')",1200)}else{v=setTimeout("jQuery('"+j.checkOut+"').datepicker('show')",500)}a=jQuery(j.checkOut)}else{if(x<=u){var s=h.checkOut.datepicker("getDate");h.checkIn.datepicker("setDate",new Date(s.setDate(s.getDate()-k)))}}}};function f(B,A){A.html("");var v=-1;var u=0;var z=e[d(B.val())];if(z!==undefined){var s=z.Properties;var w=z.ExternalProperties;if(s||w){var t='<option value="-1">'+jQuery(".label-all-props").val()+"</option>";var y="";for(var x=0;x<s.length;x++){t+=g(s[x].Code,s[x].Name);if(n&&n.PropertyCode==s[x].Code){v=x}y+=s[x].Code+"|"}for(var x=0;x<w.length;x++){t+=g(w[x].Code,w[x].Name);if(n&&n.PropertyCode==s[x].Code){v=x}y+=s[x].Code+"|"}u=s.length+1;h.propertiesList.val(y)}else{t+=g(undefined,m)}}else{t='<option value="0">'+o+"</option>"}A.html(t);if(v>-1){A.get(0).selectedIndex=v+1}return u}function d(s){for(var t=0;t<e.length;t++){if(e[t].Code==s){return t}}}function g(t,s){return"<option value='"+t+"'>"+s+"</option>"}if(jQuery(".con-book-full").length){h.numAdults.change(function(){l()});h.numChildren.change(function(){l()});h.numRooms.change(function(){l()})}l()};var $j=jQuery.noConflict();$j(document).ready(function(){if(jQuery(".con-book").length||jQuery(".con-book-full").length){var a=new outrig.book()}});function onClickSubmit(b,c){if(jQuery(".book-dest-fld").val()==""){c.IsValid=false;return}var f;var e;var a=document.getElementsByTagName("input");for(var d=0;d<a.length;d++){if(a[d].className.indexOf("book-checkin-fld")!=-1){f=a[d]}else{if(a[d].className.indexOf("book-checkout-fld")!=-1){e=a[d]}}}var g=validateDate(f.value);if(!g){alert("Please enter a valid check in date.");f.value="";f.focus();c.IsValid=false;return}var h=validateDate(e.value);if(!h){alert("Please enter a valid check out date.");e.value="";e.focus();c.IsValid=false;return}c.IsValid=true;showLoadingDialog();return false}function progressBar(){var a=setTimeout(function(){jQuery(".dialog-results-loading .dialog-progressbar").css({"background-image":"url(../images/loader-spinner.gif)"})},250)}var dialogLoading=jQuery(".dialog-results-loading").dialog({bgiframe:true,autoOpen:false,modal:true,dialogClass:"results-loading",width:669,height:240,zIndex:3999,position:"center",resizable:false,open:function(a,b){if(jQuery.browser.msie&&jQuery.browser.version.indexOf("6")==0){jQuery("select").css("visibility","hidden")}jQuery(".results-loading").css("border","4px solid #999");progressBar()},close:function(a,b){jQuery("select").css("visibility","visible")}});function showLoadingDialog(){dialogLoading.dialog("open")}function validateDate(e){return true;var d=false;var f=e.split("/");if(f.length!=3||f[0].length!=2||f[1].length!=2||f[2].length!=4){return d}var c=new Date();var a=new Date(c.getFullYear(),c.getMonth(),c.getDate());var b=new Date(f[2],parseInt(f[0],10)-1,parseInt(f[1],10));if(b<a){return d}return !d};
