//Global Variables //User defined Variables *** The values may be changed on the variables below var DATE_FORMAT = "dd-mmm-yyyy"; //Date format returnvalue (use lowercase) var PREV_COLOR = "#000000"; //Color - color the previous arrow var NEXT_COLOR = "#000000"; //Color - color for the next arrow var CLEAR_COLOR = "#000000"; //Color - color for the Clear button text var CANCEL_COLOR = "#000000"; //Color - color for the Cancel button text var MONTH_BGCOLOR = "#CCCCCC"; //Background Color - color for the Month heading var WEEK_BGCOLOR = "#CCCCCC"; //Background Color - color for the Weekday headings var DAY_BGCOLOR = "#E2E2E2"; //Background Color - color for the Days var CUR_DAY_BGCOLOR = "#AE9291"; //Background Color - color for the Current Day var PNI_MOCOLOR = "#E2E2E2"; //Background Rollover Color - color to change the button background when the mouse rolls over var DAY_MOCOLOR = "#CCCCCC"; //Background Rollover Color - color to change the Days background when the mouse rolls over var HDR_FNT_COLOR = "#000000"; //Font Color - color for the Month and Weekday headings font var DAY_FNT_COLOR = "#000000"; //Font Color - color for the Days font var CAL_BOR_COLOR = "#000000"; //Border Color - color for the border around the calendar var WEEK_BOR_COLOR = "#C0C0C0"; //Border Color - color for the border around the Weekday headings var DAY_BOR_COLOR = "#CCCCCC"; //Border Color - color for the border around the Days var MONTHS_LONG =["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; var MONTHS_SHORT =["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; var SETMULTIPLE = 0; var iStartYear = 1900;tartYear = 1900; var iEndYear = 2100; //End User variable definitions. //Define the different browser types that are supported var NS4 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4); var NS6 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==5); var IE4 = document.all; //Calendar objects var calNS4; var calNS6; var calIE4; //Holding Variables var CALENDAR_HTML = ""; var DISPLAY_DATE = ""; var CURRENT_DATE_FIELD = ""; var HLD_DIV = ""; var BUILT = "no"; //End of Global Variables //Write out the style sheets document.write(""); //This function is used to display the calendar function showCalendar(field,date,xPos,yPos, multiple) { if(!multiple) { SETMULTIPLE=false } else { SETMULTIPLE=multiple } if (HLD_DIV != date && BUILT == "yes") { if (NS4) calNS4.visibility = 'hidden'; else if (IE4) calIE4.style.visibility = 'hidden'; else if (NS6) calNS6.style.visibility = 'hidden'; BUILT = "no"; HLD_DIV = date; } //Set the Date field to use CURRENT_DATE_FIELD = field; //Set the Display Date to null DISPLAY_DATE = ""; //Build the Calendar buildCalendar(); if (!xPos) xPos = ""; if (!yPos) yPos = ""; //Display the Calendar on the Web page if (NS4) { calNS4 = new Layer(50,this); calNS4.document.write(CALENDAR_HTML); calNS4.document.close(); if (xPos != "" || yPos != "") { this.calNS4.pageX = xPos; this.calNS4.pageY = (yPos - 95); } else { this.calNS4.pageX = document.layers[date].pageX; this.calNS4.pageY = (document.layers[date].pageY - 95); } calNS4.visibility = 'visible'; } else if (IE4) { calIE4 = document.all[date]; calIE4.innerHTML = CALENDAR_HTML; if (xPos != "" || yPos != "") { calIE4.style.posLeft = xPos; calIE4.style.posTop = yPos; } calIE4.style.visibility = 'visible'; } else if (NS6) { calNS6 = document.getElementById(date); calNS6.innerHTML = CALENDAR_HTML; if (xPos != "" || yPos != "") { calNS6.style.top = yPos; calNS6.style.left = xPos; } calNS6.style.visibility = 'visible'; } BUILT = "yes"; } //This function is used to hide the calendar function hideCalendar() { if (BUILT == "no") return; if (NS4) { calNS4.visibility = 'hidden'; calNS4.document.write(""); calNS4.document.close(); } else if (IE4) { calIE4.style.visibility = 'hidden'; calIE4.innerHTML = ""; } else if (NS6) { calNS6.style.visibility = 'hidden'; calNS6.innerHTML = ""; } } //This function is used to change the Calendar Date function chgCalendarDate(dspDate) { //Set the Display to the new Date DISPLAY_DATE = dspDate; //Build the Calendar buildCalendar(); //Display the Calendar on the Web page if (NS4) { calNS4.document.write(CALENDAR_HTML); calNS4.document.close(); } else if (IE4) calIE4.innerHTML = CALENDAR_HTML; else if (NS6) calNS6.innerHTML = CALENDAR_HTML; } //This function is used to change the Date field to the selected calendar date function chgDate(txtDay, txtMonth, txtYear) { //alert(txtMonth); //alert(txtYear); strDate = DATE_FORMAT; txtDay2 = "0" + txtDay strDate = strDate.replace("dd", txtDay.substr(-2,2)); strDate = strDate.replace("d", txtDay); strDate = strDate.replace("mmmm", MONTHS_LONG[txtMonth-1]); strDate = strDate.replace("mmm", MONTHS_SHORT[txtMonth-1]); strDate = strDate.replace("mm", txtMonth); strDate = strDate.replace("yyyy", txtYear); strDate = strDate.replace("yy", txtYear.substr(-2,2)); //Change the Date field if(SETMULTIPLE) { if(document.forms[0][CURRENT_DATE_FIELD].value!="") document.forms[0][CURRENT_DATE_FIELD].value += "\n" document.forms[0][CURRENT_DATE_FIELD].value += strDate } else document.forms[0][CURRENT_DATE_FIELD].value = strDate //Hide the Calendar hideCalendar(); } //This function is used to Build the Calendar function buildCalendar() { //Define the Month Names and Month Days Array monthNames = new Array("January","Februrary","March","April","May","June","July","August","September","October","November","December"); monthDays = new Array(12); //Entry the Total Days for each Month monthDays[0] = 31; monthDays[1] = 28; monthDays[2] = 31; monthDays[3] = 30; monthDays[4] = 31; monthDays[5] = 30; monthDays[6] = 31; monthDays[7] = 31; monthDays[8] = 30; monthDays[9] = 31; monthDays[10] = 30; monthDays[11] = 31; //Determine the Date for the Calendar to Display if (DISPLAY_DATE == "") calendarDateObj = new Date(); else calendarDateObj = new Date(DISPLAY_DATE); //Obtain the Calendar Dates calendarDate = calendarDateObj.getDate(); calendarDay = calendarDateObj.getDay(); calendarMonth = calendarDateObj.getMonth(); calendarYear = calendarDateObj.getYear(); //Obtain Todays Dates currentDateObj = new Date(); currentDate = currentDateObj.getDate(); currentDay = currentDateObj.getDay(); currentMonth = currentDateObj.getMonth(); //Make sure the Year is in the correct century //calendarYear = calendarYear % 100; //calendarYear = ((calendarYear < 20) ? (2000 + calendarYear) : (1900 + calendarYear)); //Calculate the Blank entries before the 1st of the month blankEntry = calendarDate; while (blankEntry > 7) blankEntry-= 7; blankEntry = calendarDay - blankEntry + 1; if (blankEntry < 0) blankEntry+= 7; //Calculate Next Months Date nextMonth = (calendarMonth + 2); if (nextMonth == 13) { nextMonth = 1; nextYear = (calendarYear + 1); } else nextYear = calendarYear; nextDate = nextMonth + "/" + currentDate + "/" + nextYear; //Calculate Previous Months Date prevMonth = calendarMonth; if (prevMonth == 0) { prevMonth = 12; prevYear = (calendarYear - 1); } else prevYear = calendarYear; prevDate = prevMonth + "/" + currentDate + "/" + prevYear; //Build the Header for the Calendar CALENDAR_HTML = ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; //Build a blank cell for each Blank Entry before the 1st of the Month for (s = 0;s < blankEntry;s++) CALENDAR_HTML += ""; //Start the Day Counter dayCount = 1; //Loop through until the total days of calendar month have been reached while (dayCount <= monthDays[calendarMonth]) { //Start a new table row each time through the loop except the first time if (dayCount > 1) CALENDAR_HTML += ""; //Start at the next cell after the blank entries and entry the cells across the row. for (b = blankEntry;b < 7;b++) { //If the Day Counter is greater than the Month total then add blank entries if (dayCount <= monthDays[calendarMonth]) { tdProperties = "onClick=\"chgDate('" + dayCount +"', '" + (calendarMonth + 1) + "', '" + calendarYear + "') \""; tdData = "" + dayCount + ""; //If the current day is equal to the calendar day and the //current month is equal to the calendar month, check the dates if ((currentDay == calendarDay) && (currentMonth == calendarMonth)) { //If the day counter is equal to the current date then change the color if (dayCount == currentDate) tdProperties = tdProperties + "bgcolor=" + CUR_DAY_BGCOLOR + ""; else tdProperties = tdProperties + "onMouseOver=mOvr(this,'" + DAY_MOCOLOR + "') onMouseOut=mOut(this,'" + DAY_BGCOLOR + "') bgcolor=" + DAY_BGCOLOR + ""; } else tdProperties = tdProperties + "onMouseOver=mOvr(this,'" + DAY_MOCOLOR + "') onMouseOut=mOut(this,'" + DAY_BGCOLOR + "') bgcolor=" + DAY_BGCOLOR + ""; } else { tdProperties = "bgcolor=" + DAY_BGCOLOR; tdData = " "; } //Build the table cells CALENDAR_HTML += ""; //Add to the Day counter dayCount++; } //End the table row CALENDAR_HTML += ""; //Set the Blank entries to zero blankEntry=0; } //End the table CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += ""; CALENDAR_HTML += "
"; CALENDAR_HTML += "
3" + monthNames[calendarMonth] + " " + calendarYear + "4
SUNMONTUEWEDTHRFRISAT
 
