function update(themonth,theday){ document.forms[fName].elements[formType+'Day'].options[theday - 1].selected = true; document.forms[fName].elements[formType+'Month'].options[themonth].selected = true; testWindow.close(); } function loadCalendar(viewMonth) { testWindow.document.close(); testWindow.document.open(); var day_of_week = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); var month_of_year = new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"); var dateObj = new Date(); var year = dateObj.getYear(); // Returns year var month = dateObj.getMonth(); // Returns month (0-11) var today = dateObj.getDate(); // Returns day (1-31) var weekday = dateObj.getDay(); // Returns day (1-31) var DAYS_OF_WEEK = 7; // "constant" for number of days in a week var DAYS_OF_MONTH = 31; // "constant" for number of days in a month var cal; // Used for printing if (viewMonth < month) { year = year + 1; } if(year < 1900){ year += 1900; //done to solve the problem of netscape and mozilla returning year in form 10X for years > 2000 } month = viewMonth; dateObj.setDate(1); // Start the calendar day at '1' dateObj.setMonth(month); // Start the calendar month at now dateObj.setYear((year)); // VARIABLES FOR FORMATTING var TR_start = ''; var TR_end = ''; var highlight_start = '
'; var highlight_end = '
'; var TD_start = '
'; var TD_end = '
'; var prevM = month - 1; var nextM = month + 1; if (nextM == 12) { nextM = 0; } if (prevM == -1) { prevM = 11; } // BEGIN CODE FOR CALENDAR cal = 'CALENDAR'; cal += ""; // NOTE: // Update the calendar.js reference below to reference where you // put the calendar.js file. cal += '
'; cal += '' + TR_start; cal += ''; cal += TR_start; /////////////////////////////////// // DO NOT EDIT BELOW THIS POINT // /////////////////////////////////// // LOOPS FOR EACH DAY OF WEEK for(index=0; index < DAYS_OF_WEEK; index++) { // PRINTS DAY cal += TD_start + '' + day_of_week[index] + '' + TD_end; } cal += TD_end + TR_end; cal += TR_start; // FILL IN BLANK GAPS UNTIL TODAY'S DAY for(index=0; index < dateObj.getDay(); index++) { cal += TD_start + ' ' + TD_end; } // LOOPS FOR EACH DAY IN CALENDAR for(index=0; index < DAYS_OF_MONTH; index++) { if( dateObj.getDate() > index ) { // RETURNS THE NEXT DAY TO PRINT week_day =dateObj.getDay(); // START NEW ROW FOR FIRST DAY OF WEEK if(week_day == 0) { cal += TR_start; } if(week_day != DAYS_OF_WEEK) { // SET VARIABLE INSIDE LOOP FOR INCREMENTING PURPOSES var day = dateObj.getDate(); // PRINTS DAY cal += TD_start + "" + day + "" + TD_end; } // END ROW FOR LAST DAY OF WEEK if(week_day == DAYS_OF_WEEK) { cal += TR_end; } } // INCREMENTS UNTIL END OF THE MONTH dateObj.setDate(dateObj.getDate()+1); }// end for loop cal += '
'; cal += month_of_year[month] + ' ' + year + '
'; cal += ''; cal += ''; cal += '
'; cal += ''; // PRINT CALENDAR testWindow.document.write(cal); } var testWindow; var formType; var fName; function openCalendar(formName,type) { formType=type; fName=formName; testWindow = window.open('','dates','width=255,height=150,resizable=0,status=0,menubar=0,location=0'); loadCalendar(document.forms[fName].elements[formType+'Month'].selectedIndex); }