/* automatically generated from calendar.js, do not edit ! */ @"var monthArray = getMonthSelect();\n" @"var calDateField;\n" @"var calDate;\n" @"// innerHTML IS ONLY SUPPORTED BY MSIE...\n" @"function rewriteLayerWithData(obj,data) {\n" @" if (isNav) {\n" @" obj.document.clear();\n" @" obj.document.write(data);\n" @" obj.document.close();\n" @" }\n" @" if (isIE) {\n" @" obj.innerHTML = data;\n" @" }\n" @" if (usesNavImages) {\n" @" document.images['dateFieldFirstImg'].src = dateFieldFirst.src;\n" @" document.images['dateFieldPreviousImg'].src = dateFieldPrevious.src;\n" @" document.images['dateFieldTodayImg'].src = dateFieldToday.src;\n" @" document.images['dateFieldNextImg'].src = dateFieldNext.src;\n" @" document.images['dateFieldLastImg'].src = dateFieldLast.src;\n" @" document.images['dateFieldCloseImg'].src = dateFieldClose.src;\n" @" }\n" @"}\n" @"// DETERMINE BROWSER BRAND\n" @"var isNav = false;\n" @"var isIE = false;\n" @"if (navigator.appName == \"Netscape\") {\n" @" isNav = true;\n" @"}\n" @"else {\n" @" isIE = true;\n" @"}\n" @"// PRE-BUILD PORTIONS OF THE CALENDAR WHEN THIS JS LIBRARY LOADS INTO THE BROWSER\n" @"buildCalParts();\n" @"// CALENDAR FUNCTIONS BEGIN HERE ---------------------------------------------------\n" @"// SET THE INITIAL VALUE OF THE GLOBAL DATE FIELD\n" @"function setDateField(dateField) {\n" @" // ASSIGN THE INCOMING FIELD OBJECT TO A GLOBAL VARIABLE\n" @" calDateField = dateField; \n" @" // GET THE VALUE OF THE INCOMING FIELD\n" @" inDate = dateField.value;\n" @" // SET calDate TO THE DATE IN THE INCOMING FIELD OR DEFAULT TO TODAY'S DATE\n" @" setInitialDate();\n" @"}\n" @"// SET THE INITIAL CALENDAR DATE TO TODAY OR TO THE EXISTING VALUE IN dateField\n" @"function setInitialDate() {\n" @" \n" @" // CREATE A NEW DATE OBJECT (WILL GENERALLY PARSE CORRECT DATE EXCEPT WHEN \".\" IS USED AS A DELIMITER)\n" @" // (THIS ROUTINE DOES *NOT* CATCH ALL DATE FORMATS, IF YOU NEED TO PARSE A CUSTOM DATE FORMAT, DO IT HERE)\n" @" // ADD CUSTOM DATE PARSING HERE\n" @" ypos = dateFormat.indexOf('%Y');\n" @" inYear = parseInt(inDate.substr(ypos,4));\n" @" mpos = dateFormat.indexOf('%m');\n" @" if (ypos < mpos) mpos+=2; // because %Y stands for yyyy, add 2\n" @" inMonth = inDate.substr(mpos,2);\n" @" if (inMonth.charAt(0) == \"0\") \n" @" inMonth = inMonth.substr(1,inMonth.length-1);\n" @" inMonth = parseInt(inMonth);\n" @" \n" @" dpos = dateFormat.indexOf('%d');\n" @" if (ypos < dpos) dpos+=2; // same as mpos\n" @" inDay = inDate.substr(dpos,2);\n" @" if (inDay.charAt(0) == \"0\") \n" @" inDay = inDay.substr(1,inDay.length-1);\n" @" inDay = parseInt(inDay);\n" @" if ((inYear) && (inMonth) && (inDay)) {\n" @" calDate = new Date(inYear,inMonth-1,inDay);\n" @" }\n" @" else {\n" @" calDate = new Date();\n" @" }\n" @" // KEEP TRACK OF THE CURRENT DAY VALUE\n" @" calDay = calDate.getDate();\n" @" // SET DAY VALUE TO 1... TO AVOID JAVASCRIPT DATE CALCULATION ANOMALIES\n" @" // (IF THE MONTH CHANGES TO FEB AND THE DAY IS 30, THE MONTH WOULD CHANGE TO MARCH\n" @" // AND THE DAY WOULD CHANGE TO 2. SETTING THE DAY TO 1 WILL PREVENT THAT)\n" @" calDate.setDate(1);\n" @"}\n" @"// ENABLE MULTIPLE CALENDAR-USING OBJECTS BY USING VARIABLE calendarDiv;\n" @"var calendarDiv = false;\n" @"function toggleCalendar(dateFieldEl,calObj,calFormat) {\n" @" if ((calendarDiv) && (calendarDiv.id != calObj.id)) {\n" @" hideCalendar();\n" @" }\n" @" calendarDiv = calObj;\n" @" \n" @" if (isNav) condition = (calendarDiv.visibility == 'show');\n" @" if (isIE) condition = (calendarDiv.style.visibility == 'visible');\n" @" if (condition) {\n" @" hideCalendar();\n" @" }\n" @" else {\n" @" var i,j;\n" @" var dateField;\n" @" for (i = 0; i < document.forms.length; i++) {\n" @" for (j = 0; j < document.forms[i].elements.length; j++) {\n" @" if (document.forms[i].elements[j].name == dateFieldEl) {\n" @" dateField = document.forms[i].elements[j];\n" @" }\n" @" }\n" @" }\n" @" dateFormat = calFormat;\n" @" showCalendar(dateField);\n" @" }\n" @"}\n" @"// CAPTURE onMouseMove EVENT IF NETSCAPE FOR POSITIONING calendarDiv\n" @"if (isNav) {\n" @" document.captureEvents( Event.MOUSEMOVE );\n" @" document.onmousemove = actPos;\n" @"}\n" @"var curScreenPosX;\n" @"var curScreenPosY;\n" @"function actPos(e) {\n" @" \n" @" curScreenPosX = e.pageX + 10;\n" @" curScreenPosY = e.pageY;\n" @" return true;\n" @"}\n" @"function showCalendar(dateField) {\n" @" // SET INITIAL VALUE OF THE DATE FIELD AND CREATE TOP AND BOTTOM FRAMES\n" @" setDateField(dateField);\n" @" writeCalendar();\n" @" if (isNav) {\n" @" calendarDiv.visibility = 'show';\n" @" calendarDiv.left = curScreenPosX;\n" @" calendarDiv.top = curScreenPosY;\n" @" }\n" @" if (isIE) {\n" @" calendarDiv.style.visibility = 'visible';\n" @" }\n" @" return true;\n" @"}\n" @"function hideCalendar() {\n" @" if (isNav) {\n" @" calendarDiv.visibility = 'hide';\n" @" }\n" @" if (isIE) {\n" @" calendarDiv.style.visibility = 'hidden';\n" @" }\n" @" calendarDiv = false;\n" @"}\n" @"// NEW: NO FRAMES ANYMORE, ONE
INSTEAD\n" @"function writeCalendar() {\n" @" data = buildTopCalFrame() + buildBottomCalFrame();\n" @" if (isNav) rewriteLayerWithData(calendarDiv, data);\n" @" if (isIE) rewriteLayerWithData(calendarDiv, data);\n" @"}\n" @"// CREATE month/year DISPLAY\n" @"function buildCalControlMonthYear() {\n" @" month = calDate.getMonth();\n" @" year = calDate.getFullYear();\n" @" return String(monthArray[month])+\" \"+String(year);\n" @"}\n" @"var obj=false;\n" @"var X,Y;\n" @"function MD() {\n" @" if (isIE) {\n" @" ob = true;\n" @" X=event.offsetX;\n" @" Y=event.offsetY;\n" @" document.onmousemove = MM;\n" @" document.onmouseup = MU;\n" @" }\n" @"}\n" @"function MM() {\n" @" if (ob) {\n" @" calendarDiv.style.pixelLeft = event.clientX-X + document.body.scrollLeft;\n" @" calendarDiv.style.pixelTop = event.clientY-Y + document.body.scrollTop;\n" @" return false;\n" @" }\n" @"}\n" @"function MU() {\n" @" ob = false;\n" @"// document.onmousemove = null;\n" @"// document.onmouseup = null;\n" @"}\n" @"// CREATE THE TOP CALENDAR PART\n" @"function buildTopCalFrame() {\n" @" var calDoc =\n" @" \"
\" +\n" @" \"\" +\n" @" \"\" +\n" @" \"\" +\n" @" \"\" +\n" @" \"\" +\n" @" \"\";\n" @" return calDoc;\n" @"}\n" @"// CREATE THE BOTTOM CALENDAR PART\n" @"function buildBottomCalFrame() { \n" @" // START CALENDAR DOCUMENT\n" @" var calDoc = calendarBegin;\n" @" // GET MONTH, AND YEAR FROM GLOBAL CALENDAR DATE\n" @" month = calDate.getMonth();\n" @" year = calDate.getFullYear();\n" @" // GET GLOBALLY-TRACKED DAY VALUE (PREVENTS JAVASCRIPT DATE ANOMALIES)\n" @" day = calDay;\n" @" var i = 0;\n" @" // DETERMINE THE NUMBER OF DAYS IN THE CURRENT MONTH\n" @" var days = getDaysInMonth();\n" @" // IF GLOBAL DAY VALUE IS > THAN DAYS IN MONTH, HIGHLIGHT LAST DAY IN MONTH\n" @" if (day > days) {\n" @" day = days;\n" @" }\n" @" // DETERMINE WHAT DAY OF THE WEEK THE CALENDAR STARTS ON\n" @" var firstOfMonth = new Date (year, month, 1);\n" @" // GET THE DAY OF THE WEEK THE FIRST DAY OF THE MONTH FALLS ON\n" @" var startingPos = firstOfMonth.getDay();\n" @" days += startingPos;\n" @" // KEEP TRACK OF THE COLUMNS, START A NEW ROW AFTER EVERY 7 COLUMNS\n" @" var columnCount = 0;\n" @" // MAKE BEGINNING NON-DATE CELLS BLANK\n" @" for (i = 0; i < startingPos; i++) {\n" @" calDoc += blankCell;\n" @" columnCount++;\n" @" }\n" @" // SET VALUES FOR DAYS OF THE MONTH\n" @" var currentDay = 0;\n" @" var dayType = \"weekday\";\n" @" // DATE CELLS CONTAIN A NUMBER\n" @" for (i = startingPos; i < days; i++) {\n" @" var paddingChar = \" \";\n" @" // ADJUST SPACING SO THAT ALL LINKS HAVE RELATIVELY EQUAL WIDTHS\n" @" if (i-startingPos+1 < 10) {\n" @" padding = \"  \";\n" @" }\n" @" else {\n" @" padding = \" \";\n" @" }\n" @" // GET THE DAY CURRENTLY BEING WRITTEN\n" @" currentDay = i-startingPos+1;\n" @" // SET THE TYPE OF DAY, THE focusDay GENERALLY APPEARS AS A DIFFERENT COLOR\n" @" if (currentDay == day) {\n" @" dayType = \"focusDay\";\n" @" }\n" @" else {\n" @" dayType = \"weekDay\";\n" @" }\n" @" // ADD THE DAY TO THE CALENDAR STRING\n" @" calDoc += \"\";\n" @" columnCount++;\n" @" // START A NEW ROW WHEN NECESSARY\n" @" if (columnCount % 7 == 0) {\n" @" calDoc += \"\";\n" @" }\n" @" }\n" @" // MAKE REMAINING NON-DATE CELLS BLANK\n" @" for (i=days; i<42; i++) {\n" @" calDoc += blankCell;\n" @" columnCount++;\n" @" // START A NEW ROW WHEN NECESSARY\n" @" if (columnCount % 7 == 0) {\n" @" calDoc += \"\";\n" @" if (i<41) {\n" @" calDoc += \"\";\n" @" }\n" @" }\n" @" }\n" @" // FINISH THE NEW CALENDAR PAGE\n" @" calDoc += calendarEnd;\n" @" // RETURN THE COMPLETED CALENDAR PAGE\n" @" return calDoc;\n" @"}\n" @"// SET THE CALENDAR TO TODAY'S DATE AND DISPLAY THE NEW CALENDAR\n" @"function setToday() {\n" @" // SET GLOBAL DATE TO TODAY'S DATE\n" @" calDate = new Date();\n" @" // DISPLAY THE NEW CALENDAR\n" @" writeCalendar();\n" @"}\n" @"// SET THE GLOBAL DATE TO THE PREVIOUS YEAR AND REDRAW THE CALENDAR\n" @"function setPreviousYear() {\n" @" var year = calDate.getFullYear();\n" @" if (year > 1000) {\n" @" year--;\n" @" calDate.setFullYear(year);\n" @" writeCalendar();\n" @" }\n" @"}\n" @"// SET THE GLOBAL DATE TO THE PREVIOUS MONTH AND REDRAW THE CALENDAR\n" @"function setPreviousMonth() {\n" @" var year = calDate.getFullYear();\n" @" var month = calDate.getMonth();\n" @" \n" @" // IF MONTH IS JANUARY, SET MONTH TO DECEMBER AND DECREMENT THE YEAR\n" @" if (month == 0) {\n" @" month = 11;\n" @" if (year > 1000) {\n" @" year--;\n" @" calDate.setFullYear(year);\n" @" }\n" @" }\n" @" else {\n" @" month--;\n" @" }\n" @" calDate.setMonth(month);\n" @" writeCalendar();\n" @"}\n" @"// SET THE GLOBAL DATE TO THE NEXT MONTH AND REDRAW THE CALENDAR\n" @"function setNextMonth() {\n" @" var year = calDate.getFullYear();\n" @" var month = calDate.getMonth();\n" @" // IF MONTH IS DECEMBER, SET MONTH TO JANUARY AND INCREMENT THE YEAR\n" @" if (month == 11) {\n" @" month = 0;\n" @" year++;\n" @" calDate.setFullYear(year);\n" @" }\n" @" else {\n" @" month++;\n" @" }\n" @" calDate.setMonth(month);\n" @" writeCalendar();\n" @"}\n" @"// SET THE GLOBAL DATE TO THE NEXT YEAR AND REDRAW THE CALENDAR\n" @"function setNextYear() {\n" @" var year = calDate.getFullYear();\n" @" year++;\n" @" calDate.setFullYear(year);\n" @" writeCalendar();\n" @"}\n" @"// GET NUMBER OF DAYS IN MONTH\n" @"function getDaysInMonth() {\n" @" var days;\n" @" var month = calDate.getMonth()+1;\n" @" var year = calDate.getFullYear();\n" @" // RETURN 31 DAYS\n" @" if (month==1 || month==3 || month==5 || month==7 || month==8 ||\n" @" month==10 || month==12) {\n" @" days=31;\n" @" }\n" @" // RETURN 30 DAYS\n" @" else if (month==4 || month==6 || month==9 || month==11) {\n" @" days=30;\n" @" }\n" @" // RETURN 29 DAYS\n" @" else if (month==2) {\n" @" if (isLeapYear(year)) {\n" @" days=29;\n" @" }\n" @" // RETURN 28 DAYS\n" @" else {\n" @" days=28;\n" @" }\n" @" }\n" @" return (days);\n" @"}\n" @"// CHECK TO SEE IF YEAR IS A LEAP YEAR\n" @"function isLeapYear (Year) {\n" @" if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {\n" @" return (true);\n" @" }\n" @" else {\n" @" return (false);\n" @" }\n" @"}\n" @"// BUILD THE MONTH SELECT LIST\n" @"function getMonthSelect() {\n" @" // IF SET BY A PARAMETER (WRITTEN AT THE BEGINNING BY WOCalendar)\n" @" if (externMonths) {\n" @" monthArray = externMonths;\n" @" }\n" @" else {\n" @" monthArray = new Array('January', 'February', 'March', 'April', \n" @" 'May', 'June', 'July', 'August', \n" @" 'September', 'October', 'November', 'December');\n" @" }\n" @" return monthArray;\n" @"}\n" @"// SET DAYS OF THE WEEK DEPENDING ON LANGUAGE\n" @"function createWeekdayList() {\n" @" // IF SET BY A PARAMETER (WRITTEN AT THE BEGINNING BY WODateFieldScript)\n" @" if (externWeekdays) {\n" @" weekdayArray = externWeekdays;\n" @" }\n" @" else {\n" @" weekdayArray = new Array('Su','Mo','Tu','We','Th','Fr','Sa');\n" @" }\n" @" var weekdays = \"\";\n" @" for (i in weekdayArray) {\n" @" weekdays += \"\";\n" @" }\n" @" weekdays += \"\";\n" @" return weekdays;\n" @"}\n" @"// PRE-BUILD PORTIONS OF THE CALENDAR (FOR PERFORMANCE REASONS)\n" @"function buildCalParts() {\n" @" // BUILD THE BLANK CELL ROWS\n" @" blankCell = \"\";\n" @" // BUILD THE TOP PORTION OF THE CALENDAR PAGE USING CSS TO CONTROL SOME DISPLAY ELEMENTS\n" @" calendarBegin = createWeekdayList() + \"\";\n" @" // BUILD THE BOTTOM PORTION OF THE CALENDAR PAGE\n" @" calendarEnd = \"\";\n" @" // END THE TABLE AND HTML DOCUMENT\n" @" calendarEnd +=\n" @" \"
\" +\n" @" buildCalControlMonthYear() +\n" @" \"\"+\n" @" \"\" +\n" @" dateFieldCloseSRC+\" 
\"+\n" @" \"\"+\n" @" dateFieldFirstSRC+\"\" +\n" @" \" \"+\n" @" dateFieldPreviousSRC+\"\" +\n" @" \" \"+\n" @" dateFieldTodaySRC+\"\" +\n" @" \" \"+\n" @" dateFieldNextSRC+\"\"+\n" @" \" \"+\n" @" dateFieldLastSRC+\"\" +\n" @" \"
\" +\n" @" \"\" + padding + currentDay + paddingChar + \"
\"\n" @" + weekdayArray[i] + \"
   
