// $RCSfile: popupcalendarfunctions.js,v $ $Revision: 1.2 $ //************************************************************************ // Global variables //************************************************************************ var calendarWindow; //************************************************************************ // Function: getCalendarCtrlString // Purpose: Return the appropriate localized calendar control string. // (eg: prev, cancel, next). // Input: stringID - Control string to return. // language - language used by the WEB page. // locale - locale used by the WEB page. // Output: String containing the Calendar Control string. //************************************************************************ var CALCTRLSTR_NEXT = 0; var CALCTRLSTR_PREV = 1; var CALCTRLSTR_CNCL = 2; function getCalendarCtrlString (stringID, language, locale) { // var enCalendarCtrlStrings = new Array ("Next", "Prev", "Close"); // var esCalendarCtrlStrings = new Array ("Después", "Anterior", "Cancelan"); return (calendarCtrlStrings [stringID]); } //************************************************************************ // Function: parseYear // Purpose: Find the index of the year in a HTML SELECT control. // Input: year - year to locate in the control. // inY - the control to search. // Output: Index into the SELECT control. //************************************************************************ function parseYear(year, yearCtrlStr) { var retval=0; var i=0; var formyear=0; for (i=0; i<=5; i++) { eval ("formyear = document.getElementById('" + yearCtrlStr + "').options[" + i + "].text;"); if (year == formyear) { retval=i; break; } } return retval; } //************************************************************************ // Function: nextMonth // Purpose: Increment the month. // Input: month // Output: month + 1 //************************************************************************ function nextMonth (month) { if (month==12) { return 1; } else { return (month+1); } } //************************************************************************ // Function: prevMonth // Purpose: Previous month. // Input: month // Output: month - 1 //************************************************************************ function prevMonth (month) { var prevMonth = (month - 1) if (month==1) { prevMonth = 12; } return prevMonth } //************************************************************************ // Function: changeYear // Purpose: Updates the year if incrementing or decrementing into the // previous or following year. // Input: direction - incrementing or decrementing // month - month that is being updated. // year - current year value. // Output: Updated year. //************************************************************************ function changeYear (direction, month, year) { // increments or decrements month when it goes past Jan or Dec var theYear = year if (direction=='next') { if (month == 12) { theYear = (year + 1) } } if (direction=='prev') { if (month == 1) { theYear = (year - 1) } } return theYear } //************************************************************************ // Function: createCalendar // Purpose: Create the calendar popup. // Input: formStr - HTML name of the form that contains the date controls. // dayCtrlStr - HTML name of the day drop down. // monthCtrlStr - HTML name of the month drop down. // yearCtrlStr - HTML name of the year drop down. // dowCtrlStr - HTML name of the day of week control. // language - language used by the WEB page. // locale - locale used by the WEB page. // callBackFn - JavaScript function to call when closing the calendar. // Output: none //************************************************************************ function createCalendar (formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn) { calendarWindow = window.open ('', 'Calendar', 'width=220,height=255,resizable=yes,scrollbars=no'); var mthVal = eval ("parseInt(document.getElementById('" + monthCtrlStr + "').options [document.getElementById('" + monthCtrlStr + "').selectedIndex].value, 10)"); var yearVal = eval ("document.getElementById('" + yearCtrlStr + "').options [document.getElementById('" + yearCtrlStr + "').selectedIndex].value"); generateCalendar (calendarWindow, mthVal, yearVal, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn) } //************************************************************************ // Function: generateCalendar // Purpose: Emit the HTML into the calendar popup window. // Input: target - Target browser window for the calendar. // month - Month of the calendar top create. // year - Year of the calendar to create. // formStr - HTML name of the form that contains the date controls. // dayCtrlStr - HTML name of the day drop down. // monthCtrlStr - HTML name of the month drop down. // yearCtrlStr - HTML name of the year drop down. // dowCtrlStr - HTML name of the day of week control. // language - language used by the WEB page. // locale - locale used by the WEB page. // callBackFn - JavaScript function to call when closing the calendar. // Output: none //************************************************************************ function generateCalendar(target, month, year, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn) { target.document.open() calendar = "
| " calendar +=" <" calendar +=" | " calendar +="" calendar += getMonth (mthIdx) + " " + year calendar +=" | " calendar +="" calendar +="> | ||||
| S | " calendar +="M | " calendar +="T | " calendar +="W | " calendar +="T | " calendar +="F | " calendar +="S | " calendar +="
| " } else { calendar +=" | "+(i-firstDay)+" | " } if (i % 7 == 0 ) { if (i != lastDay-1) { calendar +="|||||
| " + getCalendarCtrlString (CALCTRLSTR_CNCL, language, locale) + " | " calendar +="||||||