
function updatedayofweek(dowmodifier){if(dowmodifier.indexOf('|')>0){whichones=dowmodifier.split("|");modifier=whichones[1];whichone=whichones[0];}else{whichone='';modifier=dowmodifier;}
try{if(showHomePageFloater&&modifier=='checkin'){hpShowFloater();}}catch(e){}
opposite='';if(modifier=='checkin')
{opposite='checkout';}
else if(modifier=='checkout')
{opposite='checkin';}
if(document.getElementById(whichone+modifier)){new Ajax.Updater(whichone+modifier+'dayofweek','dayofweek',{asynchronous:true,evalScripts:true,postBody:'date='+$F(whichone+modifier)+'&odate='+$F(whichone+opposite)+'&oinout='+opposite+'&inout='+modifier+'&whichone='+whichone});}else{new Ajax.Updater(whichone+modifier+'dayofweek','dayofweek',{asynchronous:true,evalScripts:true,postBody:'month='+$F(whichone+modifier+'month')+'&day='+$F(whichone+modifier+'dayofmonth')+'&oday='+$F(whichone+opposite+'dayofmonth')+'&oinout='+opposite+'&omonth='+$F(whichone+opposite+'month')+'&inout='+modifier+'&whichone='+whichone});}}
function checkMonthDaysStaticString(month,day,year,thing){daysinmonths=new Array();daysinmonths[1]=31;daysinmonths[2]=28;daysinmonths[3]=31;daysinmonths[4]=30;daysinmonths[5]=31;daysinmonths[6]=30;daysinmonths[7]=31;daysinmonths[8]=31;daysinmonths[9]=30;daysinmonths[10]=31;daysinmonths[11]=30;daysinmonths[12]=31;yearq=((year-2000)/4);if(parseInt(yearq)==parseFloat(yearq))daysinmonths[02]=29;if(day<=0||day>daysinmonths[parseInt(month)]){new Effect.Highlight(thing,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}
return true;}
function validate_dates(checkInId,checkOutId,datelessAllowed){if(($F(checkInId)=='mm/dd/yyyy'&&$F(checkOutId)!='mm/dd/yyyy')||($F(checkInId)!='mm/dd/yyyy'&&$F(checkOutId)=='mm/dd/yyyy')){new Effect.Highlight(checkInId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});new Effect.Highlight(checkOutId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}
else if(($F(checkInId)==''&&$F(checkOutId)!='')||($F(checkInId)!=''&&$F(checkOutId)=='')||($F(checkInId)==''&&$F(checkOutId)==''))
{new Effect.Highlight(checkInId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});new Effect.Highlight(checkOutId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}else{if($F(checkInId)!='mm/dd/yyyy'&&$F(checkOutId)!='mm/dd/yyyy'){var nowDate=new Date();nowDate.setHours(0,0,0);var dayOfMonth=nowDate.getUTCDate();var year=nowDate.getFullYear();var month=nowDate.getMonth()+1;checkindate=$F(checkInId).split("/");var checkindate_object=new Date();if((checkindate[2]-(-1))<2000)checkindate[2]=(checkindate[2])-(-2000);checkindate_object.setFullYear(checkindate[2],checkindate[0]-1,checkindate[1]);checkindate_object.setHours(0,0,0);checkoutdate=$F(checkOutId).split("/");var checkoutdate_object=new Date();if((checkoutdate[2]-(-1))<2000)checkoutdate[2]=(checkoutdate[2])-(-2000);checkoutdate_object.setFullYear(checkoutdate[2],checkoutdate[0]-1,checkoutdate[1]);checkoutdate_object.setHours(0,0,0);if(checkindate_object<nowDate){new Effect.Highlight(checkInId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}else if(checkoutdate_object<=checkindate_object){new Effect.Highlight(checkInId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});new Effect.Highlight(checkOutId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}else if(!checkMonthDaysStaticString(checkindate[0],checkindate[1],checkindate[2],checkInId)||!checkMonthDaysStaticString(checkoutdate[0],checkoutdate[1],checkoutdate[2],checkOutId)){return false;}else{return true;}}else{if(datelessAllowed){return true;}else{new Effect.Highlight(checkInId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});new Effect.Highlight(checkOutId,{startcolor:'#E21212',endcolor:'#FFFFFF',duration:2});return false;}}}}
function calToMonth(month,purpose){if(purpose.indexOf('|')>0){whichones=purpose.split("|");modifier=whichones[0];purpose=whichones[1];}else modifier='';var localdomain=get_current_domain();new Ajax.Updater(modifier+purpose+'cal',localdomain+'/caldraw',{asynchronous:true,evalScripts:true,postBody:'month='+month+'&purpose='+purpose+'&modifier='+modifier});}
function showCal(whichone,keepSelects,divs){if(whichone.indexOf('|')>0){whichones=whichone.split("|");modifier=whichones[0];whichone=whichones[1];}else modifier='';if($(modifier+whichone+'cal').style.display=='block')
{if(isexplodersix&&keepSelects==0)showselects(divs);$(modifier+whichone+'cal').style.display='none';}
else
{if(isexplodersix&&keepSelects==0){showselects();hideselects(divs);}
var localdomain=get_current_domain();if(document.getElementById(modifier+whichone)){new Ajax.Updater(modifier+whichone+'cal',localdomain+'/caldraw',{asynchronous:true,evalScripts:true,postBody:'date='+$F(modifier+whichone)+'&purpose='+whichone+'&modifier='+modifier});}else{new Ajax.Updater(modifier+whichone+'cal',localdomain+'/caldraw',{asynchronous:true,evalScripts:true,postBody:'month='+$F(modifier+whichone+'month')+'&purpose='+whichone+'&modifier='+modifier});}
$(modifier+whichone+'cal').style.display='block';document.addEventListener?document.addEventListener("click",checkCloseCals,false):document.attachEvent("click",checkCloseCals);if(whichone=='checkout')
{$(modifier+'checkincal').style.display='none';}
else if(whichone=='checkin')
{$(modifier+'checkoutcal').style.display='none';}}
whichone=null;}
function calSelDateLong(datestr,purpose){if(datestr.length>0){dates=datestr.split("/");}else{$(purpose).value='mm/dd/yyyy';return false;}
calSelDate(dates[2]+'-'+dates[0],dates[1],purpose);}
function calSelDate(month,day,purpose,divs){var modifier;if(purpose.indexOf('|')>0){whichones=purpose.split("|");modifier=whichones[1];sdpurpose=whichones[0];}else{modifier='';sdpurpose=purpose;}
var otherpurpose;if(sdpurpose=='checkin'){otherpurpose='checkout';}
else if(sdpurpose=='checkout'){otherpurpose='checkin';}
if(document.getElementById(modifier+sdpurpose)){var newmonth=month.split("-")[1];if(newmonth.length==1){newmonth='0'+newmonth;}
var newday=day;if(newday.length==1){newday='0'+newday;}
$(modifier+sdpurpose).value=newmonth+"/"+newday+"/"+month.split("-")[0];$(modifier+sdpurpose+'cal').style.display='none';var localdomain=get_current_domain();new Ajax.Updater(modifier+sdpurpose+'cal',localdomain+'/caldraw',{asynchronous:true,evalScripts:true,postBody:'month='+month+'&purpose='+sdpurpose+'&day='+day+'&clicked='+sdpurpose});try{var modifiertogo='';if(modifier)modifiertogo=modifier+'|';updatedayofweek(modifiertogo+sdpurpose);}catch(e){}
showselects(divs);}
if($(modifier+otherpurpose)){if(otherpurpose=='checkout'){checkinSeconds=dateToSeconds($F(modifier+sdpurpose));checkoutSeconds=dateToSeconds($F(modifier+otherpurpose));if($F(modifier+otherpurpose)=='mm/dd/yyyy'||(checkoutSeconds&&(checkoutSeconds<=checkinSeconds))){var d=new Date();d.setFullYear(parseInt(month.split("-")[0],10),(parseInt(month.split("-")[1],10)-1),(parseInt(day,10)+1));var newmonth=''+(d.getMonth()+1);if(newmonth.length==1){newmonth='0'+newmonth;}
var newday=''+d.getDate();if(newday.length==1){newday='0'+newday;}
var newyear=''+d.getFullYear();$(modifier+otherpurpose).value=newmonth+"/"+newday+"/"+newyear;var localdomain=get_current_domain();new Ajax.Updater(modifier+otherpurpose+'cal',localdomain+'/caldraw',{asynchronous:true,evalScripts:true,postBody:'month='+newyear+'-'+newmonth+'&purpose='+otherpurpose+'&day='+newday+'&clicked='+otherpurpose});try{var modifiertogo='';if(modifier)modifiertogo=modifier+'|';updatedayofweek(modifiertogo+otherpurpose);}catch(e){}
showselects(divs);}}}}
function dateToSeconds(datevalue){var match=/([0-9]{1,2})(\/?)([0-9]{1,2})\2([0-9]{4})/.exec(datevalue);if(match){var d=new Date();d.setFullYear(match[4],parseInt(match[1],10)-1,match[3]);return d.getTime();}}
function closecal(purpose,divs){if(isexplodersix)showselects(divs);$(purpose+'cal').style.display='none';}
function closeallcals(){try{closecal('checkin');closecal('checkout');}catch(e){}}
function checkCloseCals(e){source=e.srcElement?e.srcElement:e.target;if(source.id.match(/check/))return true;while(source.parentNode){source=source.parentNode;if(source.id)
if(source.id.match(/check/))return true;}
closeallcals();}
function checkDateOnKey(e){if(this.value!='mm/dd/yyyy')
this.value=this.value.replace(/[^\/\d]/g,'');}