var today = new Date(new Date().valueOf()); var dateBoxPieceBlank = " "; var dateBoxPiece = "##DAY##"; var baseDateBoxHeader = "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += ""; var dateBoxFooter = "\n"; dateBoxFooter += "\n"; dateBoxFooter += "\n
\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "\n"; baseDateBoxHeader += "
<
##MONTHNAME## ##YEAR##
>
\n"; baseDateBoxHeader += "
SunMonTueWedThuFriSat
CLOSE
\n"; var calBuffer = ""; var caldays = new Array(31,28,31,30,31,30,31,31,30,31,30,31); var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); function isLeapYear(yr) { if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) { return true; } else { return false; } } function GetDOW2(d,m,y) { var dt = new Date(y,m-1,d); return (dt.getDay())%7; } var selectBoxFlag = 0; var maxYear = 0; var minYear = 0; function displayCalendar(hideSelects, inDateSet, e) { var xMousePos = 0; var yMousePos = 0; var theForm = document.searchform; selectBoxFlag = hideSelects; var inYear = theForm.chinyear.options[theForm.chinyear.selectedIndex].value; var mon = parseInt(theForm.chinmonth.options[theForm.chinmonth.selectedIndex].value,10); var day = parseInt(theForm.chinday.options[theForm.chinday.selectedIndex].value,10); var year = parseInt(theForm.chinyear.options[theForm.chinyear.selectedIndex].value,10); currentMonth = mon; currentYear = year; currentDay = day; maxYear = parseInt(theForm.chinyear.options[(theForm.chinyear.options.length-1)].value,10); minYear = parseInt(theForm.chinyear.options[0].value,10); drawCalendarBody(inDateSet,mon,day,year); if(document.all) { xMousePos = event.x - event.offsetX + document.body.scrollLeft + 'px'; yMousePos = event.y - event.offsetY + document.body.scrollTop + 'px'; } else { xMousePos = e.pageX + 'px'; yMousePos = e.pageY + 'px'; } document.getElementById('CAL').style.left = xMousePos; document.getElementById('CAL').style.top = yMousePos; document.getElementById('CAL').style.visibility = "visible"; if (selectBoxFlag == 1) { if (theForm.nights) theForm.nights.style.visibility = "hidden"; if (theForm.children1) theForm.children1.style.visibility = "hidden"; if (theForm.children2) theForm.children2.style.visibility = "hidden"; if (theForm.children3) theForm.children3.style.visibility = "hidden"; if (theForm.children4) theForm.children4.style.visibility = "hidden"; if (theForm.childage11) theForm.childage11.style.visibility = "hidden"; if (theForm.childage21) theForm.childage21.style.visibility = "hidden"; if (theForm.childage31) theForm.childage31.style.visibility = "hidden"; if (theForm.childage41) theForm.childage41.style.visibility = "hidden"; } if (selectBoxFlag == 2) { if (theForm.nights) theForm.nights.style.visibility = "hidden"; if (theForm.rooms) theForm.rooms.style.visibility = "hidden"; if (theForm.childage11) theForm.childage11.style.visibility = "hidden"; if (theForm.childage21) theForm.childage21.style.visibility = "hidden"; if (theForm.childage31) theForm.childage31.style.visibility = "hidden"; if (theForm.childage41) theForm.childage41.style.visibility = "hidden"; if (theForm.childage51) theForm.childage51.style.visibility = "hidden"; if (theForm.childage12) theForm.childage12.style.visibility = "hidden"; if (theForm.childage22) theForm.childage22.style.visibility = "hidden"; if (theForm.childage32) theForm.childage32.style.visibility = "hidden"; if (theForm.childage42) theForm.childage42.style.visibility = "hidden"; if (theForm.childage52) theForm.childage52.style.visibility = "hidden"; } } function hideCalendar() { var theForm = document.searchform; document.getElementById('CAL').style.visibility = "hidden"; if (selectBoxFlag == 1) { if (theForm.nights) theForm.nights.style.visibility = "visible"; if (theForm.children1) theForm.children1.style.visibility = "visible"; if (theForm.children2) theForm.children2.style.visibility = "visible"; if (theForm.children3) theForm.children3.style.visibility = "visible"; if (theForm.children4) theForm.children4.style.visibility = "visible"; if (theForm.childage11) theForm.childage11.style.visibility = "visible"; if (theForm.childage21) theForm.childage21.style.visibility = "visible"; if (theForm.childage31) theForm.childage31.style.visibility = "visible"; if (theForm.childage41) theForm.childage41.style.visibility = "visible"; } if (selectBoxFlag == 2) { if (theForm.nights) theForm.nights.style.visibility = "visible"; if (theForm.rooms) theForm.rooms.style.visibility = "visible"; if (theForm.childage11) theForm.childage11.style.visibility = "visible"; if (theForm.childage21) theForm.childage21.style.visibility = "visible"; if (theForm.childage31) theForm.childage31.style.visibility = "visible"; if (theForm.childage41) theForm.childage41.style.visibility = "visible"; if (theForm.childage51) theForm.childage51.style.visibility = "visible"; if (theForm.childage12) theForm.childage12.style.visibility = "visible"; if (theForm.childage22) theForm.childage22.style.visibility = "visible"; if (theForm.childage32) theForm.childage32.style.visibility = "visible"; if (theForm.childage42) theForm.childage42.style.visibility = "visible"; if (theForm.childage52) theForm.childage52.style.visibility = "visible"; } } function nextMonth(inDateSet) { currentMonth += 1; if (currentMonth > 12 && currentYear + 1 <= maxYear) { currentMonth = 1; currentYear++; } if (currentMonth > 12) { currentMonth = 12; } if(currentMonth == (today.getMonth()+1) && currentYear == today.getYear()) { drawCalendarBody(inDateSet,currentMonth,currentDay,currentYear); } else { drawCalendarBody(inDateSet,currentMonth,0,currentYear); } } function previousMonth(inDateSet) { if ((currentMonth - 1) < (today.getMonth()+1) && currentYear <= today.getYear()) { } else { currentMonth -= 1; if (currentMonth < 1 && currentYear - 1 >= minYear) { currentMonth = 12; currentYear -= 1; } if (currentMonth == (today.getMonth()+1) && currentYear == today.getYear()) { drawCalendarBody(inDateSet,currentMonth,currentDay,currentYear); } else { drawCalendarBody(inDateSet,currentMonth,0,currentYear); } } } var currentMonth = 1; var currentYear = y2k(today.getYear()); var currentDay = 1; function drawCalendarBody(inDateSet,mon,day,year) { calObj = document.getElementById('CAL').CAL_BODY; var dowStartPos = GetDOW2(1,mon,year); var finalDay = caldays[(mon-1)]; if (isLeapYear(year) && mon == 2) { finalDay += 1; } re_MonthName = /##MONTHNAME##/g; re_Year = /##YEAR##/g; re_DateSet = /##DATESET##/g; dateBoxHeader = baseDateBoxHeader; dateBoxHeader = dateBoxHeader.replace(re_MonthName,months[(mon-1)]); dateBoxHeader = dateBoxHeader.replace(re_Year,""+year); dateBoxHeader = dateBoxHeader.replace(re_DateSet,""+inDateSet); calBuffer = generateGrid(inDateSet,dowStartPos,finalDay, mon,day,year); document.getElementById('CAL_BODY').innerHTML = dateBoxHeader + calBuffer + dateBoxFooter; } function generateGrid(inDateSet,startPos,endPos,m,d,y) { var currentDay=1; var gridCount=0; var doBlanks=true; var tmpBuffer=""; re_Month = /##MONTH##/g; re_Day = /##DAY##/g; re_Year = /##YEAR##/g; re_BGColor = /##BGCOLOR##/g; re_DateSet = /##DATESET##/g; for (var i=0;i<6;i++) { tmpBuffer += "\n"; for (var j=0;j<7;j++) { if(gridCount < startPos || currentDay > endPos) { tmpBuffer += dateBoxPieceBlank + "\n"; } else { pasrsedDBP = dateBoxPiece; pasrsedDBP = pasrsedDBP.replace(re_Month,""+m); pasrsedDBP = pasrsedDBP.replace(re_Day,""+currentDay); pasrsedDBP = pasrsedDBP.replace(re_Year,""+y); pasrsedDBP = pasrsedDBP.replace(re_DateSet,""+inDateSet); if (currentDay == d) { pasrsedDBP = pasrsedDBP.replace(re_BGColor,"#BFC1FF"); } else { pasrsedDBP = pasrsedDBP.replace(re_BGColor,"#FFFFFF"); } tmpBuffer += pasrsedDBP + "\n"; currentDay++; } gridCount++; } tmpBuffer += "\n"; } return tmpBuffer; } function setDateBoxes(whichDateSet,m,d,y) { var theForm = document.searchform; eval("monthObj = theForm.ch"+whichDateSet+"month;"); eval("dayObj = theForm.ch"+whichDateSet+"day;"); eval("yearObj = theForm.ch"+whichDateSet+"year;"); var yearOffset = parseInt(theForm.chinyear.options[0].value,10); monthObj.options[(m-1)].selected = true; dayObj.options[(d-1)].selected = true; yearObj.options[(y-yearOffset)].selected = true; changeDate(); hideCalendar(); } function y2k(number) { return (number < 1000) ? number + 1900 : number; }