var onclick_DateWidget;
var env=new Object();
if(document.all){
env.IsIE=true;
onclick_DateWidget=null;     
}
else if(document.getElementById){
env.IsNet=true;
}
function CalendarPage(dSelectedDate,objParent,sVariableName){
this.selectedDate=dSelectedDate;
this.objParent=objParent;                 
this.variableName=sVariableName;          
this.divObj=null;                         
}
CalendarPage.prototype.butTodayHandler=function(){
this.selectedDate=Date.prototype.TodayMidnight();
this.divObj.innerHTML=this.GetHtml();
};
CalendarPage.prototype.UpdateYear=function(iDiff){
var o=this.selectedDate;
this.selectedDate=new Date(o.getFullYear()+iDiff,o.getMonth(),o.getDate());
if(this.selectedDate<this.objParent.minDate) this.selectedDate=this.objParent.minDate;
if(this.selectedDate>this.objParent.maxDate) this.selectedDate=this.objParent.maxDate;
this.divObj.innerHTML=this.GetHtml();
};
CalendarPage.prototype.UpdateMonth=function(iDiff){
var o=this.selectedDate;
if(o.getDate()<29){
this.selectedDate=new Date(o.getFullYear(),o.getMonth()+iDiff,o.getDate());
}
else{
d=new Date(o.getFullYear(),o.getMonth()+iDiff,1);
n=d.getNumOfMonthDays()
if(n<this.selectedDate.getDate()){
this.selectedDate=new Date(o.getFullYear(),o.getMonth()+iDiff,n);
}
else{
this.selectedDate=new Date(o.getFullYear(),o.getMonth()+iDiff,o.getDate());
}
}
if(this.selectedDate<this.objParent.minDate) this.selectedDate=this.objParent.minDate;
if(this.selectedDate>this.objParent.maxDate) this.selectedDate=this.objParent.maxDate;
this.divObj.innerHTML=this.GetHtml();
};
CalendarPage.prototype.UpdateDate=function(iNewDate){
var o=this.selectedDate;
this.selectedDate=new Date(o.getFullYear(),o.getMonth(),iNewDate);
this.divObj.innerHTML=this.GetHtml();
this.objParent.ChildHasNewDateSelectionEvent(this);                    
};
CalendarPage.prototype.EnforceDateRange=function(sCheckType){
bReturnValue=false;
switch(sCheckType){
case "min month" :
if(this.selectedDate.getFullYear()==this.objParent.minDate.getFullYear() && this.selectedDate.getMonth()==this.objParent.minDate.getMonth()) bReturnValue=true;
break;
case "max month" :
if(this.selectedDate.getFullYear()==this.objParent.maxDate.getFullYear() && this.selectedDate.getMonth()==this.objParent.maxDate.getMonth()) bReturnValue=true;
break;
case "min year" :
if(this.selectedDate.getFullYear()==this.objParent.minDate.getFullYear()) bReturnValue=true;
break;
case "max year" :
if(this.selectedDate.getFullYear()==this.objParent.maxDate.getFullYear()) bReturnValue=true;
break;
}
return bReturnValue;
};
CalendarPage.prototype.GetHtml=function(){
this.objParent.CloseErrorPane();
if(!this.selectedDate) this.selectedDate=Date.prototype.TodayMidnight();                       
if(this.selectedDate<this.objParent.minDate) this.objParent.minDate=this.selectedDate;
if(this.selectedDate>this.objParent.maxDate) this.objParent.maxDate=this.selectedDate;
CalWeekdaysArray=new Array("S","M","T","W","T","F","S")
CalGridArray=new Array(42);
for(i=0;i<CalGridArray.length;i++){ CalGridArray[i]="<span style='cursor:default'>&nbsp;</span>"; }
iDayOffset=this.selectedDate.getDayOnFirstOfTheMonth();
var bIsPartMonth=(this.EnforceDateRange("min month") || this.EnforceDateRange("max month"));   
var y=this.selectedDate.getFullYear();
var m=this.selectedDate.getMonth();
for(i=1;i<=this.selectedDate.getNumOfMonthDays();i++){
if(bIsPartMonth && (new Date(y,m,i)<this.objParent.minDate || new Date(y,m,i)>this.objParent.maxDate)){
CalGridArray[i-1+iDayOffset]="<span class='calenderIllegalDate' style='cursor:default' >" + i + "</span>";
}
else if(i==this.selectedDate.getDate()){
CalGridArray[i-1+iDayOffset]="<span class='calendarSelectedDate' style='cursor:default' >" + i + "</span>";
}
else{
CalGridArray[i-1+iDayOffset]="<span style='cursor:pointer' onclick='CalendarUserInput(" + this.variableName + ",\"new date selection\"," + i + ");' >" + i + "</span>";
}
}
var s="";
s+= "<table class='calendarOuterTable' cellpadding='0' cellspacing='0'>";
s+=   "<tr>";
s+=     "<td nowrap align='center'>";
s+=       "<table class'calendarMonthYearHeadingsTable' cellpadding='0' cellspacing='0'>";
s+=         "<tr class='calendarEntireMonthNameRow'>";
s+=           "<td nowrap width='12'>";
if(this.EnforceDateRange("min month")){
s+=               "<span class='calendarMonthYearArrows'>&nbsp;</span>";
}
else{
s+=               "<span style='cursor:pointer' class='calendarMonthYearArrows' onclick='CalendarUserInput(" + this.variableName + ",\"month update\",-1);' >&lt;&lt;</span>";
}
s+=           "</td>";
s+=           "<td nowrap width='55' align='center'>";
s+=               "<span class='calendarMonthHeadings'>" + this.selectedDate.getMonthName(true) + "</span>";
s+=           "</td>";
s+=           "<td nowrap width='12'>";
if(this.EnforceDateRange("max month")){
s+=               "<span class='calendarMonthYearArrows'>&nbsp;</span>";
}
else{
s+=               "<span style='cursor:pointer' class='calendarMonthYearArrows' onclick='CalendarUserInput(" + this.variableName + ",\"month update\",1);' >&gt;&gt;</span>";
}
s+=           "</td>";
s+=           "<td nowrap>";
s+=             "<span class='calendarMonthHeadings'>&nbsp; &nbsp;</span>";
s+=           "</td>";
s+=           "<td nowrap width='12'>";
if(this.EnforceDateRange("min year")){
s+=               "<span class='calendarMonthYearArrows'>&nbsp;</span>";
}
else{
s+=               "<span style='cursor:pointer' class='calendarMonthYearArrows' onclick='CalendarUserInput(" + this.variableName + ",\"year update\",-1);' >&lt;&lt;</span>";
}
s+=           "</td>";
s+=           "<td nowrap>";
s+=             "<span class='calendarMonthHeadings'>" + this.selectedDate.getFullYear() + "</span>";
s+=           "</td>";
s+=           "<td nowrap width='12'>";
if(this.EnforceDateRange("max year")){
s+=               "<span class='calendarMonthYearArrows'>&nbsp;</span>";
}
else{
s+=               "<span style='cursor:pointer' class='calendarMonthYearArrows' onclick='CalendarUserInput(" + this.variableName + ",\"year update\",1);' >&gt;&gt;</span>";
}
s+=           "</td>";
s+=         "</tr>";
s+=       "</table>";
s+=     "</td>";
s+=   "</tr>";
s+=   "<tr>";
s+=     "<td nowrap>";
s+=       "<table class'calendarGridTable' cellpadding='0' cellspacing='0' width='100%'>";
s+=         "<tr>";
for(i=0;i<CalWeekdaysArray.length;i++){
s+= "<td width='14%' nowrap class='calendarWeekdayCell'>" + CalWeekdaysArray[i] + "</td>";
}
s+= "</tr>";
for(i=0;i<6;i++){
s+= "<tr>";
for(j=0;j<7;j++){
s+= "<td nowrap class='calendarDayCell'>" + CalGridArray[i*7+j] + "</td>";
}
s+= "</tr>";
}
s+=       "</table>";
s+=     "</td>";
s+=   "</tr>";
if(Date.prototype.TodayMidnight()>=this.objParent.minDate && Date.prototype.TodayMidnight()<=this.objParent.maxDate){
s+=   "<tr>";
s+=     "<td nowrap align='center' class='calendarTodayRow'>";
s+=       "<div style='cursor:pointer' class='calendarTodayButton' onclick='CalendarUserInput(" + this.variableName + ",\"today\",0);' >today</div>";
s+=     "</td>";
s+=   "</tr>";
}
s+= "</table>";
return s;
};
function DateWidget(sWidgetType,sObjName,sTagId,dBeginDate,dEndDate){
this.widgetType=sWidgetType;                       
this.myVarName=sObjName;                           
this.htmlObj=document.getElementById(sTagId);      
this.tagId=sTagId;                                 
this.imageFolderPath="/AWC_Common_v2/aspx/Tools/DateWidget/";                    
this.calPane=null;                                 
this.errorPane=null;                               
this.errorMsgDiv=null;                             
this.errorMsg="";                                  
this.friendlyValidationLabel="";                   
this.hiddenFieldName="";
this.fieldRequiredMarkerHtml="<font style='font-size:10pt; font-weight:bold; color:red'><b>*</b></font>";
this.minDate=new Date(1900,0,1);
this.maxDate=new Date(2099,11,31);
this.isRequired=false;
this.beginDate=dBeginDate;
this.beginPage=new CalendarPage(dBeginDate,this,this.myVarName+".beginPage");
if(this.widgetType=="range"){
this.endDate=dEndDate;
this.endPage=new CalendarPage(dEndDate,this,this.myVarName+".endPage");
}
}
DateWidget.prototype.UpdateTextValue=function(){
var sDateInput1="<input class='calendarTextInputBox' type='text' id='"+this.myVarName+"_beginDateInputBox' name='"+this.myVarName+"_beginDateInputBox' size='12' maxlength='10' value='"+ this.GetDateValue(this.beginDate) +"' onchange='"+this.myVarName+".FilterInput(this,\"beginDate\")'>";
if(this.widgetType=="range"){
var sDateInput2="<input class='calendarTextInputBox' type='text' id='"+this.myVarName+"_endDateInputBox' name='"+this.myVarName+"_endDateInputBox' size='12' maxlength='10' value='"+ this.GetDateValue(this.endDate) +"' onchange='"+this.myVarName+".FilterInput(this,\"endDate\")'>";
}
var sCalendarIcon="<img style='cursor:pointer' id='" +this.myVarName+ "_CalendarIcon' name='" +this.myVarName+ "_CalendarIcon' src='"+ this.imageFolderPath +"CalendarIcon.GIF' border='0' align='absbottom'>";
var t="";
t+= "<table cellpadding='0' cellspacing='0' border='0'>";
t+=   "<tr>";
t+=     "<td>";
t+=       "<table cellpadding='0' cellspacing='0' border='0'>";
t+=         "<tr>";
t+=           "<td nowrap class='calendarTextDateFormat'>mm/dd/yyyy</td>";
if(this.widgetType=="range"){
t+=         "<td nowrap class='calendarTextDateFormat'>&nbsp;</td>";
t+=         "<td nowrap class='calendarTextDateFormat'>mm/dd/yyyy</td>";
}
t+=         "</tr>";
t+=       "<tr>";
t+=         "<td nowrap>"+sDateInput1+"</td>";
if(this.widgetType=="range"){
t+=       "<td nowrap class='calendarStringTo'>&nbsp;to&nbsp;</td>";
t+=       "<td nowrap>"+ sDateInput2 +"</td>";
}
t+=       "</tr>";
t+=       "</table>";
t+=     "</td>";
t+=     "<td valign='bottom'><div style='padding:1px 0px'>"+ sCalendarIcon +"</div></td>";
t+=     "<td>&nbsp;"+this.fieldRequiredMarkerHtml+"</td>";
t+=   "</tr>";
t+= "</table>";
this.htmlObj.innerHTML=t;
var s=this.myVarName + "_CalendarIcon"
if(env.IsIE) document.getElementById(s).onclick=CalendarMouseClick;
if(env.IsNet) document.getElementById(s).addEventListener("click",CalendarMouseClick,true);
this.UpdateHiddenField();
};
DateWidget.prototype.CreateGraphicalView=function(){
this.beginPage.selectedDate=this.beginDate;
if(this.widgetType=="range") this.endPage.selectedDate=this.endDate;
x=GetOffsetLeft(document.getElementById(this.tagId),document.body);
y=GetOffsetTop(document.getElementById(this.tagId),document.body)+document.getElementById(this.tagId).offsetHeight;
this.calPane=document.createElement("DIV")
this.calPane.id=this.myVarName + "_CalPane";
this.calPane.style.position="absolute";
this.calPane.style.left=x;
this.calPane.style.top=y;
document.body.appendChild(this.calPane);
if(this.widgetType=="range"){
var c="";
c+= "<div class='mainPanelDiv'>";
c+= "<table class='mainPanelTable' cellpadding='0' cellspacing='0' border='0'>";
c+=   "<tr>";
c+=     "<td nowrap class='mainPanelLabels'>start date:</td>";
c+=     "<td nowrap class='mainPanelLabels'>end date:</td>";
c+=   "</tr>";
c+=   "<tr>";
c+=     "<td nowrap>"
c+=       "<div class='calendarOuterDiv' id='" + this.myVarName + "_BeginPageDiv' name='" + this.myVarName + "_BeginPageDiv'>"
c+=        this.beginPage.GetHtml()
c+=       "</div>"
c+=     "</td>";
c+=     "<td nowrap>"
c+=       "<div class='calendarOuterDiv' id='" + this.myVarName + "_EndPageDiv' name='" + this.myVarName + "_EndPageDiv'>"
c+=        this.endPage.GetHtml()
c+=       "</div>"
c+=     "</td>";
c+=   "</tr>";
c+=   "<tr>";
c+=     "<td nowrap colspan='2' align='center'>";
c+=       "<span style='cursor:pointer' class='mainPanelButtons' onclick='" + this.myVarName + ".butOkHandler();' >ok</span>";
c+=       "<span style='font-size:6px'>&nbsp;&nbsp;</span>";
c+=       "<span style='cursor:pointer' class='mainPanelButtons' onclick='" + this.myVarName + ".butCancelHandler();' >cancel</span>";
c+=     "</td>";
c+=   "</tr>";
c+= "</table>";
c+= "</div>";
this.calPane.innerHTML=c;
this.beginPage.divObj=document.getElementById(this.myVarName + "_BeginPageDiv");
this.endPage.divObj=document.getElementById(this.myVarName + "_EndPageDiv");
}
else{
var c="";
c+= "<div class='mainPanelDiv'>";
c+= "<table class='mainPanelTable' cellpadding='0' cellspacing='0' border='0'>";
c+=   "<tr>";
c+=     "<td nowrap>"
c+=       "<div class='calendarOuterDiv' id='" + this.myVarName + "_BeginPageDiv' name='" + this.myVarName + "_BeginPageDiv'>"
c+=        this.beginPage.GetHtml()
c+=       "</div>"
c+=     "</td>";
c+=   "</tr>";
c+=   "<tr>";
c+=     "<td nowrap colspan='2' align='center'>";
c+=       "<span style='cursor:pointer' class='mainPanelButtons' onclick='" + this.myVarName + ".butOkHandler();' >ok</span>";
c+=       "<span style='font-size:6px'>&nbsp;&nbsp;</span>";
c+=       "<span style='cursor:pointer' class='mainPanelButtons' onclick='" + this.myVarName + ".butCancelHandler();' >cancel</span>";
c+=     "</td>";
c+=   "</tr>";
c+= "</table>";
c+= "</div>";
this.calPane.innerHTML=c;
this.beginPage.divObj=document.getElementById(this.myVarName + "_BeginPageDiv");
}
if(env.IsIE){
var f="";
f+= "if("+this.myVarName+".errorPane){";
f+=   this.myVarName + ".errorPane" + ".removeNode(true);";
f+=   this.myVarName + ".errorMsgDiv=\"\";";
f+=   this.myVarName + ".errorPane=null;";
f+=   "}";
f+= this.myVarName+".calPane.removeNode(true);";
f+= "document.body.detachEvent ('onclick', onclick_DateWidget);";
f+= "onclick_DateWidget=null;";
onclick_DateWidget=new Function(f);
document.body.attachEvent ('onclick', onclick_DateWidget);
var f="";
f+= "window.event.cancelBubble=true;";
f+= this.myVarName + ".CloseErrorPane();";
this.calPane.onclick=new Function(f);
}
if(env.IsNet){
var f="";
f+= "";
f+= "if(!MouseClickIsInObjectArea(e.pageX,e.pageY," + this.myVarName + ".calPane)){";
f+= this.myVarName + ".CloseErrorPane();";
f+= "  document.body.removeChild(" + this.myVarName + ".calPane);";
f+= "  var body=document.getElementsByTagName(\"body\")[0];";
f+= "  body.removeEventListener(\"click\",BodyClick,true);";
f+= "  BodyClick=null;";
f+= "  }";
BodyClick=new Function("e",f);
var body=document.getElementsByTagName("body")[0];
body.addEventListener("click",BodyClick,true);
var f="";
f+= "if("+this.myVarName + ".errorPane){";
f+=   "if(!MouseClickIsInObjectArea(e.pageX,e.pageY," + this.myVarName + ".errorPane)){";
f+=      this.myVarName + ".CloseErrorPane();";
f+=     "}";
f+=   "}";
CalPaneClick=new Function("e",f);
this.calPane.addEventListener("click",CalPaneClick,true);
}
};
DateWidget.prototype.DestroyGraphicalView=function(){
this.CloseErrorPane();
if(env.IsIE){
this.calPane.removeNode(true);
this.calPane=null;
document.body.detachEvent ('onclick', onclick_DateWidget);
onclick_DateWidget=null;
}
if(env.IsNet){
var body=document.getElementsByTagName("body")[0];
document.body.removeChild(this.calPane)
this.calPane=null;
body.removeEventListener("click",BodyClick,true);
BodyClick=null;
}
};
DateWidget.prototype.butOkHandler=function(){
if(!this.errorPane){
if(this.IsValid()){
this.beginDate=this.beginPage.selectedDate;
if(this.widgetType=="range") this.endDate=this.endPage.selectedDate;
this.UpdateTextValue();
this.DestroyGraphicalView();
}
else{
if(env.IsIE) window.event.cancelBubble=true;
this.ShowValidationError();
}
}
else{
if(env.IsIE) window.event.cancelBubble=true;
}
};
DateWidget.prototype.butCancelHandler=function(){
this.DestroyGraphicalView();
};
DateWidget.prototype.IsValid=function(){
this.errorMsg="";
if(this.widgetType=="range"){
if(this.beginPage.selectedDate>this.endPage.selectedDate){
this.errorMsg="Not a valid date range. The 'end date' occurs before the 'start date'.";
return false;
}
}
return true;
};
DateWidget.prototype.ShowValidationError=function(){
x=GetOffsetLeft(this.calPane,document.body);
y=GetOffsetTop(this.calPane,document.body);
this.errorPane=document.createElement("DIV")
this.errorPane.id=this.myVarName+"_ErrorPane";  this.errorPane.style.position="absolute";
this.errorPane.style.left=x;
this.errorPane.style.top=y;
this.errorPane.style.width="250px";
document.body.appendChild(this.errorPane);
var m=""
m+= "<div class='errorPanel'>";
m+= "<table cellpadding='0' cellspacing='0' border='0'>";
m+=   "<tr>";
m+=     "<td><div id='" + this.myVarName + "_ErrorMsgDiv' name='" + this.myVarName + "_ErrorMsgDiv' class='errorText'></div></td>";
m+=     "<td valign='top' align='right'><div id='" + this.myVarName + "_ErrorX' name='" + this.myVarName + "_ErrorX' class='errorCloseX' style='cursor:pointer'>X</div></td>";
m+=   "</tr>";
m+= "</table>";
m+= "</div>";
this.errorPane.innerHTML=m;
this.errorMsgDiv=document.getElementById(this.myVarName + "_ErrorMsgDiv");
this.errorMsgDiv.innerHTML=this.errorMsg
if(env.IsIE){
var f="";
f+= this.myVarName + ".errorPane" + ".removeNode(true);";
f+= this.myVarName + ".errorMsgDiv=\"\";";
f+= this.myVarName + ".errorPane=null;";
f+= "window.event.cancelBubble=true;"
document.getElementById(this.myVarName + "_ErrorX").onclick=new Function(f);
document.getElementById(this.myVarName + "_ErrorPane").onclick=new Function("window.event.cancelBubble=true;");
}
if(env.IsNet){
var f=""
f+= "document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\""+this.myVarName+"_ErrorPane\"));";
f+= this.myVarName + ".errorMsgDiv=\"\";";
f+= this.myVarName + ".errorPane=null;";
ErrorPaneCloseXClick=new Function("e",f);
document.getElementById(this.myVarName + "_ErrorX").addEventListener("click",ErrorPaneCloseXClick,true);
}
};
DateWidget.prototype.CloseErrorPane=function(){
if(this.errorPane){
if(env.IsIE) this.errorPane.removeNode(true);
if(env.IsNet) document.getElementsByTagName("body")[0].removeChild(this.errorPane);
this.errorMsgDiv="";
this.errorPane=null;
}
};
DateWidget.prototype.ChildHasNewDateSelectionEvent=function(objTarget){
if(this.widgetType=="range"){
if(objTarget==this.beginPage && this.endPage.selectedDate<this.beginPage.selectedDate){
this.endPage.selectedDate=this.beginPage.selectedDate;
this.endPage.divObj.innerHTML=this.endPage.GetHtml();
}
}
else{
this.butOkHandler();
}
};
DateWidget.prototype.GetDateValue=function(dDate){
if(dDate) return dDate.toShortFormNumeric();
else return "";
};
DateWidget.prototype.FilterInput=function(objTextBox,sDateObj){
if(this.beginDate){
if(this.beginDate<this.minDate) this.minDate=this.beginDate;
if(this.beginDate>this.maxDate) this.maxDate=this.beginDate;
}
if(this.endDate){
if(this.endDate<this.minDate) this.minDate=this.endDate;
if(this.endDate>this.maxDate) this.maxDate=this.endDate;
}
regEx=/^(\d{1,2})\D(\d{1,2})\D(\d{1,4})$/
AryDateComponent = regEx.exec(objTextBox.value);
if(AryDateComponent){
var y=AryDateComponent[3];
var m=AryDateComponent[1]-1;
var d=AryDateComponent[2];
dDate=new Date(y,m,d);
if(dDate<this.minDate){
alert("The new date cannot occur prior to " + this.minDate.toShortFormText(true) + ".")
dDate=this.minDate;
}
if(dDate>this.maxDate){
alert("The new date cannot occur after " + this.maxDate.toShortFormText(true) + ".")
dDate=this.maxDate;
}
if(sDateObj=="beginDate") this.beginDate=dDate;
else this.endDate=dDate;
y=dDate.getFullYear();
m=dDate.getMonth()+1;
d=dDate.getDate();
objTextBox.value="";
if(m<10) objTextBox.value+= "0";
objTextBox.value+= m;
objTextBox.value+= "/";
if(d<10) objTextBox.value+= "0";
objTextBox.value+= d;
objTextBox.value+= "/";
objTextBox.value+= y;
}
else{
if(objTextBox.value!="") alert("Please enter a valid date.");
objTextBox.value="";
if(sDateObj=="beginDate") this.beginDate=null;
else this.endDate=null;
}
this.UpdateHiddenField();
};
DateWidget.prototype.Validate=function(){
var msg;
if(this.widgetType=="single"){
if(this.isRequired && !this.beginDate){
if(this.friendlyValidationLabel!="") msg="A valid date is required for '"+ this.friendlyValidationLabel +"'.";
else msg="Please provide a valid date.";
alert(msg);
return false;
}
else{
return true;
}
}
if(this.widgetType=="range"){
if( (this.beginDate && !this.endDate) || (!this.beginDate && this.endDate) ){
if(this.friendlyValidationLabel!="") msg="A valid date range is requied for '"+ this.friendlyValidationLabel +"'.";
else msg="Please provide a valid date range.";
alert(msg);
return false;
}
else if(this.isRequired && (!this.beginDate || !this.endDate) ){
if(this.friendlyValidationLabel!="") msg="A valid date range is requied for '"+ this.friendlyValidationLabel +"'.";
else msg="Please provide a valid date range.";
alert(msg);
return false;
}
else{
return true;
}
}
};
DateWidget.prototype.UpdateHiddenField=function(){
sPostValue=""
sPostValue += this.GetDateValue(this.beginDate);
sPostValue += "~"
sPostValue += this.GetDateValue(this.endDate)
document.getElementById(this.hiddenFieldName).value=sPostValue;
};
CalendarMouseClick=function(e){
if(env.IsNet){
srcId=e.target.name;
srcObj=eval(srcId.substring(0,srcId.indexOf("_")));
el=srcObj.CreateGraphicalView();
}
if(env.IsIE){
if(onclick_DateWidget){
window.event.returnValue=false;
}
else{
srcId=window.event.srcElement.name;
window.event.cancelBubble = true;
srcObj=eval(srcId.substring(0,srcId.indexOf("_")));
el=srcObj.CreateGraphicalView();
}
}
};
function CalendarUserInput(objCalendar,sCmd,iValue){
switch(sCmd){
case "year update" :
objCalendar.UpdateYear(iValue);
break;
case "month update" :
objCalendar.UpdateMonth(iValue);
break;
case "new date selection" :
objCalendar.UpdateDate(iValue);
break;    
case "today" :
objCalendar.butTodayHandler();
break;    
}
}
function MouseClickIsInObjectArea(x,y,obj){
var body=document.getElementsByTagName("body")[0];
var x1=GetOffsetLeft(obj,body);
var y1=GetOffsetTop(obj,body);
var x2=obj.offsetWidth+ x1;
var y2=obj.offsetHeight + y1;
return (x>=x1 && x<=x2 && y>=y1 && y<=y2);
}
Date.prototype.getWeekdayName=function(bLongName){
var aryShort=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
var aryLong=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
if(bLongName) return aryLong[this.getDay()];
else return aryShort[this.getDay()];
};
Date.prototype.getMonthName=function(bLongName){
var aryShort=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var aryLong=Array("January","February","March","April","May","June","July","August","September","October","November","December")
if(bLongName) return aryLong[this.getMonth()];
else return aryShort[this.getMonth()];
};
Date.prototype.toShortFormText=function(bLongNames){
var s="";
s+= this.getWeekdayName(bLongNames);
s+= " ";
s+= this.getMonthName(bLongNames);
s+= " ";
s+= this.getDate();
s+= ", ";
s+= this.getFullYear();
return s;
};
Date.prototype.getNumOfMonthDays=function(){
var n;
var aryDaysPerMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if(this.getFullYear()%4==0 && this.getMonth()==1) n=29;
else n=aryDaysPerMonth[this.getMonth()];
return n;
}
Date.prototype.getDayOnFirstOfTheMonth=function(){
var d=new Date(this.getFullYear(),this.getMonth(),1)
return d.getDay();
}
Date.prototype.TodayMidnight=function(){
var d=new Date();
var t=new Date(d.getFullYear(),d.getMonth(),d.getDate());
return t;
}  
Date.prototype.toShortFormNumeric=function(){
y=this.getFullYear();
m=this.getMonth()+1;
d=this.getDate();
var s="";
if(m<10) s+= "0";
s+= m;
s+= "/";
if(d<10) s+= "0";
s+= d;
s+= "/";
s+= y;
return s;
};
function GetOffsetTop(e,container){
var iOffsetTop=e.offsetTop;
if (container==e) return iOffsetTop;
if (e.offsetParent) iOffsetTop=iOffsetTop+GetOffsetTop(e.offsetParent,container);
return iOffsetTop;
}
function GetOffsetLeft(e,container){
var iOffsetLeft=e.offsetLeft;
if (container==e) return iOffsetLeft;
if (e.offsetParent) iOffsetLeft=iOffsetLeft+GetOffsetLeft(e.offsetParent,container);
return iOffsetLeft;
}
function ValidateDateWidgets(){
if(singleDate.Validate() && dateRange.Validate() && dob.Validate() && holiday.Validate()) alert("All dates are valid.");
};
 