//Niketa Mahana 07-Sept-2006 For SBS/AVATS var fixedX = -1; // x position (-1 if to appear below control) var fixedY = -1; // y position (-1 if to appear below control) var startAt = 0; // 0 - sunday ; 1 - monday var showWeekNumber = 0; // 0 - don't show; 1 - show var showToday = 1; // 0 - don't show; 1 - show var imgDir = "images/"; // directory for images ... e.g. var imgDir="/img/" var gotoString = "Go To Current Month"; var todayString = "Today is"; var weekString = "Wk"; var scrollLeftMessage = "Click to scroll to previous month. Hold mouse button to scroll automatically."; var scrollRightMessage = "Click to scroll to next month. Hold mouse button to scroll automatically."; var selectMonthMessage = "Click to select a month."; var selectYearMessage = "Click to select a year."; var selectDateMessage = "Select [date] as date."; // do not replace [date], it will be replaced by date. var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed, yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear; var bPageLoaded = false; var ie = ("ActiveXObject" in window); var dom = document.getElementById; var today = new Date(); var dateNow = today.getDate(); var monthNow = today.getMonth(); var yearNow = today.getYear(); var imgsrc = new Array("drop1.gif", "drop2.gif"); var img = new Array(); var submitmode=false; var bShow = false; /* hides and objects (for IE only) */ function showElement(elmID) { if( ie ) { for(var i = 0; i < document.all.tags( elmID ).length; i++) { obj = document.all.tags( elmID )[i]; if( !obj || !obj.offsetParent ) { continue; } obj.style.visibility = ""; } } } function HolidayRec (d, m, y, desc) { this.d = d; this.m = m; this.y = y; this.desc = desc; } var HolidaysCounter = 0; var Holidays = new Array(); function addHoliday (d, m, y, desc) { Holidays[HolidaysCounter++] = new HolidayRec(d, m, y, desc); } if (dom) { for (i=0;i"); if (showToday==1) { document.write(""); } document.write ("
Close the Calendar
"); } var monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var monthName2 = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); if (startAt==0) { dayName = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); } else { dayName = new Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); } function swapImage(srcImg, destImg){ if (ie) { document.getElementById(srcImg).setAttribute("src", imgDir + destImg); } } function init() { //some browsers has incorect date if (yearNow < 1000) { yearNow += 1900; } crossobj=document.getElementById("calendar").style; hideCalendar(); crossMonthObj=document.getElementById("selectMonth").style; crossYearObj=document.getElementById("selectYear").style; monthConstructed=false; yearConstructed=false; if (showToday==1) { document.getElementById("lblToday").innerHTML = todayString + " " + dayName[(today.getDay() - startAt == -1) ? 6 : (today.getDay() - startAt)] + ", " + dateNow + " " + monthName[monthNow].substring(0, 3) + " " + yearNow + ""; } sHTML1 = "   "; sHTML1 += "   "; sHTML1 += " "; sHTML1 += " "; document.getElementById("caption").innerHTML = sHTML1; bPageLoaded = true; } function hideCalendar() { if (!crossobj) return; crossobj.visibility = "hidden"; if (crossMonthObj != null) { crossMonthObj.visibility = "hidden"; } if (crossYearObj != null) { crossYearObj.visibility = "hidden"; } showElement('SELECT'); showElement('APPLET'); } function padZero(num) { return (num < 10)? '0' + num : num ; } function constructDate(d,m,y) { sTmp = dateFormat; sTmp = sTmp.replace("dd", ""); sTmp = sTmp.replace("d", ""); sTmp = sTmp.replace("", padZero(d)); sTmp = sTmp.replace("", d); sTmp = sTmp.replace("mmm", ""); sTmp = sTmp.replace("mm", ""); sTmp = sTmp.replace("m", ""); sTmp = sTmp.replace("", m + 1); sTmp = sTmp.replace("", padZero(m + 1)); sTmp = sTmp.replace("", monthName2[m]); sTmp = sTmp.replace("yyyy", y); return sTmp.replace("yy", padZero(y % 100)); } function closeCalendar() { var sTmp; hideCalendar(); var thedate=(constructDate(dateSelected,monthSelected,yearSelected)); ctlToPlaceValue.value = thedate; //fire onchange event if(ctlToPlaceValue.fireEvent && document.createEventObject) { var eventToFire = document.createEventObject(); ctlToPlaceValue.fireEvent('onchange',eventToFire); } else { if(ctlToPlaceValue.dispatchEvent) { var eventToFire = document.createEvent("HTMLEvents"); eventToFire.initEvent("change",true,true); ctlToPlaceValue.dispatchEvent(eventToFire); } } ctlToPlaceValue.focus(); if (submitmode){ document.forms[0].submit(); } } /*** Month Pulldown ***/ function StartDecMonth() { intervalID1 = setInterval("decMonth()", 80); } function StartIncMonth() { intervalID1 = setInterval("incMonth()", 80); } function incMonth () { monthSelected++; if (monthSelected>11) { monthSelected = 0; yearSelected++; } constructCalendar(); } function decMonth () { monthSelected--; if (monthSelected<0) { monthSelected = 11; yearSelected--; } constructCalendar(); } function constructMonth() { popDownYear(); if (!monthConstructed) { sHTML = ""; for (i=0; i<12; i++) { sName = monthName[i]; if (i==monthSelected){ sName = "" + sName + ""; } sHTML += " " + sName + " "; } document.getElementById("selectMonth").innerHTML = "" + sHTML + ""; monthConstructed = true; } } function popUpMonth() { constructMonth(); crossMonthObj.visibility = (dom || ie) ? "visible" : "show"; crossMonthObj.left = (parseInt(crossobj.left) + 50) + "px"; crossMonthObj.top = (parseInt(crossobj.top) + 26) + "px"; hideElement( 'SELECT', document.getElementById("selectMonth") ); hideElement( 'APPLET', document.getElementById("selectMonth") ); } function popDownMonth() { crossMonthObj.visibility = "hidden"; } /*** Year Pulldown ***/ function incYear() { for (i=0; i<7; i++){ newYear = (i + nStartingYear) + 1; if (newYear == yearSelected) { txtYear = " " + newYear + " "; } else { txtYear = " " + newYear + " "; } document.getElementById("y" + i).innerHTML = txtYear; } nStartingYear++; bShow = true; } function decYear() { for (i=0; i<7; i++){ newYear = (i + nStartingYear) - 1; if (newYear == yearSelected) { txtYear = " " + newYear + " "; } else { txtYear = " " + newYear + " "; } document.getElementById("y" + i).innerHTML = txtYear; } nStartingYear--; bShow = true; } function selectYear(nYear) { yearSelected=parseInt(nYear+nStartingYear); yearConstructed=false; constructCalendar(); popDownYear(); } function constructYear() { popDownMonth(); sHTML = ""; //Remove year constructed test as date textboxes are no longer read only //if (!yearConstructed) { sHTML = "-"; j = 0; nStartingYear = yearSelected - 3; for (i=(yearSelected-3); i<=(yearSelected+3); i++) { sName = i; if (i==yearSelected){ sName = "" + sName + ""; } sHTML += " " + sName + " "; j ++; } sHTML += "+"; document.getElementById("selectYear").innerHTML = "" + sHTML + ""; yearConstructed = true; } function popDownYear() { clearInterval(intervalID1); clearTimeout(timeoutID1); clearInterval(intervalID2); clearTimeout(timeoutID2); crossYearObj.visibility = "hidden"; } function popUpYear() { var leftOffset; constructYear(); crossYearObj.visibility = (dom || ie) ? "visible" : "show"; leftOffset = parseInt(crossobj.left) + document.getElementById("spanYear").offsetLeft; if (ie) { leftOffset += 6; } crossYearObj.left = leftOffset + "px"; crossYearObj.top = (parseInt(crossobj.top) + 26) + "px"; } /*** calendar ***/ function WeekNbr(today) { Year = takeYear(today); Month = today.getMonth(); Day = today.getDate(); now = Date.UTC(Year,Month,Day+1,0,0,0); var Firstday = new Date(); Firstday.setYear(Year); Firstday.setMonth(0); Firstday.setDate(1); then = Date.UTC(Year,0,1,0,0,0); var Compensation = Firstday.getDay(); if (Compensation > 3) Compensation -= 4; else Compensation += 3; NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7); return NumberOfWeek; } function takeYear(theDate) { x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y; } function constructCalendar () { var dateMessage; var startDate = new Date(yearSelected, monthSelected, 1); var endDate = new Date(yearSelected, monthSelected + 1, 0); numDaysInMonth = endDate.getDate(); datePointer = 0; dayPointer = startDate.getDay() - startAt; if (dayPointer<0) { dayPointer = 6; } sHTML = ""; if (showWeekNumber==1) { sHTML += ""; } for (i=0; i<7; i++) { sHTML += ""; } sHTML += ""; if (showWeekNumber==1) { sHTML += ""; } for ( var i=1; i<=dayPointer;i++ ) { sHTML += ""; } for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ ) { dayPointer++; sHTML += ""; if ((showWeekNumber==1)&&(datePointer"; } } } document.getElementById("content").innerHTML = sHTML; document.getElementById("spanMonth").innerHTML = " " + monthName[monthSelected] + " "; document.getElementById("spanYear").innerHTML = " " + yearSelected + " "; } function popUpCalendar(ctl, ctl2Id, format, obj) { if (obj) { (submitmode = true); } else { (submitmode = false); } var ctl2 = document.getElementById(ctl2Id); var leftpos = 0; var toppos = 0; if(ctl2.isDisabled) { return; } if (bPageLoaded) { //alert("in here"); if ( crossobj.visibility == "hidden" ) { ctlToPlaceValue = ctl2; dateFormat="dd/mm/yyyy"; formatChar = " "; aFormat = dateFormat.split(formatChar); if (aFormat.length<3) { formatChar = "/"; aFormat = dateFormat.split(formatChar); if (aFormat.length<3) { formatChar = "."; aFormat = dateFormat.split(formatChar); if (aFormat.length<3) { formatChar = "-"; aFormat = dateFormat.split(formatChar); if (aFormat.length<3) { // invalid date format formatChar = ""; } } } } tokensChanged = 0; if ( formatChar != "" ) { // use user's date aData = ctl2.value.split(formatChar); //alert(aData) for (i=0;i<3;i++) { if ((aFormat[i]=="d") || (aFormat[i]=="dd")) { dateSelected = parseInt(aData[i], 10); tokensChanged++; } else if ((aFormat[i]=="m") || (aFormat[i]=="mm")) { monthSelected = parseInt(aData[i], 10) - 1; tokensChanged++; } else if (aFormat[i]=="yyyy") { yearSelected = parseInt(aData[i], 10); tokensChanged++; } else if (aFormat[i]=="mmm") { for (j=0; j<12; j++) { if (aData[i]==monthName[j]) { monthSelected = j; tokensChanged++; } } } } } if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected) ||isNaN(yearSelected) || (yearSelected + '').length != 4 || !validateDate(ctl2)) { dateSelected = dateNow; monthSelected = monthNow; yearSelected = yearNow; } odateSelected = dateSelected; omonthSelected = monthSelected; oyearSelected = yearSelected; var aTag = ctl; aTag = aTag.offsetParent; while(aTag != null) { leftpos += aTag.offsetLeft; toppos += aTag.offsetTop; aTag = aTag.offsetParent; } crossobj.left = (fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX) + "px"; crossobj.top = (fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY) + "px"; constructCalendar (1, monthSelected, yearSelected); crossobj.visibility=(dom||ie)? "visible" : "show"; hideElement( 'SELECT', document.getElementById("calendar") ); hideElement( 'APPLET', document.getElementById("calendar") ); bShow = true; } } else { init(); popUpCalendar(ctl, ctl2, format); } } function validateDate(dateControl) { var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/; return ((dateControl.value.match(RegExPattern)) && (dateControl.value!='')); } document.onkeypress = function hidecal1 (windowEvent) { if(window.event) { windowEvent = event; } if (windowEvent.keyCode == 27) { hideCalendar(); } } document.onclick = function hidecal2 () { if (!bShow) { hideCalendar(); } bShow = false; } if(ie) { init(); } else { window.onload = init; }
" + weekString + "" + dayName[i] + "
" + WeekNbr(startDate) + "  "; var sStyle="normal-day-style"; //regular day if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)) //today { sStyle = "current-day-style"; } else if (dayPointer % 7 == (startAt * -1) +1) //end-of-the-week day { sStyle = "end-of-weekday-style"; } //selected day if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected)) { sStyle += " selected-day-style"; } sHint = ""; for (k=0;k " + datePointer + " "; sHTML += ""; if ((dayPointer+startAt) % 7 == startAt) { sHTML += "