function isLeapYear(year){ if(( year%4==0 && year%100==0 )|| year%400==0 ) return true; else return false; } function maxDay(month,year){ if(isLeapYear(year)){ maxDayMonth=new Array(31,29,31,30,31,30,31,31,30,31,30,31); }else{ maxDayMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31); } return maxDayMonth[month]; } function adjust_dates() { d = new Date(); day = d.getDate(); month = d.getMonth(); month_name = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); document.FrontPage_Form1.DaysToStay.selectedIndex = 0; document.FrontPage_Form1.ARRIVAL_DATE.selectedIndex = day-0; document.FrontPage_Form1.ARRIVAL_MONTH.selectedIndex = month; document.forms[0].ARRIVAL_MONTH.onchange(); } function determineyear(month,day){ thisDate=new Date(); thisYear=thisDate.getYear(); thisMonth=thisDate.getMonth(); thisDay=thisDate.getDate(); if((month+1)=thisDay){year=thisYear;} else{year=thisYear+1;} }else{year=thisYear+1;}} return year; } function checkDates(el){ var days; var inDate,inDay,inMonth,inYear; var outDate,outDay,outMonth,outYear; form=document.th_start;//dereference ms=86400000; //ms in 24 hours inDay=document.FrontPage_Form1.ARRIVAL_DATE.selectedIndex+1; inMonth=document.FrontPage_Form1.ARRIVAL_MONTH.selectedIndex; inYear=determineyear(inMonth,inDay); outDay=document.FrontPage_Form1.DEPARTURE_DATE.selectedIndex+1; outMonth=document.FrontPage_Form1.DEPARTURE_MONTH.selectedIndex; outYear=determineyear(outMonth,outDay); if(inDay>maxDay(inMonth,inYear)){ inDay=maxDay(inMonth,inYear);} if(outDay>maxDay(outMonth,outYear)){ outDay=maxDay(outMonth,outYear);} inDate=new Date(inYear,inMonth,inDay); outDate=new Date(outYear,outMonth,outDay); if(el.name=='DaysToStay'){ DaysToStay=document.FrontPage_Form1.DaysToStay.selectedIndex+1; outDate.setTime(inDate.getTime()+DaysToStay*ms); }else if(el.name=='ARRIVAL_DATE' || el.name=='ARRIVAL_MONTH'){ DaysToStay=document.FrontPage_Form1.DaysToStay.selectedIndex+0; outDate.setTime(inDate.getTime()+DaysToStay*ms); }else if(el.name=='DEPARTURE_DATE' || el.name=='DEPARTURE_MONTH'){ DaysToStay=(outDate-inDate)/ms; } document.FrontPage_Form1.ARRIVAL_MONTH.selectedIndex=inDate.getMonth(); document.FrontPage_Form1.ARRIVAL_DATE.selectedIndex=inDate.getDate()-1; document.FrontPage_Form1.DEPARTURE_MONTH.selectedIndex=outDate.getMonth(); document.FrontPage_Form1.DEPARTURE_DATE.selectedIndex=outDate.getDate()-1; document.FrontPage_Form1.DaysToStay.selectedIndex=DaysToStay-0; if(inDate<(thisDate)) alert(" Sorry! Arrival date has already passed! \n\nPlease select a valid date starting from tomorrow. \n\n Click OK to continue "); if(DaysToStay=0) alert(" Sorry! We can only accept \n\n reservations of 1 nights or more \n\n Click OK to continue "); if(DaysToStay>180) alert(" Please note! We can only accept reservations of up to 180 nights "); } function openWindow(url,top,left,width,height){ popupWin = window.open(url, 'remote', 'scrollbars=yes,toolbars=no,resizable=no,top=' + top + ',left=' + left + ',width=' + width + ',height=' + height); }