function vOnLoadEvents(onLoadTag) { var agt=navigator.userAgent.toLowerCase(); if (onLoadTag == "results" && (agt.indexOf("safari") == -1)) { window.location.hash=onLoadTag; } else { document.searchForm.QueryText.focus; } vCheckState(); vCheckExpDateOperator(); vCheckStartDateOperator(); vCheckAwardNumberOperator(); vCheckOriginalAwardDateOperator(); } function vSetSearchParameters() { // Fix all possibly disabled fields. if (typeof(document.searchForm.PIState) != "undefined") { if ( document.searchForm.PIState.disabled ) { document.searchForm.PIState.disabled = false; document.searchForm.PIZip.disabled = false; document.searchForm.PIState.value = ""; document.searchForm.PIZip.value = ""; } } if (typeof(document.searchForm.ExpDateTo) != "undefined") { if ( document.searchForm.ExpDateTo.disabled ) { document.searchForm.ExpDateTo.disabled = false; document.searchForm.ExpDateTo.value = ""; } if ( document.searchForm.ExpDateFrom.disabled ) { document.searchForm.ExpDateFrom.disabled = false; document.searchForm.ExpDateFrom.value = ""; } if ( document.searchForm.OriginalAwardDateTo.disabled ) { document.searchForm.OriginalAwardDateTo.disabled = false; document.searchForm.OriginalAwardDateTo.value = ""; } if ( document.searchForm.OriginalAwardDateFrom.disabled ) { document.searchForm.OriginalAwardDateFrom.disabled = false; document.searchForm.OriginalAwardDateFrom.value = ""; } if ( document.searchForm.StartDateTo.disabled ) { document.searchForm.StartDateTo.disabled = false; document.searchForm.StartDateTo.value = ""; } if ( document.searchForm.StartDateFrom.disabled ) { document.searchForm.StartDateFrom.disabled = false; document.searchForm.StartDateFrom.value = ""; } if ( document.searchForm.AwardNumberTo.disabled ) { document.searchForm.AwardNumberTo.disabled = false; document.searchForm.AwardNumberTo.value = ""; } if ( document.searchForm.AwardNumberFrom.disabled ) { document.searchForm.AwardNumberFrom.disabled = false; document.searchForm.AwardNumberFrom.value = ""; } } } function vLookupWindow(sLookup) { var url = "/awardsearch/subLookup.do?"; url = url + "dispatch=" + sLookup //alert('url = ' + url); var hNewWnd = window.open(url,"","width=520,height=590,left=480,resizable=yes,status=yes,scrollbars=yes"); if ((document.window != null) && (!hNewWnd.opener)) hNewWnd.opener = document.window; } function popwin(url) { //alert('popwin url = ' + url); var hNewWnd = window.open(url,"","width=520,height=590,left=480,resizable=yes,status=yes,scrollbars=yes"); if ((document.window != null) && (!hNewWnd.opener)) hNewWnd.opener = document.window; } function vCheckState() { if (typeof(document.searchForm.PICountry) != "undefined") { if ((document.searchForm.PICountry.value != null) && (document.searchForm.PICountry.options[document.searchForm.PICountry.selectedIndex].value !='US') && document.searchForm.PICountry.options[document.searchForm.PICountry.selectedIndex].value !='' ) { document.searchForm.PIState.disabled = true; document.searchForm.PIZip.disabled = true; } else { document.searchForm.PIState.disabled = false; document.searchForm.PIZip.disabled = false; } } } function vCheckCongDist() { if (typeof(document.searchForm.CongDistCode) != "undefined") { if ( ((document.searchForm.PIState.value == null) || (document.searchForm.PIState.options[document.searchForm.PIState.selectedIndex].value =='')) && (document.searchForm.CongDistCode.options[document.searchForm.CongDistCode.selectedIndex].value !='') ) { alert("Please remember to select a state for the congressional district. The state selection is found above in the Awardee Information section."); } } } function vCheckExpDateOperator() { if (typeof(document.searchForm.ExpDateOperator) != "undefined") { if (document.searchForm.ExpDateOperator.options[document.searchForm.ExpDateOperator.selectedIndex].value == "") { document.searchForm.ExpDateTo.disabled = true; document.searchForm.ExpDateTo.value = ""; document.searchForm.ExpDateFrom.disabled = true; document.searchForm.ExpDateFrom.value = ""; } else if (document.searchForm.ExpDateOperator.options[document.searchForm.ExpDateOperator.selectedIndex].value == "Range") { document.searchForm.ExpDateTo.disabled = false; if ( document.searchForm.ExpDateTo.value == "" ) { document.searchForm.ExpDateTo.value = ""; } document.searchForm.ExpDateFrom.disabled = false; if ( document.searchForm.ExpDateFrom.value == "" ) { document.searchForm.ExpDateFrom.value = ""; } } else if (document.searchForm.ExpDateOperator.options[document.searchForm.ExpDateOperator.selectedIndex].value == "Before") { document.searchForm.ExpDateTo.disabled = false; document.searchForm.ExpDateFrom.disabled = true; document.searchForm.ExpDateFrom.value = ""; if ( document.searchForm.ExpDateTo.value == "" ) { document.searchForm.ExpDateTo.value = ""; } } else { document.searchForm.ExpDateFrom.disabled = false; document.searchForm.ExpDateTo.disabled = true; document.searchForm.ExpDateTo.value = ""; if ( document.searchForm.ExpDateFrom.value == "" ) { document.searchForm.ExpDateFrom.value = ""; } } } } function vCheckOriginalAwardDateOperator() { if (typeof(document.searchForm.OriginalAwardDateOperator) != "undefined") { if (document.searchForm.OriginalAwardDateOperator.options[document.searchForm.OriginalAwardDateOperator.selectedIndex].value == "") { document.searchForm.OriginalAwardDateTo.disabled = true; document.searchForm.OriginalAwardDateTo.value = ""; document.searchForm.OriginalAwardDateFrom.disabled = true; document.searchForm.OriginalAwardDateFrom.value = ""; } else if (document.searchForm.OriginalAwardDateOperator.options[document.searchForm.OriginalAwardDateOperator.selectedIndex].value == "Range") { document.searchForm.OriginalAwardDateTo.disabled = false; if ( document.searchForm.OriginalAwardDateTo.value == "" ) { document.searchForm.OriginalAwardDateTo.value = ""; } document.searchForm.OriginalAwardDateFrom.disabled = false; if ( document.searchForm.OriginalAwardDateFrom.value == "" ) { document.searchForm.OriginalAwardDateFrom.value = ""; } } else if (document.searchForm.OriginalAwardDateOperator.options[document.searchForm.OriginalAwardDateOperator.selectedIndex].value == "Before") { document.searchForm.OriginalAwardDateTo.disabled = false; document.searchForm.OriginalAwardDateFrom.disabled = true; document.searchForm.OriginalAwardDateFrom.value = ""; if ( document.searchForm.OriginalAwardDateTo.value == "" ) { document.searchForm.OriginalAwardDateTo.value = ""; } } else { document.searchForm.OriginalAwardDateFrom.disabled = false; document.searchForm.OriginalAwardDateTo.disabled = true; document.searchForm.OriginalAwardDateTo.value = ""; if ( document.searchForm.OriginalAwardDateFrom.value == "" ) { document.searchForm.OriginalAwardDateFrom.value = ""; } } } } function vCheckStartDateOperator() { if (typeof(document.searchForm.StartDateOperator) != "undefined") { if (document.searchForm.StartDateOperator.options[document.searchForm.StartDateOperator.selectedIndex].value == "") { document.searchForm.StartDateTo.disabled = true; document.searchForm.StartDateTo.value = ""; document.searchForm.StartDateFrom.disabled = true; document.searchForm.StartDateFrom.value = ""; } else if (document.searchForm.StartDateOperator.options[document.searchForm.StartDateOperator.selectedIndex].value == "Range") { document.searchForm.StartDateTo.disabled = false; if ( document.searchForm.StartDateTo.value == "" ) { document.searchForm.StartDateTo.value = ""; } document.searchForm.StartDateFrom.disabled = false; if ( document.searchForm.StartDateFrom.value == "" ) { document.searchForm.StartDateFrom.value = ""; } } else if (document.searchForm.StartDateOperator.options[document.searchForm.StartDateOperator.selectedIndex].value == "Before") { document.searchForm.StartDateTo.disabled = false; document.searchForm.StartDateFrom.disabled = true; document.searchForm.StartDateFrom.value = ""; if ( document.searchForm.StartDateTo.value == "" ) { document.searchForm.StartDateTo.value = ""; } } else { document.searchForm.StartDateFrom.disabled = false; document.searchForm.StartDateTo.disabled = true; document.searchForm.StartDateTo.value = ""; if ( document.searchForm.StartDateFrom.value == "" ) { document.searchForm.StartDateFrom.value = ""; } } } } function vCheckAwardNumberOperator() { if (typeof(document.searchForm.AwardNumberOperator) != "undefined") { if (document.searchForm.AwardNumberOperator.options[document.searchForm.AwardNumberOperator.selectedIndex].value == "") { document.searchForm.AwardNumberTo.disabled = true; document.searchForm.AwardNumberTo.value = ""; document.searchForm.AwardNumberFrom.disabled = true; document.searchForm.AwardNumberFrom.value = ""; } else if (document.searchForm.AwardNumberOperator.options[document.searchForm.AwardNumberOperator.selectedIndex].value == "Range") { document.searchForm.AwardNumberTo.disabled = false; if ( document.searchForm.AwardNumberTo.value == "" ) { document.searchForm.AwardNumberTo.value = ""; } document.searchForm.AwardNumberFrom.disabled = false; if ( document.searchForm.AwardNumberFrom.value == "" ) { document.searchForm.AwardNumberFrom.value = ""; } } else if (document.searchForm.AwardNumberOperator.options[document.searchForm.AwardNumberOperator.selectedIndex].value == "Before") { document.searchForm.AwardNumberTo.disabled = false; document.searchForm.AwardNumberFrom.disabled = true; document.searchForm.AwardNumberFrom.value = ""; if ( document.searchForm.AwardNumberTo.value == "" ) { document.searchForm.AwardNumberTo.value = ""; } } else { document.searchForm.AwardNumberFrom.disabled = false; document.searchForm.AwardNumberTo.disabled = true; document.searchForm.AwardNumberTo.value = ""; if ( document.searchForm.AwardNumberFrom.value == "" ) { document.searchForm.AwardNumberFrom.value = ""; } } } } function vCheckIncludeCOPI() { if ( document.searchForm.IncludeCOPI.checked == true ) { document.searchForm.COPIFirstName.value = document.searchForm.PIFirstName.value; document.searchForm.COPILastName.value = document.searchForm.PILastName.value; } else { document.searchForm.COPIFirstName.value = ""; document.searchForm.COPILastName.value = ""; } } function vCheckRestrictActive() { if ( document.searchForm.RestrictActive.checked ) { document.searchForm.RestrictExpired.checked = false; document.searchForm.RestrictHistorical.checked = false; } } function vCheckRestrictExpired() { if ( document.searchForm.RestrictExpired.checked ) { document.searchForm.RestrictActive.checked = false; document.searchForm.RestrictHistorical.checked = false; } } function vCheckRestrictHistorical() { if ( document.searchForm.RestrictHistorical.checked ) { document.searchForm.RestrictActive.checked = false; document.searchForm.RestrictExpired.checked = false; } } // // JavaScript Calendar Component // Usage: Add the following lines of code to your page to enable the Calendar // component. // // // // THIS LINE LOADS THE JS LIBRARY FOR THE CALENDAR COMPONENT // // // // // // // THIS LINE IS USED IN CONJUNCTION WITH A FORM FIELD (myDateField) IN A FORM (myForm). // // Replace "myForm" and "myDateField" WITH THE NAME OF YOUR FORM AND INPUT FIELD RESPECTIVELY // // WINDOW OPTIONS SET THE WIDTH, HEIGHT, AND X/Y POSITION OF THE CALENDAR WINDOW // // WITH TITLEBAR ON, ALL OTHER OPTIONS (TOOLBARS, ETC) ARE DISABLED BY DEFAULT // // // Popup Calendar // // // // Required Files: // // calendar.js - contains all JavaScript functions to make the calendar work // // calendar.html - html document with the following 2 lines of code // calDocFrameset = parent.opener.calDocTop + parent.opener.calDocBottom // document.write(calDocFrameset); // // (not required if you call the showCalendar() // function. However, calling showCalendar() directly causes // the Java Virtual Machine (JVM) to start which slows down the // loading of the calendar.) // // // Files Generally Included: // // calendar.gif - image that looks like a little calendar // // yourPage.html - page that contains a form and a date field which implements // the calendar component // // Note: This file has been edited to take out references to framesets // BEGIN USER-EDITABLE SECTION ----------------------------------------------------- // SPECIFY DATE FORMAT RETURNED BY THIS CALENDAR // (THIS IS ALSO THE DATE FORMAT RECOGNIZED BY THIS CALENDAR) // DATE FORMAT OPTIONS: // // dd = 1 or 2-digit Day // DD = 2-digit Day // mm = 1 or 2-digit Month // MM = 2-digit Month // yy = 2-digit Year // YY = 4-digit Year // yyyy = 4-digit Year // month = Month name in lowercase letters // Month = Month name in initial caps // MONTH = Month name in captital letters // mon = 3-letter month abbreviation in lowercase letters // Mon = 3-letter month abbreviation in initial caps // MON = 3-letter month abbreviation in uppercase letters // weekday = name of week in lowercase letters // Weekday = name of week in initial caps // WEEKDAY = name of week in uppercase letters // wkdy = 3-letter weekday abbreviation in lowercase letters // Wkdy = 3-letter weekday abbreviation in initial caps // WKDY = 3-letter weekday abbreviation in uppercase letters // // Examples: // // calDateFormat = "mm/dd/yy"; // calDateFormat = "Weekday, Month dd, yyyy"; // calDateFormat = "wkdy, mon dd, yyyy"; // calDateFormat = "DD.MM.YY"; // FORMAT UNSUPPORTED BY JAVASCRIPT -- REQUIRES CUSTOM PARSING // calDateFormat = "MM/DD/yyyy"; // CALENDAR COLORS //topBackground = "white"; // BG COLOR OF THE TOP FRAME //bottomBackground = "white"; // BG COLOR OF THE BOTTOM FRAME //tableBGColor = "black"; // BG COLOR OF THE BOTTOM FRAME'S TABLE //cellColor = "lightgrey"; // TABLE CELL BG COLOR OF THE DATE CELLS IN THE BOTTOM FRAME //headingCellColor = "white"; // TABLE CELL BG COLOR OF THE WEEKDAY ABBREVIATIONS //headingTextColor = "black"; // TEXT COLOR OF THE WEEKDAY ABBREVIATIONS //dateColor = "blue"; // TEXT COLOR OF THE LISTED DATES (1-28+) //focusColor = "#ff0000"; // TEXT COLOR OF THE SELECTED DATE (OR CURRENT DATE) //hoverColor = "darkred"; // TEXT COLOR OF A LINK WHEN YOU HOVER OVER IT //fontStyle = "12pt arial, helvetica"; // TEXT STYLE FOR DATES //headingFontStyle = "bold 12pt arial, helvetica"; // TEXT STYLE FOR WEEKDAY ABBREVIATIONS topBackground = "#BDDBE7"; bottomBackground = "#BDDBE7"; tableBGColor = "black"; cellColor = "white"; headingCellColor = "#003399"; headingTextColor = "white"; dateColor = "blue"; focusColor = "#ff0000"; hoverColor = "darkred"; fontStyle = "bold 12pt arial, helvetica"; headingFontStyle = "bold 12pt arial, helvetica"; // FORMATTING PREFERENCES bottomBorder = false; // TRUE/FALSE (WHETHER TO DISPLAY BOTTOM CALENDAR BORDER) tableBorder = 0; // SIZE OF CALENDAR TABLE BORDER (BOTTOM FRAME) 0=none // END USER-EDITABLE SECTION ------------------------------------------------------- // DETERMINE BROWSER BRAND var isNav = false; var isIE = false; // ASSUME IT'S EITHER NETSCAPE OR MSIE if (navigator.appName == "Netscape") { isNav = true; } else { isIE = true; } // GET CURRENTLY SELECTED LANGUAGE selectedLanguage = navigator.language; // PRE-BUILD PORTIONS OF THE CALENDAR WHEN THIS JS LIBRARY LOADS INTO THE BROWSER buildCalParts(); // CALENDAR FUNCTIONS BEGIN HERE --------------------------------------------------- // SET THE INITIAL VALUE OF THE GLOBAL DATE FIELD function setDateField(dateField) { if ( !dateField.disabled ) { // ASSIGN THE INCOMING FIELD OBJECT TO A GLOBAL VARIABLE calDateField = dateField; // GET THE VALUE OF THE INCOMING FIELD inDate = dateField.value; // SET calDate TO THE DATE IN THE INCOMING FIELD OR DEFAULT TO TODAY'S DATE setInitialDate(); // THE CALENDAR FRAMESET DOCUMENTS ARE CREATED BY JAVASCRIPT FUNCTIONS calDocTop = buildTopCalFrame(); calDocBottom = buildBottomCalFrame(); top.newWin = window.open('common/calendar.html', 'cal', 'dependent=yes, width=280, height=270, screenX=200, screenY=300, titlebar=yes'); } else { alert("Field is disabled. Please select or change the date search type."); } // End if } // SET THE INITIAL CALENDAR DATE TO TODAY OR TO THE EXISTING VALUE IN dateField function setInitialDate() { // CREATE A NEW DATE OBJECT (WILL GENERALLY PARSE CORRECT DATE EXCEPT WHEN "." IS USED AS A DELIMITER) // (THIS ROUTINE DOES *NOT* CATCH ALL DATE FORMATS, IF YOU NEED TO PARSE A CUSTOM DATE FORMAT, DO IT HERE) calDate = new Date(inDate); // IF THE INCOMING DATE IS INVALID, USE THE CURRENT DATE if (isNaN(calDate)) { // ADD CUSTOM DATE PARSING HERE // IF IT FAILS, SIMPLY CREATE A NEW DATE OBJECT WHICH DEFAULTS TO THE CURRENT DATE calDate = new Date(); } // KEEP TRACK OF THE CURRENT DAY VALUE calDay = calDate.getDate(); // SET DAY VALUE TO 1... TO AVOID JAVASCRIPT DATE CALCULATION ANOMALIES // (IF THE MONTH CHANGES TO FEB AND THE DAY IS 30, THE MONTH WOULD CHANGE TO MARCH // AND THE DAY WOULD CHANGE TO 2. SETTING THE DAY TO 1 WILL PREVENT THAT) calDate.setDate(1); } // POPUP A WINDOW WITH THE CALENDAR IN IT function showCalendar(dateField) { // SET INITIAL VALUE OF THE DATE FIELD AND CREATE TOP AND BOTTOM FRAMES setDateField(dateField); // USE THE JAVASCRIPT-GENERATED DOCUMENTS (calDocTop, calDocBottom) IN THE FRAMESET //calDocFrameset = //"\n" + //"\n" + // " Calendar\n" + //"\n" + //newWin = window; // USE THE JAVASCRIPT-GENERATED DOCUMENTS (calDocTop, calDocBottom) IN THE FRAMESET //"\n" + //" \n" + //" \n" + //"\n"; // for browsers that cannot use framesets calDocFrameset = calDocTop + calDocBottom; winPrefs = '"dependent=yes, width=280, height=270, screenX=200, screenY=300, titlebar=yes"'; //"\n"; // DISPLAY THE CALENDAR IN A NEW POPUP WINDOW top.newWin = window.open("javascript:parent.opener.calDocFrameset", "calWin", winPrefs); top.newWin.focus(); } // CREATE THE TOP CALENDAR FRAME function buildTopCalFrame() { // CREATE THE TOP FRAME OF THE CALENDAR var calDoc = "" + "" + "NSF :: Calendar"+ ""+ "" + "" + "
" + "
" + "" + "" + "" + "" + "" + "" + "
" + "
" + getMonthSelect() + "" + "
" + "
" + "" + "
" + "
" + "
"; return calDoc; } // CREATE THE BOTTOM CALENDAR FRAME // (THE MONTHLY CALENDAR) function buildBottomCalFrame() { // START CALENDAR DOCUMENT var calDoc = calendarBegin; // GET MONTH, AND YEAR FROM GLOBAL CALENDAR DATE month = calDate.getMonth(); year = calDate.getFullYear(); // GET GLOBALLY-TRACKED DAY VALUE (PREVENTS JAVASCRIPT DATE ANOMALIES) day = calDay; var i = 0; // DETERMINE THE NUMBER OF DAYS IN THE CURRENT MONTH var days = getDaysInMonth(); // IF GLOBAL DAY VALUE IS > THAN DAYS IN MONTH, HIGHLIGHT LAST DAY IN MONTH if (day > days) { day = days; } // DETERMINE WHAT DAY OF THE WEEK THE CALENDAR STARTS ON var firstOfMonth = new Date (year, month, 1); // GET THE DAY OF THE WEEK THE FIRST DAY OF THE MONTH FALLS ON var startingPos = firstOfMonth.getDay(); days += startingPos; // KEEP TRACK OF THE COLUMNS, START A NEW ROW AFTER EVERY 7 COLUMNS var columnCount = 0; // MAKE BEGINNING NON-DATE CELLS BLANK for (i = 0; i < startingPos; i++) { calDoc += blankCell; columnCount++; } // SET VALUES FOR DAYS OF THE MONTH var currentDay = 0; var dayType = "weekday"; // DATE CELLS CONTAIN A NUMBER for (i = startingPos; i < days; i++) { var paddingChar = " "; // ADJUST SPACING SO THAT ALL LINKS HAVE RELATIVELY EQUAL WIDTHS if (i-startingPos+1 < 10) { padding = "  "; } else { padding = " "; } // GET THE DAY CURRENTLY BEING WRITTEN currentDay = i-startingPos+1; // SET THE TYPE OF DAY, THE focusDay GENERALLY APPEARS AS A DIFFERENT COLOR if (currentDay == day) { dayType = "focusDay"; } else { dayType = "weekDay"; } // ADD THE DAY TO THE CALENDAR STRING calDoc += "" + "" + padding + currentDay + paddingChar + ""; columnCount++; // START A NEW ROW WHEN NECESSARY if (columnCount % 7 == 0) { calDoc += ""; } } // MAKE REMAINING NON-DATE CELLS BLANK for (i=days; i<42; i++) { calDoc += blankCell; columnCount++; // START A NEW ROW WHEN NECESSARY if (columnCount % 7 == 0) { calDoc += ""; if (i<41) { calDoc += ""; } } } // FINISH THE NEW CALENDAR PAGE calDoc += calendarEnd; // RETURN THE COMPLETED CALENDAR PAGE return calDoc; } // WRITE THE MONTHLY CALENDAR TO THE BOTTOM CALENDAR FRAME function writeCalendar() { // CREATE THE NEW CALENDAR FOR THE SELECTED MONTH & YEAR calDocBottom = buildBottomCalFrame(); calDocTop = buildTopCalFrame(); // WRITE THE NEW CALENDAR TO THE BOTTOM FRAME //top.newWin.frames['bottomCalFrame'].document.open(); //top.newWin.frames['bottomCalFrame'].document.write(calDocBottom); //top.newWin.frames['bottomCalFrame'].document.close(); // for browsers that cannot use framesets top.newWin.document.open(); top.newWin.document.write(calDocTop, calDocBottom); top.newWin.document.close(); } // SET THE CALENDAR TO TODAY'S DATE AND DISPLAY THE NEW CALENDAR function setToday() { // SET GLOBAL DATE TO TODAY'S DATE calDate = new Date(); // SET DAY MONTH AND YEAR TO TODAY'S DATE var month = calDate.getMonth(); var year = calDate.getFullYear(); calDay = calDate.getDate(); // SET MONTH IN DROP-DOWN LIST //top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month; // for browsers that cannot use framesets top.newWin.document.calControl.month.selectedIndex = month; // SET YEAR VALUE //top.newWin.frames['topCalFrame'].document.calControl.year.value = year; top.newWin.document.calControl.year.value = year; // DISPLAY THE NEW CALENDAR writeCalendar(); } // SET THE GLOBAL DATE TO THE NEWLY ENTERED YEAR AND REDRAW THE CALENDAR function setYear() { // GET THE NEW YEAR VALUE //var year = top.newWin.frames['topCalFrame'].document.calControl.year.value; // for browsers that cannot use framesets var year = top.newWin.document.calControl.year.value; // IF IT'S A FOUR-DIGIT YEAR THEN CHANGE THE CALENDAR if (isFourDigitYear(year)) { calDate.setFullYear(year); writeCalendar(); } else { // HIGHLIGHT THE YEAR IF THE YEAR IS NOT FOUR DIGITS IN LENGTH //top.newWin.frames['topCalFrame'].document.calControl.year.focus(); //top.newWin.frames['topCalFrame'].document.calControl.year.select(); top.newWin.document.calControl.year.focus(); top.newWin.document.calControl.year.select(); } } // SET THE GLOBAL DATE TO THE SELECTED MONTH AND REDRAW THE CALENDAR function setCurrentMonth() { // GET THE NEWLY SELECTED MONTH AND CHANGE THE CALENDAR ACCORDINGLY //var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex; // for browsers that do not use framesets var month = top.newWin.document.calControl.month.selectedIndex; calDate.setMonth(month); writeCalendar(); } // SET THE GLOBAL DATE TO THE PREVIOUS YEAR AND REDRAW THE CALENDAR function setPreviousYear() { //var year = top.newWin.frames['topCalFrame'].document.calControl.year.value; // for browsers that do not handle framesets var year = top.newWin.document.calControl.year.value; if (isFourDigitYear(year) && year > 1000) { year--; calDate.setFullYear(year); //top.newWin.frames['topCalFrame'].document.calControl.year.value = year; top.newWin.document.calControl.year.value = year; writeCalendar(); } } // SET THE GLOBAL DATE TO THE PREVIOUS MONTH AND REDRAW THE CALENDAR function setPreviousMonth() { //var year = top.newWin.frames['topCalFrame'].document.calControl.year.value; // for browsers that do not handle framesets var year = top.newWin.document.calControl.year.value; if (isFourDigitYear(year)) { //var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex; var month = top.newWin.document.calControl.month.selectedIndex; // IF MONTH IS JANUARY, SET MONTH TO DECEMBER AND DECREMENT THE YEAR if (month == 0) { month = 11; if (year > 1000) { year--; calDate.setFullYear(year); //top.newWin.frames['topCalFrame'].document.calControl.year.value = year; top.newWin.document.calControl.year.value = year; } } else { month--; } calDate.setMonth(month); //top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month; top.newWin.document.calControl.month.selectedIndex = month; writeCalendar(); } } // SET THE GLOBAL DATE TO THE NEXT MONTH AND REDRAW THE CALENDAR function setNextMonth() { //var year = top.newWin.frames['topCalFrame'].document.calControl.year.value; // for browsers that do not handle framesets var year = top.newWin.document.calControl.year.value; if (isFourDigitYear(year)) { //var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex; var month = top.newWin.document.calControl.month.selectedIndex; // IF MONTH IS DECEMBER, SET MONTH TO JANUARY AND INCREMENT THE YEAR if (month == 11) { month = 0; year++; calDate.setFullYear(year); //top.newWin.frames['topCalFrame'].document.calControl.year.value = year; top.newWin.document.calControl.year.value = year; } else { month++; } calDate.setMonth(month); //top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month; top.newWin.document.calControl.month.selectedIndex = month; writeCalendar(); } } // SET THE GLOBAL DATE TO THE NEXT YEAR AND REDRAW THE CALENDAR function setNextYear() { //var year = top.newWin.frames['topCalFrame'].document.calControl.year.value; // for browsers that do not handle framesets var year = top.newWin.document.calControl.year.value; if (isFourDigitYear(year)) { year++; calDate.setFullYear(year); //top.newWin.frames['topCalFrame'].document.calControl.year.value = year; top.newWin.document.calControl.year.value = year; writeCalendar(); } } // GET NUMBER OF DAYS IN MONTH function getDaysInMonth() { var days; var month = calDate.getMonth()+1; var year = calDate.getFullYear(); // RETURN 31 DAYS if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) { days=31; } // RETURN 30 DAYS else if (month==4 || month==6 || month==9 || month==11) { days=30; } // RETURN 29 DAYS else if (month==2) { if (isLeapYear(year)) { days=29; } // RETURN 28 DAYS else { days=28; } } return (days); } // CHECK TO SEE IF YEAR IS A LEAP YEAR function isLeapYear (Year) { if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) { return (true); } else { return (false); } } // ENSURE THAT THE YEAR IS FOUR DIGITS IN LENGTH function isFourDigitYear(year) { if (year.length != 4) { //top.newWin.frames['topCalFrame'].document.calControl.year.value = calDate.getFullYear(); //top.newWin.frames['topCalFrame'].document.calControl.year.select(); //top.newWin.frames['topCalFrame'].document.calControl.year.focus(); // for browsers that cannot use framesets top.newWin.document.calControl.year.value = calDate.getFullYear(); top.newWin.document.calControl.year.select(); top.newWin.document.calControl.year.focus(); } else { return true; } } // BUILD THE MONTH SELECT LIST function getMonthSelect() { // BROWSER LANGUAGE CHECK DONE PREVIOUSLY (navigator.language()) // FIRST TWO CHARACTERS OF LANGUAGE STRING SPECIFIES THE LANGUAGE // (THE LAST THREE OPTIONAL CHARACTERS SPECIFY THE LANGUAGE SUBTYPE) // SET THE NAMES OF THE MONTH TO THE PROPER LANGUAGE (DEFAULT TO ENGLISH) // IF FRENCH if (selectedLanguage == "fr") { monthArray = new Array('Janvier', 'F?vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'D?cembre'); } // IF GERMAN else if (selectedLanguage == "de") { monthArray = new Array('Januar', 'Februar', 'M?rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'); } // IF SPANISH else if (selectedLanguage == "es") { monthArray = new Array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); } // DEFAULT TO ENGLISH else { monthArray = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); } // DETERMINE MONTH TO SET AS DEFAULT var activeMonth = calDate.getMonth(); // START HTML SELECT LIST ELEMENT monthSelect = ""; // RETURN A STRING VALUE WHICH CONTAINS A SELECT LIST OF ALL 12 MONTHS return monthSelect; } // SET DAYS OF THE WEEK DEPENDING ON LANGUAGE function createWeekdayList() { // IF FRENCH if (selectedLanguage == "fr") { weekdayList = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'); weekdayArray = new Array('Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'); } // IF GERMAN else if (selectedLanguage == "de") { weekdayList = new Array('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'); weekdayArray = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'); } // IF SPANISH else if (selectedLanguage == "es") { weekdayList = new Array('Domingo', 'Lunes', 'Martes', 'Mi?rcoles', 'Jueves', 'Viernes', 'S?bado') weekdayArray = new Array('Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'); } else { weekdayList = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); weekdayArray = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); } // START HTML TO HOLD WEEKDAY NAMES IN TABLE FORMAT var weekdays = ""; // LOOP THROUGH WEEKDAY ARRAY for (i in weekdayArray) { weekdays += "" + weekdayArray[i] + ""; } weekdays += ""; // RETURN TABLE ROW OF WEEKDAY ABBREVIATIONS TO DISPLAY ABOVE THE CALENDAR return weekdays; } // PRE-BUILD PORTIONS OF THE CALENDAR (FOR PERFORMANCE REASONS) function buildCalParts() { // GENERATE WEEKDAY HEADERS FOR THE CALENDAR weekdays = createWeekdayList(); // BUILD THE BLANK CELL ROWS blankCell = "   "; // BUILD THE TOP PORTION OF THE CALENDAR PAGE USING CSS TO CONTROL SOME DISPLAY ELEMENTS calendarBegin = // Commented out so browsers that do not use framesets will be able to use this js // "" + // "" + // STYLESHEET DEFINES APPEARANCE OF CALENDAR // "" + // "" + // " Please only click the day on the calendar once.
"; // NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE TABLE OUTLINES PROPERLY if (isNav) { calendarBegin += "
"; } // BUILD WEEKDAY HEADINGS calendarBegin += "" + weekdays + ""; // BUILD THE BOTTOM PORTION OF THE CALENDAR PAGE calendarEnd = ""; // WHETHER OR NOT TO DISPLAY A THICK LINE BELOW THE CALENDAR if (bottomBorder) { calendarEnd += ""; } // added because calendar header was not ended correctly at first calendarEnd += "
"; // NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE BORDERS PROPERLY if (isNav) { calendarEnd += "
"; } // END THE TABLE AND HTML DOCUMENT calendarEnd += //"" + "" + "" + ""; } // REPLACE ALL INSTANCES OF find WITH replace // inString: the string you want to convert // find: the value to search for // replace: the value to substitute // // usage: jsReplace(inString, find, replace); // example: jsReplace("To be or not to be", "be", "ski"); // result: "To ski or not to ski" // function jsReplace(inString, find, replace) { var outString = ""; if (!inString) { return ""; } // REPLACE ALL INSTANCES OF find WITH replace if (inString.indexOf(find) != -1) { // SEPARATE THE STRING INTO AN ARRAY OF STRINGS USING THE VALUE IN find t = inString.split(find); // JOIN ALL ELEMENTS OF THE ARRAY, SEPARATED BY THE VALUE IN replace return (t.join(replace)); } else { return inString; } } // JAVASCRIPT FUNCTION -- DOES NOTHING (USED FOR THE HREF IN THE CALENDAR CALL) function doNothing() { } // ENSURE THAT VALUE IS TWO DIGITS IN LENGTH function makeTwoDigit(inValue) { var numVal = parseInt(inValue, 10); // VALUE IS LESS THAN TWO DIGITS IN LENGTH if (numVal < 10) { // ADD A LEADING ZERO TO THE VALUE AND RETURN IT return("0" + numVal); } else { return numVal; } } // SET FIELD VALUE TO THE DATE SELECTED AND CLOSE THE CALENDAR WINDOW function returnDate(inDay) { // inDay = THE DAY THE USER CLICKED ON calDate.setDate(inDay); // SET THE DATE RETURNED TO THE USER var day = calDate.getDate(); var month = calDate.getMonth()+1; var year = calDate.getFullYear(); var monthString = monthArray[calDate.getMonth()]; var monthAbbrev = monthString.substring(0,3); var weekday = weekdayList[calDate.getDay()]; var weekdayAbbrev = weekday.substring(0,3); outDate = calDateFormat; // RETURN TWO DIGIT DAY if (calDateFormat.indexOf("DD") != -1) { day = makeTwoDigit(day); outDate = jsReplace(outDate, "DD", day); } // RETURN ONE OR TWO DIGIT DAY else if (calDateFormat.indexOf("dd") != -1) { outDate = jsReplace(outDate, "dd", day); } // RETURN TWO DIGIT MONTH if (calDateFormat.indexOf("MM") != -1) { month = makeTwoDigit(month); outDate = jsReplace(outDate, "MM", month); } // RETURN ONE OR TWO DIGIT MONTH else if (calDateFormat.indexOf("mm") != -1) { outDate = jsReplace(outDate, "mm", month); } // RETURN FOUR-DIGIT YEAR if (calDateFormat.indexOf("yyyy") != -1) { outDate = jsReplace(outDate, "yyyy", year); } // RETURN TWO-DIGIT YEAR else if (calDateFormat.indexOf("yy") != -1) { var yearString = "" + year; var yearString = yearString.substring(2,4); outDate = jsReplace(outDate, "yy", yearString); } // RETURN FOUR-DIGIT YEAR else if (calDateFormat.indexOf("YY") != -1) { outDate = jsReplace(outDate, "YY", year); } // RETURN DAY OF MONTH (Initial Caps) if (calDateFormat.indexOf("Month") != -1) { outDate = jsReplace(outDate, "Month", monthString); } // RETURN DAY OF MONTH (lowercase letters) else if (calDateFormat.indexOf("month") != -1) { outDate = jsReplace(outDate, "month", monthString.toLowerCase()); } // RETURN DAY OF MONTH (UPPERCASE LETTERS) else if (calDateFormat.indexOf("MONTH") != -1) { outDate = jsReplace(outDate, "MONTH", monthString.toUpperCase()); } // RETURN DAY OF MONTH 3-DAY ABBREVIATION (Initial Caps) if (calDateFormat.indexOf("Mon") != -1) { outDate = jsReplace(outDate, "Mon", monthAbbrev); } // RETURN DAY OF MONTH 3-DAY ABBREVIATION (lowercase letters) else if (calDateFormat.indexOf("mon") != -1) { outDate = jsReplace(outDate, "mon", monthAbbrev.toLowerCase()); } // RETURN DAY OF MONTH 3-DAY ABBREVIATION (UPPERCASE LETTERS) else if (calDateFormat.indexOf("MON") != -1) { outDate = jsReplace(outDate, "MON", monthAbbrev.toUpperCase()); } // RETURN WEEKDAY (Initial Caps) if (calDateFormat.indexOf("Weekday") != -1) { outDate = jsReplace(outDate, "Weekday", weekday); } // RETURN WEEKDAY (lowercase letters) else if (calDateFormat.indexOf("weekday") != -1) { outDate = jsReplace(outDate, "weekday", weekday.toLowerCase()); } // RETURN WEEKDAY (UPPERCASE LETTERS) else if (calDateFormat.indexOf("WEEKDAY") != -1) { outDate = jsReplace(outDate, "WEEKDAY", weekday.toUpperCase()); } // RETURN WEEKDAY 3-DAY ABBREVIATION (Initial Caps) if (calDateFormat.indexOf("Wkdy") != -1) { outDate = jsReplace(outDate, "Wkdy", weekdayAbbrev); } // RETURN WEEKDAY 3-DAY ABBREVIATION (lowercase letters) else if (calDateFormat.indexOf("wkdy") != -1) { outDate = jsReplace(outDate, "wkdy", weekdayAbbrev.toLowerCase()); } // RETURN WEEKDAY 3-DAY ABBREVIATION (UPPERCASE LETTERS) else if (calDateFormat.indexOf("WKDY") != -1) { outDate = jsReplace(outDate, "WKDY", weekdayAbbrev.toUpperCase()); } // SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR calDateField.value = outDate; // GIVE FOCUS BACK TO THE DATE FIELD calDateField.focus(); // CLOSE THE CALENDAR WINDOW top.newWin.close() }