var calendarWindow=null; var weekdayArr = [0,6]; var cssPath="../css/template.css"; var todaysDate = new Date(); isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false; isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false; function createCalendar(name) { getDatesFromLists(); if(name=='Begin') createCalendar(name,beginDate); else createCalendar(name,endDate); } function createCalendar(name,date) { if(date==null) { getDatesFromLists(); if(name=='Begin') date=beginDate; else date=endDate; } var position = "top=330,left=500"; if(name=='Begin') position = "top=230,left=400"; if(calendarWindow!=null && navigator.appName == "Netscape" ) { calendarWindow.close(); calendarWindow=null; } calendarWindow = window.open("", name, "width=180,height=180,status=no,resizable=no," + position +"\n"); calendarWindow.opener=window; setCalendarRef(calendarWindow); if (date == null) date= new Date(); var curMonth=monthNames[date.getMonth()]; var curYear=date.getYear(); var nextMonth,nextYear,lastMonth,lastYear; var theFirst=new Date(); theFirst.setDate(1); if(date.getMonth()==11) { nextMonth = "January" nextYear= theFirst.getYear()+1; } else { nextMonth=monthNames[theFirst.getMonth + 1]; nextYear=theFirst.getYear(); } if(theFirst.getMonth()==0) { lastMonth = "December" lastYear= theFirst.getYear()-1; } else { lastMonth=monthNames[theFirst.getMonth - 1]; lastYear=theFirst.getYear(); } if (navigator.appName == "Netscape" ) { lastYear+=1900; nextYear+=1900; curYear+=1900; } if(name=='Begin') title="Arrival"; else title="Departure"; calendarWindow.document.open(); var calendarString="" calendarString+="\n"; calendarString+=" Calendar\n"; calendarString+="\n"; calendarString+=""; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\t\n"; calendarString+="\t\t\n"; calendarString+="\t\n"; calendarString+="\t\n"; calendarString+="\t\t\n"; calendarString+="\t\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; calendarString+="\n"; //write out the month calendarString+=writeMonth(date,name); calendarString+="\n"; calendarWindow.document.write(calendarString); calendarWindow.document.close(); calendarWindow.focus(); } function writeMonth(date,name) { var beginCalendar=true; if(name!='Begin') beginCalendar = false; date = cleanDate(date); var theFirst=new Date(date); theFirst.setDate(1); var curDay=new Date(date); curDay.setTime(theFirst.getTime() - (theFirst.getDay() * day)); var Day=1; var LastDay=daysInMonth(new Date(date)); var OnLastDay=0; var monthString = ""; //Fll in days of week until the first of month monthString = monthString + ""; while(curDay.getDate()>1) { monthString = monthString + ""; curDay.setTime(curDay.getTime() + day); } // Write rest of the 1st week for (j=curDay.getDay(); j<7; j++) { if(curDay.getTime() < minBeginDate.getTime()) monthString+=""; else if (curDay.getTime() == cleanDate(beginDate).getTime() || curDay.getTime() == cleanDate(endDate).getTime()) monthString+=""; else monthString+=""; curDay.setTime(curDay.getTime() + day); } monthString +="\n"; // Write the rest of the weeks for (k=2; k<7; k++) { monthString+="\n"; for (j=0; j<7; j++) { if(curDay.getTime() < minBeginDate.getTime()) monthString+=""; else if ((beginCalendar && curDay.getTime() == cleanDate(beginDate).getTime()) || (!beginCalendar && curDay.getTime() == cleanDate(endDate).getTime())) monthString+=""; else monthString+=""; curDay.setTime(curDay.getTime() + day); if (Day > LastDay) { OnLastDay = 1; break; } } if (j == 6) monthString = monthString + ""; if (OnLastDay == 1) break; } // Fill up the rest of last week with proper blanks, so that we get proper square blocks for (m=1; m<(7-j); m++) { monthString = monthString + ""; curDay.setTime(curDay.getTime() + day); } return monthString; } function formatDate(calDate) { return "" + calDate.getYear() + "-" + calDate.getMonth() + "-" + calDate.getDate(); } function formatYear(p_day) { var vData; var vY2 = new String(curYear.substr(2,2)); return vY2; } function formatMonth(p_day) { var vData; var vMonth = curMonth; vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth; return vMonth; } function formatDay(p_day) { var vData; var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day; return (vDD - 1); } function closeCalendar() { if(calendarWindow!=null) calendarWindow.close(); calendarWindow=null; } function setCalendarRef(calWindow) { calendarWindow=calWindow; } function setDay(dateInSeconds,lstName) { var newDate = new Date(); newDate.setTime(dateInSeconds); if(lstName=="Begin") { beginDate=newDate; setDates(); adjustDates(); if(beginDate!=newDate) newDate=beginDate; //createCalendar(lstName,newDate); } else { endDate=newDate; setDates(); adjustDates(); if(endDate!=newDate) newDate=endDate; //createCalendar(lstName,newDate); } calendarWindow.close(); calendarWindow=null; } function showLastMonth(name,dateInSeconds) { var newDate = new Date(); newDate.setTime(dateInSeconds); createCalendar(name,getLastMonth(newDate)); } function showNextMonth(name,dateInSeconds) { var newDate = new Date(); newDate.setTime(dateInSeconds); createCalendar(name,getNextMonth(newDate)); } function initForm() { initDayList(document.forms[0].lstBeginDay,new Date()); initYearList(document.forms[0].lstBeginYear); initDayList(document.forms[0].lstEndDay,new Date()); initYearList(document.forms[0].lstEndYear); } function setForm() { var dt = new Date() var dt2 = new Date(); dt2.setTime(dt.getTime()+ day); var dat=""; var dat2=""; if (navigator.appName == "Microsoft Internet Explorer" ) { dat+=dt.getYear(); dat2+=dt2.getYear(); } else { dat+=dt.getYear()+1900; dat2+=dt2.getYear()+1900; } setIndex(dat2,document.forms[0].lstEndYear); setIndex(dat,document.forms[0].lstBeginYear); setIndex(dt2.getDate(),document.forms[0].lstEndDay); setIndex(dt.getDate(),document.forms[0].lstBeginDay); document.forms[0].lstEndMonth.options[dt2.getMonth()].selected=true; document.forms[0].lstBeginMonth.options[dt.getMonth()].selected=true; //checkMonths() } // Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x function isBrowserSupp() { // Get the version of the browser version = parseFloat( navigator.appVersion ); if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) { return false; } else { return true; } }
" + title + "
\n"; calendarString+="\t\t\t\n"; calendarString+="\t\t\t\t\n"; calendarString+="\t\t\t\t\t\n"; calendarString+="\t\t\t\t\t\n"; calendarString+="\t\t\t\t\t\n"; calendarString+="\t\t\t\t\n"; calendarString+="\t\t\t
<<" + curMonth + " " + curYear + ">>
\n"; calendarString+="\t\t
SMTWTFS
" + curDay.getDate() + "" + curDay.getDate() + "" + curDay.getDate() + "" + curDay.getDate() + "
" + curDay.getDate() + "" + curDay.getDate() + "" + curDay.getDate() + "
" + curDay.getDate() + "