var fixedX=-1;var fixedY=-1;var startAt=1;var showToday=1;var shortDays=1;var calWidth=174;var calPos='right';var imgDir=CAL_IMG_FOLDER;var todayString=TXT_TODAY+':';var cal,monthSelected,yearSelected,dateSelected,omonthSelected,oyearSelected,odateSelected,dateCtrl,dayCtrl,monthCtrl,ctlNow,dateFormat,nStartingYear,endFunction;var bMouseOver=falsevar bPageLoaded=falsevar ie=document.allvar dom=document.getElementByIdvar ns4=document.layersvar today=new Date()var dateNow=today.getDate()var monthNow=today.getMonth()var yearNow=today.getYear()var bShowCal=false;var monthName=new Array(TXT_JANUARY,TXT_FEBRUARY,TXT_MARCH,TXT_APRIL,TXT_MAY,TXT_JUNE,TXT_JULY,TXT_AUGUST,TXT_SEPTEMBER,TXT_OCTOBER,TXT_NOVEMBER,TXT_DECEMBER);var monthShorts=new Array(TXT_JAN,TXT_FEB,TXT_MAR,TXT_APR,TXT_MAY_SHORT,TXT_JUN,TXT_JUL,TXT_AUG,TXT_SEP,TXT_OCT,TXT_NOV,TXT_DEC);var dayName=new Array(TXT_MON,TXT_TUE,TXT_WED,TXT_THU,TXT_FRI,TXT_SAT,TXT_SUN);if(startAt==0){dayName=new Array(TXT_SUN,TXT_MON,TXT_TUE,TXT_WED,TXT_THU,TXT_FRI,TXT_SAT);}var dayTitle=(shortDays==0?dayName:new Array(TXT_MON_SHORT,TXT_TUE_SHORT,TXT_WED_SHORT,TXT_THU_SHORT,TXT_FRI_SHORT,TXT_SAT_SHORT,TXT_SUN_SHORT));if(startAt==0){dayTitle=(shortDays==0?dayName:new Array(TXT_SUN_SHORT,TXT_MON_SHORT,TXT_TUE_SHORT,TXT_WED_SHORT,TXT_THU_SHORT,TXT_FRI_SHORT,TXT_SAT_SHORT));}function getCalDiv(){var calDiv=GetItemById("calendar");if(!calDiv&& dom){calDiv=document.createElement('DIV');calDiv.style.position='absolute';calDiv.id='calendar';calDiv.className='div-style';calDiv.onclick=new Function('bShowCal=true');calDiv.onmouseover=new Function('bMouseOver=true');calDiv.onmouseout=new Function('bMouseOver=false');document.body.appendChild(calDiv);var calTbl="<table cellspacing=1 cellpadding=0 width=100% class='table-style'><tr class='title-background-style'><td><table border=0 cellspacing=0 cellpadding=0 width='100%'><tr><td id='caption' class='title-style'></td><td class='title-style' align=right valign=middle><a href='javascript:hideCalendar();'><IMG SRC='"+imgDir+"close.gif' WIDTH='10' HEIGHT='10' BORDER='0' ALT='Close the Calendar'></a></td></tr></table></td></tr><tr><td><span id='calContent'></span></td></tr>";if(showToday==1){calTbl+="<tr><td class='today-style'><span id='lblToday'></span></td></tr>";}calTbl+="</table>";calDiv.innerHTML=calTbl;}if(!calDiv.hideFrame&& BrowserNeedIFrame()){hideFrame=document.createElement('IFRAME');hideFrame.id=calDiv.id+'hideFrame';hideFrame.style.border='2px';hideFrame.style.zIndex='999';hideFrame.style.visibility='hidden';hideFrame.style.position='absolute';document.body.appendChild(hideFrame);calDiv.hideFrame=hideFrame;}return calDiv;}function swapImage(srcImg,destImg){if(ie){GetItemById(srcImg).setAttribute("src",imgDir+destImg)}}function initCal(){if(!ns4){if(!ie){yearNow+=1900}cal=getCalDiv();hideCalendar();if(showToday==1){GetItemById("lblToday").innerHTML=todayString+" <a class='today-style' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>"+dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", "+dateNow+" "+monthShorts[monthNow]+" "+yearNow+"</a>";}html="<table width=100% cellpadding=0 border=0><tr>";html+="<td id='spanLeft' class='title-button' onmouseover='swapImage(\"changeLeft\",\"left2.gif\");' onclick='javascript:decMonth()' onmouseout='swapImage(\"changeLeft\",\"left1.gif\");'><IMG id='changeLeft' SRC='"+imgDir+"left1.gif' width=10 height=10 border=0 align=absmiddle></td>";html+="<td id='spanMonthYear' class='title-month-year' style='width:"+(calWidth-75)+"px'></td>";html+="<td id='spanRight' class='title-button' onmouseover='swapImage(\"changeRight\",\"right2.gif\");' onmouseout='swapImage(\"changeRight\",\"right1.gif\");' onclick='incMonth()'><IMG id='changeRight' SRC='"+imgDir+"right1.gif' width=10 height=10 border=0 align=absmiddle></td>";html+="</tr></table>";GetItemById("caption").innerHTML=html;bPageLoaded=true;}}function hideCalendar(){if(cal&& cal.style){cal.style.visibility="hidden";if(cal.hideFrame){cal.hideFrame.style.visibility=cal.style.visibility;}}}function padZero(num){return(num<10)?'0'+num:num;}function constructDate(d,m,y){sTmp=dateFormat;sTmp=sTmp.replace("dd","<e>");sTmp=sTmp.replace("d","<d>");sTmp=sTmp.replace("<e>",padZero(d));sTmp=sTmp.replace("<d>",d);sTmp=sTmp.replace("mmm","<o>");sTmp=sTmp.replace("mm","<n>");sTmp=sTmp.replace("m","<m>");sTmp=sTmp.replace("<m>",m+1);sTmp=sTmp.replace("<n>",padZero(m+1));sTmp=sTmp.replace("<o>",monthName[m]);return sTmp.replace("yyyy",y);}function closeCalendar(){var sTmp;dateCtrl.value=constructDate(dateSelected,monthSelected,yearSelected);if(dayCtrl){dayCtrl.value=dateSelected;}if(monthCtrl){monthCtrl.value=yearSelected+"-"+(monthSelected+1);}if(endFunction){endFunction();}hideCalendar();}function incMonth(){monthSelected++;if(monthSelected>11){monthSelected=0;yearSelected++;}constructCalendar();}function decMonth(){monthSelected--;if(monthSelected<0){monthSelected=11;yearSelected--;}constructCalendar();}function constructCalendar(){var startDate=new Date(yearSelected,monthSelected,1);var endDate=new Date(yearSelected,monthSelected+1,1);endDate=new Date(endDate-(24*60*60*1000));numDaysInMonth=endDate.getDate();datePointer=0;dayPointer=startDate.getDay()-startAt;if(dayPointer<0){dayPointer=6;}sHTML="<table width=100% border=0 cellspacing=0 class='body-style'><tr>";for(i=0;i<7;i++){sHTML+="<td class='day-title-style'>"+dayTitle[i]+"</td>";}sHTML+="</tr><tr>";for(var i=1;i<=dayPointer;i++){sHTML+="<td>&nbsp;</td>";}for(datePointer=1;datePointer<=numDaysInMonth;datePointer++){dayPointer++;sHTML+="<td class='day-cell-style'>";var sStyle="normal-day-style";if((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)){sStyle="current-day-style";}else if(dayPointer%7==(startAt*-1)+1){sStyle="end-of-weekday-style";}if((datePointer==odateSelected)&&(monthSelected==omonthSelected)&&(yearSelected==oyearSelected)){sStyle+=" selected-day-style";}var itemDate=new Date(yearSelected,monthSelected,datePointer,23,59,59);if(itemDate<today){sHTML+="<span class='disabled-day-style'>&nbsp;"+datePointer+"&nbsp;</span>";}else{sHTML+="<a class='"+sStyle+"' href='javascript:dateSelected="+datePointer+";closeCalendar();'>&nbsp;"+datePointer+"&nbsp;</a>";}if((dayPointer+startAt)%7==startAt){sHTML+="</tr><tr>";}}GetItemById("calContent").innerHTML=sHTML;GetItemById("spanMonthYear").innerHTML=monthName[monthSelected]+"&nbsp;"+yearSelected;ResizeHideFrame();}function popUpCalendar(ctl,format,dateId,ctlDay,ctlMonth,func,pos){if(typeof(ctl)=='string'){ctl=GetItemById(ctl);}if(!pos){pos=calPos;}var parent=GetParent(ctl);if(parent&& parent.disabled)return;var leftpos=0;var toppos=0;if(bPageLoaded){bMouseOver=false;endFunction=func;dateCtrl=(dateId?GetItemById(dateId):null);dayCtrl=(ctlDay?GetItemById(ctlDay):null);monthCtrl=(ctlMonth?GetItemById(ctlMonth):null);dateFormat=format.toLowerCase();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){formatChar="";}}}}tokensChanged=0if(formatChar!=""){aData=dateCtrl.value.split(formatChar);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)){dateSelected=dateNow;monthSelected=monthNow;yearSelected=yearNow;}odateSelected=dateSelected;omonthSelected=monthSelected;oyearSelected=yearSelected;aTag=ctl.offsetParent;while(aTag&& aTag.tagName!="BODY"){leftpos+=aTag.offsetLeft;toppos+=aTag.offsetTop;aTag=aTag.offsetParent;}constructCalendar(1,monthSelected,yearSelected);var left=(fixedX==-1)?ctl.offsetLeft+leftpos+(pos=='right'?ctl.offsetWidth:0)+1:fixedX;var top=(fixedY==-1)?ctl.offsetTop+toppos+(pos=='bottom'?ctl.offsetHeight:0):fixedY;cal.style.width=calWidth+"px";cal.style.left=left+"px";cal.style.top=top+"px";cal.style.visibility=(dom||ie)?"visible":"show";cal.style.zIndex='1000';ResizeHideFrame();bShowCal=true;}else{initCal();popUpCalendar(ctl,format,dateId,ctlDay,ctlMonth,func,pos);}}function ResizeHideFrame(){if(cal.hideFrame){cal.hideFrame.style.left=cal.style.left;cal.hideFrame.style.top=cal.style.top;cal.hideFrame.style.width=cal.style.width;cal.hideFrame.style.visibility=cal.style.visibility;cal.hideFrame.height=(cal.offsetHeight?cal.offsetHeight:cal.style.pixelHeight);}}calendarVisible=function(){if(cal&& cal.style){return(cal.style.visibility!="hidden");}return false;}document.onclick=function(){if(!bShowCal){hideCalendar();}bShowCal=false;}function BrowserNeedIFrame(){var agent=navigator.userAgent;var arrNoFrame=['Konqueror'];for(var i=0;i<arrNoFrame.length;i++){if(agent.indexOf(arrNoFrame[i])!=-1){return false;}}return true;}function GetParent(elem){return(elem.parentElement?elem.parentElement:elem.parentNode);}function GetItemById(id){return(document.all?document.all[id]:document.getElementById(id));}