﻿function CheckStyle(strclass)
{try
{var rules;if(typeof document.styleSheets!="undefined")
{var cssSheets=document.styleSheets;for(var i=0;i<cssSheets.length;i++)
{rules=(typeof cssSheets[i].cssRules!="undefined")?cssSheets[i].cssRules:cssSheets[i].rules;for(var j=0;j<rules.length;j++)
{try
{if(rules[j].selectorText!=''&&rules[j].selectorText.toUpperCase()==strclass.toUpperCase())
{return true;}}
catch(ex){}}}}
return false;}
catch(ex)
{return false;}}
var cal_calid='mycal';var cal_shown=false;var cal_defaultformat='dd MMM yyyy';var cal_defaultmonths=1;var cal_defaultvertical='NO';var ie=document.all;document.write('<div id="'+cal_calid+'" style="z-index: 100; width: 150px; padding: 2px 2px 2px 2px; display: none; position: absolute;" onclick="cal_shown=true;"></div>');document.write('<div id="calinfo" class="cal_info" nowrap> </div>');document.write('<style type="text/css">');if(!CheckStyle('.cal_calendar'))document.write('.cal_calendar     {cursor: default; background-color: #EEEEF0; border: 1px solid #000000; font-size: 11px; font-family: Arial, Helvetica, sans-serif;}')
if(!CheckStyle('.cal_weekday'))document.write('.cal_weekday      {background-color: #AAAAAA; border-bottom: 1px solid #000000; text-align: center; height:14px;}');if(!CheckStyle('.cal_month'))
{document.write('.cal_month        {background-color: #9999FF; color: #FFFFFF; border-bottom: 1px solid #000000; text-align: left;}');document.write('.cal_month a      {background-color: #6666FF; padding: 0px 1px 0px 2px; color: #FFFFFF; font-weight: bold; text-decoration: none;}');}
if(!CheckStyle('.cal_year'))
{document.write('.cal_year         {background-color: #9999FF; color: #FFFFFF; border-bottom: 1px solid #000000; text-align: right;}');document.write('.cal_year  a      {background-color: #6666FF; padding: 0px 1px 0px 2px; color: #FFFFFF; font-weight: bold; text-decoration: none;}');}
if(!CheckStyle('.cal_nodate'))document.write('.cal_nodate       {color: #AAAAAA; text-align: center; font-style: italic; text-decoration: line-through;}');if(!CheckStyle('.cal_date'))document.write('.cal_date         {cursor: pointer; text-align: center;}');if(!CheckStyle('.cal_dateselected'))document.write('.cal_dateselected {border: 1px solid #000000; cursor: pointer; text-align: center; font-weight: bold;}');if(!CheckStyle('.cal_info'))document.write('.cal_info         {z-index: 200; background-color: #FFFF99; padding: 2px 2px 2px 2px; display: none; position: absolute; text-align: center; border: 1px solid #000000; font-size: 11px; font-family: Arial, Helvetica, sans-serif;}');document.write('</style>');var cal_fullmonths=new Array(12);cal_fullmonths[0]='January';cal_fullmonths[1]='February';cal_fullmonths[2]='March';cal_fullmonths[3]='April';cal_fullmonths[4]='May';cal_fullmonths[5]='June';cal_fullmonths[6]='July';cal_fullmonths[7]='August';cal_fullmonths[8]='September';cal_fullmonths[9]='October';cal_fullmonths[10]='November';cal_fullmonths[11]='December';var cal_shortmonths=new Array(12);cal_shortmonths[0]='Jan';cal_shortmonths[1]='Feb';cal_shortmonths[2]='Mar';cal_shortmonths[3]='Apr';cal_shortmonths[4]='May';cal_shortmonths[5]='Jun';cal_shortmonths[6]='Jul';cal_shortmonths[7]='Aug';cal_shortmonths[8]='Sep';cal_shortmonths[9]='Oct';cal_shortmonths[10]='Nov';cal_shortmonths[11]='Dec';document.onclick=function hidecal2()
{if(!cal_shown&&document.getElementById(cal_calid).style.display!='none')
{HideCalendar();}
cal_shown=false;}
function ShowCalendar(strsourceid,strtargetid,strformat,intmonths,datmin,datmax,strdefault,verticalmonth)
{try
{var strval;var datstart=new Date();if(strsourceid&&!document.getElementById(strsourceid))
{strsourceid=strsourceid.id;}
if(strtargetid&&!document.getElementById(strtargetid))
{strtargetid=strtargetid.id;}
if(!intmonths)
intmonths=1;if(!verticalmonth)
{verticalmonth='NO';}
else if(verticalmonth&&intmonths==1)
{verticalmonth='YES';}
else if(verticalmonth&&intmonths>1)
{if(verticalmonth.toUpperCase()=='YES')
{verticalmonth='YES';}
else
{verticalmonth='NO';}}
if(!strformat||strformat=='')
strformat=cal_defaultformat;if(datmin)
datmin=new Date(datmin);else
datmin=new Date('1 Jan 1900');if(datmax)
datmax=new Date(datmax);else
datmax=new Date('1 Jan 3000');if(cal_shown)
{if(strdefault&&strdefault!='')
{datstart.setTime(Date.parse(strdefault));}
else
{datstart=new Date();}}
else
{if(!document.getElementById(strtargetid))
{if(strdefault!=''&&strdefault)
{datstart.setTime(Date.parse(strdefault));}
else
{datstart=new Date();}}
else
{datstart=new Date(document.getElementById(strtargetid).value);if(!datstart||isNaN(datstart))
{if(strdefault&&strdefault!='')
{datstart.setTime(Date.parse(strdefault));if(isNaN(datstart))
{datstart=new Date();}}
else
{datstart=new Date();}}}}
datstart.setHours(0,0,0,0);var datprev=new Date();datprev.setTime(datstart.getTime());datprev.setDate(21);datprev.setHours(0,0,0,0);datprev.setTime(datprev.getTime()-(intmonths*32*24*3600*1000));var datnext=new Date();datnext.setTime(datstart.getTime());datnext.setDate(20);datnext.setHours(0,0,0,0);datnext.setTime(datnext.getTime()+(intmonths*32*24*3600*1000));var strcal='';var dat;var i;for(i=0;i<intmonths;i++)
{dat=new Date();datstart.setHours(0,0,0,0);dat.setTime(datstart.getTime());dat.setDate(1);dat.setHours(0,0,0,0);dat.setTime(dat.getTime()+(i*32*24*3600*1000));if(verticalmonth=='NO'&&i==0)
{strcal+='<table><tr><td valign="top">';}
else if(verticalmonth=='NO'&&i>0)
{strcal+='</td><td>';}
if(i==0)
{if(intmonths==1)
{strcal+=BuildMonth(strtargetid,dat,datstart,strformat,datmin,datmax,true,true,strsourceid,intmonths,true,null,datprev,datnext);}
else
{strcal+=BuildMonth(strtargetid,dat,datstart,strformat,datmin,datmax,true,false,strsourceid,intmonths,false,null,datprev,datnext);}}
else if(i>0)
{if(i==intmonths-1)
{strcal+=BuildMonth(strtargetid,dat,datstart,strformat,datmin,datmax,false,true,strsourceid,intmonths,true,null,datprev,datnext);}
else
{strcal+=BuildMonth(strtargetid,dat,datstart,strformat,datmin,datmax,false,false,strsourceid,intmonths,false,null,datprev,datnext);}}
if(verticalmonth=='NO'&&i==intmonths)
{strcal+='</td></tr></table>';}}
document.getElementById(cal_calid).innerHTML=strcal;var leftpos;var toppos;var aTag=document.getElementById(strsourceid);leftpos=document.getElementById(strsourceid).offsetLeft;toppos=document.getElementById(strsourceid).offsetTop+parseInt(document.getElementById(strsourceid).offsetHeight);do
{aTag=aTag.offsetParent;leftpos+=aTag.offsetLeft;toppos+=aTag.offsetTop;}while(aTag.tagName!="BODY");document.getElementById(cal_calid).style.display='block';document.getElementById(cal_calid).style.position='absolute';document.getElementById(cal_calid).style.left=(leftpos+2)+'px';document.getElementById(cal_calid).style.top=(toppos+2)+'px';HideElement('SELECT',cal_calid);HideElement('APPLET',cal_calid);cal_shown=!cal_shown;}
catch(ex)
{alert('ShowCalendar() Error:\n'+ex.message);}}
function BuildMonth(strtargetid,datstart,datsel,strformat,datmin,datmax,blnshowprevcontrol,blnshownextcontrol,strsourceid,intmonths,blnshowclose,verticalmonth,prevmonth,nextmonth)
{try
{var datcurr;var datnext;var datnext;var strout;var blnsamemonth;var i;strout='';if(datsel)
{datsel=new Date(datsel);}
datstart=new Date(datstart);datmin=new Date(datmin);datmax=new Date(datmax);datcurr=new Date();datstart.setHours(0,0,0,0);datcurr.setTime(datstart.getTime());datcurr.setDate(1);if(blnshowprevcontrol)
{datprev=prevmonth;}
if(blnshownextcontrol)
{datnext=nextmonth;}
strout+='<table cellpadding="0" cellspacing="0" border="0" class="cal_calendar" width="150" height="150" style="padding: 0px 0px 0px 0px;">';strout+='<tr><td colspan="7" width="100%"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';if(blnshowprevcontrol)
{strout+='<td class="cal_month">';strout+='<a href="javascript:{}" onclick="cal_shown=true;ShowCalendar(\''+strsourceid+'\', \''+strtargetid+'\', \''+strformat+'\', \''+intmonths+'\', \''+FormatDate(datmin,'dd MMM yyyy')+'\', \''+FormatDate(datmax,'dd MMM yyyy')+'\', \''+FormatDate(datprev,'dd MMM yyyy')+'\',\''+verticalmonth+'\');" onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datprev,'MMMM yyyy')+'\', event);" style="cursor: pointer;"><</a>';strout+='</td>';}
else
{strout+='<td class="cal_month"> </td>';}
strout+='<td width="68" class="cal_month" style="text-align: center;"> '+FormatDate(datcurr,'MMMM')+' </td>';strout+='<td class="cal_month"> </td>';strout+='<td class="cal_year">';strout+=' '+FormatDate(datcurr,'yyyy')+' ';strout+='</td>';if(blnshownextcontrol)
{strout+='<td class="cal_month">';strout+='<a href="javascript:{}" onclick="cal_shown=true;ShowCalendar(\''+strsourceid+'\', \''+strtargetid+'\', \''+strformat+'\', \''+intmonths+'\', \''+FormatDate(datmin,'dd MMM yyyy')+'\', \''+FormatDate(datmax,'dd MMM yyyy')+'\', \''+FormatDate(datnext,'dd MMM yyyy')+'\',\''+verticalmonth+'\');" onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datnext,'MMMM yyyy')+'\', event);" style="cursor: pointer;">></a>';strout+='</td>';}
else
{strout+='<td class="cal_month"> </td>';}
strout+='</tr></table></td></tr>';strout+='<tr><td class="cal_weekday">S</td><td class="cal_weekday">M</td><td class="cal_weekday">T</td><td class="cal_weekday">W</td><td class="cal_weekday">T</td><td class="cal_weekday">F</td><td class="cal_weekday">S</td></tr>'
strout+='<tr>';i=0;if(datcurr.getDay()!=0)
{for(i=0;i<datcurr.getDay();i++)
{strout+='<td> </td>';}}
blnsamemonth=true;while(blnsamemonth)
{if(i%7==0)
{strout+='</tr><tr>';}
if(FormatDate(datcurr,"yyyy-MM-dd")>FormatDate(datmax,"yyyy-MM-dd")||FormatDate(datcurr,"yyyy-MM-dd")<FormatDate(datmin,"yyyy-MM-dd"))
{strout+='<td class="cal_nodate" width="14%" '+((FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(new Date(),"yyyy-MM-dd"))?' style="color: red;" ':'')+'>'+datcurr.getDate()+'</td>';}
else
{if(datsel&&FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(datsel,"yyyy-MM-dd"))
{if(FormatDate(datcurr,'yyyy-MM-dd')==FormatDate(document.getElementById(strtargetid).value,'yyyy-MM-dd'))
{strout+='<td class="cal_dateselected" width="14%" '+((FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(new Date(),"yyyy-MM-dd"))?' style="color: red;" ':'')+' onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datcurr,strformat)+'\', event);" onclick="cal_shown=true;document.getElementById(\''+strtargetid+'\').value=\''+FormatDate(datcurr,strformat)+'\';if (document.getElementById(\''+strtargetid+'\').onblur) {document.getElementById(\''+strtargetid+'\').onblur();} if (document.getElementById(\''+strtargetid+'\').onchange) {document.getElementById(\''+strtargetid+'\').onchange();} HideCalendar();">'+datcurr.getDate()+'</td>';}
else
{strout+='<td class="cal_date" width="14%" '+((FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(new Date(),"yyyy-MM-dd"))?' style="color: red;" ':'')+' onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datcurr,strformat)+'\', event);" onclick="cal_shown=true;document.getElementById(\''+strtargetid+'\').value=\''+FormatDate(datcurr,strformat)+'\';if (document.getElementById(\''+strtargetid+'\').onblur) {document.getElementById(\''+strtargetid+'\').onblur();} if (document.getElementById(\''+strtargetid+'\').onchange) {document.getElementById(\''+strtargetid+'\').onchange();} HideCalendar();">'+datcurr.getDate()+'</td>';}}
else
{if(FormatDate(datcurr,'yyyy-MM-dd')==FormatDate(document.getElementById(strtargetid).value,'yyyy-MM-dd'))
{strout+='<td class="cal_dateselected" width="14%" '+((FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(new Date(),"yyyy-MM-dd"))?' style="color: red;" ':'')+' onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datcurr,strformat)+'\', event);" onclick="cal_shown=true;document.getElementById(\''+strtargetid+'\').value=\''+FormatDate(datcurr,strformat)+'\';if (document.getElementById(\''+strtargetid+'\').onblur) {document.getElementById(\''+strtargetid+'\').onblur();} if (document.getElementById(\''+strtargetid+'\').onchange) {document.getElementById(\''+strtargetid+'\').onchange();} HideCalendar();">'+datcurr.getDate()+'</td>';}
else
{strout+='<td class="cal_date" width="14%" '+((FormatDate(datcurr,"yyyy-MM-dd")==FormatDate(new Date(),"yyyy-MM-dd"))?' style="color: red;" ':'')+' onmouseout="CalInfo(\'\', event);" onmousemove="CalInfo(\''+FormatDate(datcurr,strformat)+'\', event);" onclick="cal_shown=true;document.getElementById(\''+strtargetid+'\').value=\''+FormatDate(datcurr,strformat)+'\';if (document.getElementById(\''+strtargetid+'\').onblur) {document.getElementById(\''+strtargetid+'\').onblur();} if (document.getElementById(\''+strtargetid+'\').onchange) {document.getElementById(\''+strtargetid+'\').onchange();} HideCalendar();">'+datcurr.getDate()+'</td>';}}}
datnext=new Date();datcurr.setHours(0,0,0,0);datnext.setTime(datcurr.getTime()+(1000*3600*26));datnext.setHours(0,0,0,0);if(datnext.getMonth()!=datcurr.getMonth())
{blnsamemonth=false;}
datcurr.setHours(0,0,0,0);datcurr.setTime(datcurr.getTime()+(1000*3600*26));datcurr.setHours(0,0,0,0);i++;}
strout+='</tr>';if(blnshowclose)
{strout+='<tr><td colspan="7" align="center"><a href="javascript:{}" style="cursor: pointer;" onmousemove="CalInfo(\'Close Calendar\', event);" onmouseout="CalInfo(\'\', event);" onclick="HideCalendar();">[Close]</td></tr>';}
strout+='</table>';return strout;}
catch(ex)
{if(ex.message)
alert('BuildMonth() Error:\n'+ex.message);else
alert('BuildMonth() Error:\n'+ex);}}
function HideCalendar()
{document.getElementById(cal_calid).style.display='none';CalInfo('',null);ShowElement('SELECT');ShowElement('APPLET');}
function GetMouseX(evt)
{try
{if(ie)
{if(!evt)
evt=window.event;if(evt)
return(ie?(evt.clientX+document.body.scrollLeft):evt.pageX);}
else
{if(evt.pageX)
return evt.pageX;else if(evt.clientX)
return evt.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);else
return null;}}
catch(ex)
{}}
function GetMouseY(evt)
{try
{if(ie)
{if(!evt)
evt=window.event;if(evt)
return(ie?(evt.clientY+document.body.scrollTop):evt.pageY);}
else
{if(evt.pageY)
return evt.pageY;else if(evt.clientY)
return evt.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);else
return null;}}
catch(ex)
{}}
function CalInfo(strmessage,evt)
{if(strmessage=='')
{document.getElementById('calinfo').style.display='none';}
else
{document.getElementById('calinfo').innerHTML=strmessage;document.getElementById('calinfo').style.position='absolute';document.getElementById('calinfo').style.left=(GetMouseX(evt)+12)+'px';document.getElementById('calinfo').style.top=(GetMouseY(evt)+12)+'px';document.getElementById('calinfo').style.display='block';}
SetStatus(strmessage);}
function SetStatus(strmessage)
{window.status=strmessage;}
