function YearDigitsOnly(n){var t=n.keyCode?n.keyCode:n.which;return t==8||t==9||t==37||t==39||t==46||t>47&&t<58}function GetTagPixels(n,t){var i=t=="LEFT"?n.offsetLeft:n.offsetTop;while(n.tagName!="BODY"&&n.tagName!="HTML")n=n.offsetParent,i+=t=="LEFT"?n.offsetLeft:n.offsetTop;return i}function BehindCal(n,t,i,r,u,f){var e=GetTagPixels(n,"LEFT"),s=e+n.offsetWidth,o=f+n.offsetHeight;return f<u&&o>r&&e<i&&s>t}function FixSelectLists(n){var i,t;if(navigator.appName=="Microsoft Internet Explorer"){var r=this.getCalendar(),o=r.offsetLeft,s=o+r.offsetWidth,f=r.offsetTop,e=f+CellHeight*9,u=!1;n:for(i=this.formNumber;i<document.forms.length;i++)for(t=0;t<document.forms[i].elements.length;t++)if(typeof document.forms[i].elements[t].type=="string"){document.forms[i].elements[t].type=="hidden"&&document.forms[i].elements[t].name==this.hiddenFieldName&&(u=!0,t+=3);if(u)if(document.forms[i].elements[t].type.substr(0,6)=="select"){ListTopY=GetTagPixels(document.forms[i].elements[t],"TOP");if(ListTopY<e)BehindCal(document.forms[i].elements[t],o,s,f,e,ListTopY)&&(document.forms[i].elements[t].style.visibility=n?"hidden":"visible");else break n}}}}function DayCellHover(n,t,i,r){n.style.backgroundColor=t?DayBGColor:i;if(t)if(this.yearValue==Today.getFullYear()&&this.monthIndex==Today.getMonth()&&r==Today.getDate())self.status="Click to select today";else{var u=r.toString();switch(u.substr(u.length-1,1)){case"1":u+=r==11?"th":"st";break;case"2":u+=r==12?"th":"nd";break;case"3":u+=r==13?"th":"rd";break;default:u+="th"}self.status="Click to select "+this.monthName+" "+u}else self.status="";return!0}function PickDisplayDay(n){var t,i;this.show();var u=this.getMonthList(),r=this.getDayList(),f=this.getYearField();for(FixDayList(r,GetDayCount(this.displayed.yearValue,this.displayed.monthIndex)),t=0;t<u.length;t++)u.options[t].value==this.displayed.monthIndex&&(u.options[t].selected=!0);for(i=1;i<=r.length;i++)i==n&&(r.options[i-1].selected=!0);this.setPicked(this.displayed.yearValue,this.displayed.monthIndex,n),f.value=this.picked.yearPad,f.defaultValue=f.value}function BuildCalendarDays(){var r=5,n,t,i;for(this.displayed.dayCount==31&&this.displayed.firstDay>4||this.displayed.dayCount==30&&this.displayed.firstDay==6?r=6:this.displayed.dayCount==28&&this.displayed.firstDay==0&&(r=4),n='<table width="'+CellWidth*7+'" cellspacing="0" cellpadding="1" style="cursor:default">',t=0;t<r;t++){for(n+="<tr>",i=1;i<=7;i++)Day=t*7+(i-this.displayed.firstDay),Day<1||Day>this.displayed.dayCount?n+='<td class="calendarDateInput" style="height:'+CellHeight+'">&nbsp;</td>':(this.displayed.yearValue==this.picked.yearValue&&this.displayed.monthIndex==this.picked.monthIndex&&Day==this.picked.day?(TextStyle="color:white;font-weight:bold;",BackColor=DayBGColor):(TextStyle="color:black;",BackColor=CalBGColor),this.displayed.yearValue==Today.getFullYear()&&this.displayed.monthIndex==Today.getMonth()&&Day==Today.getDate()&&(TextStyle+="border:1px solid darkred;padding:0px;"),n+='<td align="center" class="calendarDateInput" style="cursor:default;height:'+CellHeight+";width:"+CellWidth+";"+TextStyle+";background-color:"+BackColor+'" onClick="'+this.objName+".pickDay("+Day+')" onMouseOver="return '+this.objName+".displayed.dayHover(this,true,'"+BackColor+"',"+Day+')" onMouseOut="return '+this.objName+".displayed.dayHover(this,false,'"+BackColor+"')\">"+Day+"</td>");n+="</tr>"}return n+="</table>"}function GetGoodYear(n){if(n.length==4)return n;var t=n<Y2kPivotPoint?2e3:1900;return t+parseInt(n,10)}function GetDayCount(n,t){return t==1&&(n%400==0||n%4==0&&n%100!=0)?29:MonthDays[t]}function VirtualButton(n,t){t?(n.style.borderLeft="buttonshadow 1px solid",n.style.borderTop="buttonshadow 1px solid",n.style.borderBottom="buttonhighlight 1px solid",n.style.borderRight="buttonhighlight 1px solid"):(n.style.borderLeft="buttonhighlight 1px solid",n.style.borderTop="buttonhighlight 1px solid",n.style.borderBottom="buttonshadow 1px solid",n.style.borderRight="buttonshadow 1px solid")}function NeighborHover(n,t,i){return t?(VirtualButton(n,!1),self.status="Click to view "+i.fullName):(n.style.border="buttonface 1px solid",self.status=""),!0}function FixDayList(n,t){var r=n.selectedIndex+1,u,i;if(t!=n.length){for(u=n.length,i=Math.min(t,u);i<Math.max(t,u);i++)i>=t?n.options[t]=null:n.options[i]=new Option(i+1,i+1);r=Math.min(r,t),n.options[r-1].selected=!0}return r}function FixYearInput(n){var t=new RegExp("\\d{"+n.defaultValue.length+"}");t.test(n.value)||(n.value=n.defaultValue)}function CalIconHover(n){var t=this.isShowing()?"hide":"show";return self.status=n?"Click to "+t+" the calendar":"",!0}function CalTimerReset(){eval("clearTimeout("+this.timerID+")"),eval(this.timerID+"=setTimeout('"+this.objName+".show()',"+HideWait*1e3+")")}function DoTimer(n){n?eval("clearTimeout("+this.timerID+")"):(eval(this.timerID+"=null"),this.resetTimer())}function ShowCalendar(){var n;this.isShowing()?(n=!0,this.getCalendar().style.zIndex=--ZCounter,this.getCalendar().style.visibility="hidden",this.getCalendar().style.display="none",this.fixSelects(!1)):(n=!1,this.fixSelects(!0),this.getCalendar().style.zIndex=++ZCounter,this.getCalendar().style.visibility="visible",this.getCalendar().style.display="inline"),this.handleTimer(n),self.status=""}function SetElementStatus(n){this.getDayList().style.visibility=n?"hidden":"visible",this.getYearField().style.visibility=n?"hidden":"visible",this.getCalendarLink().style.visibility=n?"hidden":"visible"}function CheckMonthChange(n){var i=this.getDayList(),t;n.options[n.selectedIndex].value==""?(i.selectedIndex=0,this.hideElements(!0),this.setHidden("")):(this.hideElements(!1),this.isShowing()&&(this.resetTimer(),this.getCalendar().style.zIndex=++ZCounter),t=FixDayList(i,GetDayCount(this.picked.yearValue,n.options[n.selectedIndex].value)),this.setPicked(this.picked.yearValue,n.options[n.selectedIndex].value,t))}function CheckDayChange(n){this.isShowing()&&this.show(),this.setPicked(this.picked.yearValue,this.picked.monthIndex,n.selectedIndex+1)}function CheckYearInput(n){if(n.value.length==n.defaultValue.length&&n.defaultValue!=n.value){this.isShowing()&&(this.resetTimer(),this.getCalendar().style.zIndex=++ZCounter);var t=GetGoodYear(n.value),r=this.getMonthList(),i=FixDayList(this.getDayList(),GetDayCount(t,this.picked.monthIndex));this.setPicked(t,this.picked.monthIndex,i),n.defaultValue=n.value}}function dateObject(){var n,t,i;Function.call?(n=this,t=0):(n=arguments[0],t=1),n.date=arguments.length==t+1?new Date(arguments[t+0]):new Date(arguments[t+0],arguments[t+1],arguments[t+2]),n.yearValue=n.date.getFullYear(),n.monthIndex=n.date.getMonth(),n.monthName=MonthNames[n.monthIndex],n.fullName=n.monthName+" "+n.yearValue,n.day=n.date.getDate(),n.dayCount=GetDayCount(n.yearValue,n.monthIndex),i=new Date(n.yearValue,n.monthIndex,1),n.firstDay=i.getDay()}function storedMonthObject(n,t,i,r){var u;Function.call?dateObject.call(this,t,i,r):dateObject(this,t,i,r),this.yearPad=this.yearValue.toString(),this.monthPad=this.monthIndex<9?"0"+String(this.monthIndex+1):this.monthIndex+1,this.dayPad=this.day<10?"0"+this.day.toString():this.day,this.monthShort=this.monthName.substr(0,3).toUpperCase(),n.indexOf("YYYY")==-1&&(this.yearPad=this.yearPad.substr(2)),u=n.indexOf("/")<0?n.indexOf("-")<0?"":"-":"/",/DD?.?((MON)|(MM?M?))/.test(n)?(this.formatted=this.dayPad+u,this.formatted+=RegExp.$1.length==3?this.monthShort:this.monthPad):/((MON)|(MM?M?))?.?DD?/.test(n)&&(this.formatted=RegExp.$1.length==3?this.monthShort:this.monthPad,this.formatted+=u+this.dayPad),this.formatted=n.substr(0,2)=="YY"?this.yearPad+u+this.formatted:this.formatted+u+this.yearPad}function displayMonthObject(n,t,i,r){Function.call?dateObject.call(this,t,i,r):dateObject(this,t,i,r),this.displayID=n.hiddenFieldName+"_Current_ID",this.getDisplay=new Function("return document.getElementById(this.displayID)"),this.dayHover=DayCellHover,this.goCurrent=new Function(n.objName+".getCalendar().style.zIndex=++ZCounter;"+n.objName+".setDisplayed(Today.getFullYear(),Today.getMonth());"),n.formNumber<0||(this.getDisplay().innerHTML=this.fullName)}function neighborMonthObject(n,t,i){Function.call?dateObject.call(this,i):dateObject(this,i),this.buttonID=n.hiddenFieldName+"_"+t+"_ID",this.hover=new Function("C","O","NeighborHover(C,O,this)"),this.getButton=new Function("return document.getElementById(this.buttonID)"),this.go=new Function(n.objName+".getCalendar().style.zIndex=++ZCounter;"+n.objName+".setDisplayed(this.yearValue,this.monthIndex);"),n.formNumber<0||(this.getButton().title=this.monthName)}function SetDisplayedMonth(n,t){this.displayed=new displayMonthObject(this,n,t,1),this.previous=new neighborMonthObject(this,"Previous",this.displayed.date.getTime()-864e5),this.next=new neighborMonthObject(this,"Next",this.displayed.date.getTime()+864e5*(this.displayed.dayCount+1)),this.formNumber<0||(this.getDayTable().innerHTML=this.buildCalendar())}function SetPickedMonth(n,t,i){this.picked=new storedMonthObject(this.format,n,t,i),this.setHidden(this.picked.formatted),this.setDisplayed(n,t)}function calendarObject(n,t,i){function h(n){for(var t=0;t<MonthNames.length;t++)if(MonthNames[t].substr(0,3).toUpperCase()==n.toUpperCase())break;return t}function s(n,r){n.setPicked(Today.getFullYear(),Today.getMonth(),Today.getDate()),r&&alert("WARNING: The supplied date is not in valid '"+t+"' format: "+i+".\nTherefore, the current system date will be used instead: "+n.picked.formatted)}var o,e,f,r,u;this.hiddenFieldName=n,this.monthListID=n+"_Month_ID",this.dayListID=n+"_Day_ID",this.yearFieldID=n+"_Year_ID",this.monthDisplayID=n+"_Current_ID",this.calendarID=n+"_ID",this.dayTableID=n+"_DayTable_ID",this.calendarLinkID=this.calendarID+"_Link",this.timerID=this.calendarID+"_Timer",this.objName=n+"_Object",this.format=t,this.formNumber=-1,this.picked=null,this.displayed=null,this.previous=null,this.next=null,this.setPicked=SetPickedMonth,this.setDisplayed=SetDisplayedMonth,this.checkYear=CheckYearInput,this.fixYear=FixYearInput,this.changeMonth=CheckMonthChange,this.changeDay=CheckDayChange,this.resetTimer=CalTimerReset,this.hideElements=SetElementStatus,this.show=ShowCalendar,this.handleTimer=DoTimer,this.iconHover=CalIconHover,this.buildCalendar=BuildCalendarDays,this.pickDay=PickDisplayDay,this.fixSelects=FixSelectLists,this.setHidden=new Function("D","if (this.formNumber >= 0) this.getHiddenField().value=D"),this.getHiddenField=new Function("return document.forms[this.formNumber].elements[this.hiddenFieldName]"),this.getMonthList=new Function("return document.getElementById(this.monthListID)"),this.getDayList=new Function("return document.getElementById(this.dayListID)"),this.getYearField=new Function("return document.getElementById(this.yearFieldID)"),this.getCalendar=new Function("return document.getElementById(this.calendarID)"),this.getDayTable=new Function("return document.getElementById(this.dayTableID)"),this.getCalendarLink=new Function("return document.getElementById(this.calendarLinkID)"),this.getMonthDisplay=new Function("return document.getElementById(this.monthDisplayID)"),this.isShowing=new Function("return !(this.getCalendar().style.visibility != 'visible')"),i!=""&&(this.format=="YYYYMMDD"&&/^(\d{4})(\d{2})(\d{2})$/.test(i)?this.setPicked(RegExp.$1,parseInt(RegExp.$2,10)-1,RegExp.$3):this.format.substr(0,2)=="YY"&&/^(\d{2,4})(-|\/)/.test(i)?(f=GetGoodYear(RegExp.$1),/(-|\/)(\w{1,3})(-|\/)(\w{1,3})$/.test(i)?(o=RegExp.$2,e=RegExp.$4,/D$/.test(this.format)?(u=e,r=o):(u=o,r=e),r=/\d{1,2}/i.test(r)?parseInt(r,10)-1:h(r),this.setPicked(f,r,u)):s(this,!0)):/(-|\/)(\d{2,4})$/.test(i)?(f=GetGoodYear(RegExp.$2),/^(\w{1,3})(-|\/)(\w{1,3})(-|\/)/.test(i)?(this.format.substr(0,1)=="D"?(u=RegExp.$1,r=RegExp.$3):(r=RegExp.$1,u=RegExp.$3),r=/\d{1,2}/i.test(r)?parseInt(r,10)-1:h(r),this.setPicked(f,r,u)):s(this,!0)):s(this,!0))}function DateInput(DateName,Required,n,DefaultDate){var t,CurrentDate,InitialStatus,InitialDate,f,e,NoneSelected,i,j,w;if(arguments.length==0)document.writeln('<span style="color:red;font-size:'+FontSize+"px;font-family:"+FontFamily+";\">ERROR: Missing required parameter in call to 'DateInput': [name of hidden date field].</span>");else{arguments.length<3?(n=DefaultDateFormat,arguments.length<2&&(Required=!1)):/^(Y{2,4}(-|\/)?)?((MON)|(MM?M?)|(DD?))(-|\/)?((MON)|(MM?M?)|(DD?))((-|\/)Y{2,4})?$/i.test(n)?n=n.toUpperCase():(t="WARNING: The supplied date format for the '"+DateName+"' field is not valid: "+n+"\nTherefore, the default date format will be used instead: "+DefaultDateFormat,n=DefaultDateFormat,arguments.length==4&&(CurrentDate=new storedMonthObject(n,Today.getFullYear(),Today.getMonth(),Today.getDate()),t+="\n\nThe supplied date ("+DefaultDate+") cannot be interpreted with the invalid format.\nTherefore, the current system date will be used instead: "+CurrentDate.formatted,DefaultDate=CurrentDate.formatted),alert(t)),CurrentDate||(CurrentDate=new storedMonthObject(n,Today.getFullYear(),Today.getMonth(),Today.getDate())),arguments.length<4&&(DefaultDate=Required?CurrentDate.formatted:""),eval(DateName+"_Object=new calendarObject('"+DateName+"','"+n+"','"+DefaultDate+"')"),Required||arguments.length==4?(InitialStatus="",InitialDate=eval(DateName+"_Object.picked.formatted")):(InitialStatus=' style="visibility:hidden"',InitialDate="",eval(DateName+"_Object.setPicked("+Today.getFullYear()+","+Today.getMonth()+","+Today.getDate()+")"));with(document){for(writeln('<input type="hidden" name="'+DateName+'" value="'+InitialDate+'">'),f=0;f<forms.length;f++)for(e=0;e<forms[f].elements.length;e++)if(typeof forms[f].elements[e].type=="string")if(forms[f].elements[e].type=="hidden"&&forms[f].elements[e].name==DateName){eval(DateName+"_Object.formNumber="+f);break}for(writeln('<table cellpadding="0" cellspacing="2"><tr>'+String.fromCharCode(13)+'<td valign="middle">'),writeln('<select class="calendarDateInput" id="'+DateName+'_Month_ID" onChange="'+DateName+'_Object.changeMonth(this)">'),Required||(NoneSelected=DefaultDate==""?" selected":"",writeln('<option value=""'+NoneSelected+">"+UnselectedMonthText+"</option>")),i=0;i<12;i++)MonthSelected=DefaultDate!=""&&eval(DateName+"_Object.picked.monthIndex")==i?" selected":"",writeln('<option value="'+i+'"'+MonthSelected+">"+MonthNames[i].substr(0,3)+"</option>");for(writeln("</select>"+String.fromCharCode(13)+"</td>"+String.fromCharCode(13)+'<td valign="middle">'),writeln("<select"+InitialStatus+' class="calendarDateInput" id="'+DateName+'_Day_ID" onChange="'+DateName+'_Object.changeDay(this)">'),j=1;j<=eval(DateName+"_Object.picked.dayCount");j++)DaySelected=DefaultDate!=""&&eval(DateName+"_Object.picked.day")==j?" selected":"",writeln("<option"+DaySelected+">"+j+"</option>");for(writeln("</select>"+String.fromCharCode(13)+"</td>"+String.fromCharCode(13)+'<td valign="middle">'),writeln("<input"+InitialStatus+' class="calendarDateInput" style="height:15px;" type="text" id="'+DateName+'_Year_ID" size="'+eval(DateName+"_Object.picked.yearPad.length")+'" maxlength="'+eval(DateName+"_Object.picked.yearPad.length")+'" title="Year" value="'+eval(DateName+"_Object.picked.yearPad")+'" onKeyPress="return YearDigitsOnly(window.event)" onKeyUp="'+DateName+'_Object.checkYear(this)" onBlur="'+DateName+'_Object.fixYear(this)">'),write('<td valign="middle">'+String.fromCharCode(13)+'<span class="calendarIMG"><a'+InitialStatus+' id="'+DateName+'_ID_Link" href="javascript:'+DateName+'_Object.show()" onMouseOver="return '+DateName+'_Object.iconHover(true)" onMouseOut="return '+DateName+'_Object.iconHover(false)"><img src="'+ImageURL+'" title="Calendar" border="0"></a></span>'),writeln('<span id="'+DateName+'_ID" style="position:absolute;visibility:hidden;display:none;width:'+CellWidth*7+"px;background-color:"+CalBGColor+';border:1px solid dimgray;" onMouseOver="'+DateName+'_Object.handleTimer(true)" onMouseOut="'+DateName+'_Object.handleTimer(false)">'),writeln('<table width="'+CellWidth*7+'" cellspacing="0" cellpadding="1">'+String.fromCharCode(13)+'<tr style="background-color:'+TopRowBGColor+';">'),writeln('<td id="'+DateName+'_Previous_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:'+CellHeight+'" onClick="'+DateName+'_Object.previous.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return '+DateName+'_Object.previous.hover(this,true)" onMouseOut="return '+DateName+'_Object.previous.hover(this,false)" title="'+eval(DateName+"_Object.previous.monthName")+'"><img src="'+PrevURL+'"></td>'),writeln('<td id="'+DateName+'_Current_ID" style="cursor:pointer" align="center" class="calendarDateInput" style="height:'+CellHeight+'" colspan="5" onClick="'+DateName+'_Object.displayed.goCurrent()" onMouseOver="self.status=\'Click to view '+CurrentDate.fullName+'\';return true;" onMouseOut="self.status=\'\';return true;" title="Show Current Month">'+eval(DateName+"_Object.displayed.fullName")+"</td>"),writeln('<td id="'+DateName+'_Next_ID" style="cursor:default" align="center" class="calendarDateInput" style="height:'+CellHeight+'" onClick="'+DateName+'_Object.next.go()" onMouseDown="VirtualButton(this,true)" onMouseUp="VirtualButton(this,false)" onMouseOver="return '+DateName+'_Object.next.hover(this,true)" onMouseOut="return '+DateName+'_Object.next.hover(this,false)" title="'+eval(DateName+"_Object.next.monthName")+'"><img src="'+NextURL+'"></td></tr>'+String.fromCharCode(13)+"<tr>"),w=0;w<7;w++)writeln('<td width="'+CellWidth+'" align="center" class="calendarDateInput" style="height:'+CellHeight+";width:"+CellWidth+';font-weight:bold;border-top:1px solid dimgray;border-bottom:1px solid dimgray;">'+WeekDays[w]+"</td>");writeln("</tr>"+String.fromCharCode(13)+"</table>"+String.fromCharCode(13)+'<span id="'+DateName+'_DayTable_ID">'+eval(DateName+"_Object.buildCalendar()")+"</span>"+String.fromCharCode(13)+"</span>"+String.fromCharCode(13)+"</td>"+String.fromCharCode(13)+"</tr>"+String.fromCharCode(13)+"</table>")}}}var DefaultDateFormat="MM/DD/YYYY",HideWait=5,Y2kPivotPoint=76,UnselectedMonthText="",FontSize=11,FontFamily="Arial",CellWidth=18,CellHeight=16,ImageURL="Images/request/icon_calendar.gif",NextURL="Images/request/next.gif",PrevURL="Images/request/prev.gif",CalBGColor="white",TopRowBGColor="buttonface",DayBGColor="lightgrey",ZCounter=100,Today=new Date,WeekDays=["S","M","T","W","T","F","S"],MonthDays=[31,28,31,30,31,30,31,31,30,31,30,31],MonthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];with(document)writeln("<style>"),writeln("td.calendarDateInput {letter-spacing:normal;line-height:normal;font-family:"+FontFamily+",Sans-Serif;font-size:"+FontSize+"px;}"),writeln("select.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}"),writeln("input.calendarDateInput {letter-spacing:.06em;font-family:Verdana,Sans-Serif;font-size:11px;}"),writeln("</style>")