\";\n" @"}\n" @"// REPLACE ALL INSTANCES OF find WITH replace\n" @"// inString: the string you want to convert\n" @"// find: the value to search for\n" @"// replace: the value to substitute\n" @"//\n" @"// usage: jsReplace(inString, find, replace);\n" @"// example: jsReplace(\"To be or not to be\", \"be\", \"ski\");\n" @"// result: \"To ski or not to ski\"\n" @"//\n" @"function jsReplace(inString, find, replace) {\n" @" var outString = \"\";\n" @" if (!inString) {\n" @" return \"\";\n" @" }\n" @" // REPLACE ALL INSTANCES OF find WITH replace\n" @" if (inString.indexOf(find) != -1) {\n" @" // SEPARATE THE STRING INTO AN ARRAY OF STRINGS USING THE VALUE IN find\n" @" t = inString.split(find);\n" @" // JOIN ALL ELEMENTS OF THE ARRAY, SEPARATED BY THE VALUE IN replace\n" @" return (t.join(replace));\n" @" }\n" @" else {\n" @" return inString;\n" @" }\n" @"}\n" @"// JAVASCRIPT FUNCTION -- DOES NOTHING (USED FOR THE HREF IN THE CALENDAR CALL)\n" @"function doNothing() {\n" @"}\n" @"// ENSURE THAT VALUE IS TWO DIGITS IN LENGTH\n" @"function makeTwoDigit(inValue) {\n" @" var numVal = parseInt(inValue, 10);\n" @" // VALUE IS LESS THAN TWO DIGITS IN LENGTH\n" @" if (numVal < 10) {\n" @" // ADD A LEADING ZERO TO THE VALUE AND RETURN IT\n" @" return(\"0\" + numVal);\n" @" }\n" @" else {\n" @" return numVal;\n" @" }\n" @"}\n" @"// SET FIELD VALUE TO THE DATE SELECTED AND CLOSE THE CALENDAR WINDOW\n" @"function returnDate(inDay)\n" @"{\n" @" // inDay = THE DAY THE USER CLICKED ON\n" @" calDate.setDate(inDay);\n" @" // SET THE DATE RETURNED TO THE USER\n" @" var day = calDate.getDate();\n" @" var month = calDate.getMonth()+1;\n" @" var year = calDate.getFullYear();\n" @" outDate = dateFormat;\n" @" outDate = jsReplace(outDate,'%Y',String(year));\n" @" outDate = jsReplace(outDate,'%m',makeTwoDigit(month));\n" @" outDate = jsReplace(outDate,'%d',makeTwoDigit(day));\n" @" // SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR\n" @" calDateField.value = outDate;\n" @" // CLOSE THE CALENDAR WINDOW\n" @" hideCalendar();\n" @"}\n"