" + tdData + "
 
"; CALENDAR_HTML += ""; CALENDAR_HTML += "Cancel" CALENDAR_HTML += " "; CALENDAR_HTML += ""; CALENDAR_HTML += (SETMULTIPLE)?"Clear Last":"Clear" CALENDAR_HTML += "
"; } //This function is used to control the mouse over event. function mOvr(src,clrOver) { if (!src.contains(event.fromElement)) { src.style.cursor = 'hand'; src.bgColor = clrOver; } } //This function is used to control the mouse out event. function mOut(src,clrIn) { if (!src.contains(event.toElement)) { src.style.cursor = 'default'; src.bgColor = clrIn; } } function clear() { if(SETMULTIPLE) //Multivalue { var strValue="" var dates=document.forms[0][CURRENT_DATE_FIELD].value.split("\n"); for(i=0;i<(dates.length-1);i++) { strValue += (strValue=="")?"":"\n"; strValue += dates[i].replace("\n","").replace("\r",""); } document.forms[0][CURRENT_DATE_FIELD].value = strValue; } else //SingleValue { document.forms[0][CURRENT_DATE_FIELD].value = "" } //Hide the Calendar hideCalendar(); } function cancel() { //Hide the Calendar hideCalendar(); } function changeYear(iMonth, iDay, cmbYear) { iYear = cmbYear.options[cmbYear.selectedIndex].value; goToDate = iMonth + "/" + iDay + "/" + iYear; chgCalendarDate(goToDate) }