function dom_browser(){this.myNav=this.navigator;this.version=this.navigator.appVersion;this.name=this.navigator.appName;this.userAgt=this.navigator.userAgent;this.ns4=(document.layers)?true:false;this.ns6=(this.navigator.userAgent.indexOf("Netscape6")!=-1)?true:false;this.dom=(document.getElementById)?true:false;this.ie4=(document.all)?true:false;this.mac=(this.version.indexOf("Mac")!=-1)?true:false;this.ie=(this.version.indexOf("MSIE")!=-1)?true:false;this.windows=(this.version.indexOf("Windows")!=-1)?true:false;this.hasPlugins=(this.navigator.plugins)?true:false;this.ie6=(this.version.indexOf("MSIE")!=-1&&this.version.indexOf("6")!=-1)?true:false;this.ie55=(this.version.indexOf("MSIE 5.5")!=-1)?true:false;this.ie5=(this.version.indexOf("MSIE 5.01")!=-1)?true:false;this.ns=(this.userAgt.indexOf("Netscape")!=-1)?true:false;this.ff=(this.userAgt.indexOf("Firefox")!=-1)?true:false;this.safari=(this.userAgt.indexOf("Safari")!=-1)?true:false;}
dom_browser();function trim(str){return str.replace(/^\s*|\s*$/g,"");}
function addClassName(myElement,myClass){var currentClassName=trim(myElement.className);var myReg=new RegExp("(^"+myClass+"$)|( "+myClass+"$)|(^"+myClass+" )|( "+myClass+" )","g");if(!myReg.test(currentClassName)){if(currentClassName!=""){myElement.className+=" "+myClass;}else{myElement.className=myClass;}}}
function removeClassName(myElement,myClass){var currentClassName=trim(myElement.className);var myReg=new RegExp("(^"+myClass+"$)|( "+myClass+"$)|(^"+myClass+" )|( "+myClass+" )","g");myElement.className=currentClassName.replace(myReg,"");}
function switchClassName(myElement,removeClass,addClass){removeClassName(myElement,removeClass);addClassName(myElement,addClass);}
function hasClassName(myElement,myClass){var currentClassName=trim(myElement.className);var myReg=new RegExp("(^"+myClass+"$)|( "+myClass+"$)|(^"+myClass+" )|( "+myClass+" )","g");if(myReg.test(currentClassName)){return true;}else{return false;}}
function getQueryStringValue(myUrl,myKey){var myTempArray=myUrl.split("?");if(myTempArray.length>1){var myTemp2Array=myTempArray[1].split("&");var myTemp3Array=Array();for(var i=0;i<myTemp2Array.length;i++){myTemp3Array=myTemp2Array[i].split("=");if(myTemp3Array[0]==myKey){return myTemp3Array[1];}}
return"";}else{return null;}}
function wn_formValidator(myFormId){this.myForm=document.getElementById(myFormId);this.listen=function(evnt,elem,func){if(elem.addEventListener)
elem.addEventListener(evnt,func,false);else if(elem.attachEvent){var r=elem.attachEvent("on"+evnt,func);return r;}}
this.checkEmail=function(myEmail){var myReg=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i;if(myReg.test(myEmail)){return true;}else{return false;}}
this.showError=function(myErrorObj,myMessage){try{myErrorObj.style.display="block";myErrorObj.innerHTML+=myMessage+" ";}catch(Exception){}}
this.clearErrors=function(){try{myErrorObj=document.getElementById(this.myForm.id+"_error");myErrorObj.innerHTML="";myErrorObj.style.display="none";}catch(Exception){}}
this.checkForm=function(){var errorFound=false;var showGenericError=true;var isMandatory=false;this.clearErrors();for(var i=0;i<this.myForm.elements.length;i++){try{if(this.myForm.elements[i].type=="radio"){myErrorElement=document.getElementById(this.myForm.elements[i].name+"_error");}else{myErrorElement=document.getElementById(this.myForm.elements[i].id+"_error");}
if(myErrorElement!=null&&typeof(myErrorElement)!="undefined"){myErrorElement.innerHTML="";}
if(hasClassName(this.myForm.elements[i],"mandatory")){isMandatory=true;switch(this.myForm.elements[i].type){case"text":if(this.myForm.elements[i].value==""){this.showError(myErrorElement,"Required.");errorFound=true;}
break;case"select":case"select-one":if(this.myForm.elements[i].options[this.myForm.elements[i].options.selectedIndex].value==""){this.showError(myErrorElement,"Required.");errorFound=true;}
break;case'radio':var radioSelected=false;if(!this.myForm.elements[i].checked){var radioElement=this.myForm.elements[i].name;for(k=0;k<this.myForm.elements.length;k++){if(radioElement==this.myForm.elements[k].name&&i!=k){if(this.myForm.elements[k].checked){radioSelected=true;}}}
if(radioSelected==false){if(myErrorElement)this.showError(myErrorElement,"You are required to make a selection.");errorFound=true;}}
break;default:}}else{isMandatory=false;}
if(hasClassName(this.myForm.elements[i],"integer")){var integerRegExp=/^[\d]+$/;if(!(!isMandatory&&this.myForm.elements[i].value=="")){if(!this.myForm.elements[i].value.match(integerRegExp)){try{this.showError(myErrorElement,"Must be a valid number. ");}catch(Exception){}
errorFound=true;}}}
if(hasClassName(this.myForm.elements[i],"email")){var emailRegExp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;if(!(!isMandatory&&this.myForm.elements[i].value=="")){var myTempEmail=this.myForm.elements[i].value;if(!emailRegExp.test(myTempEmail)){this.showError(myErrorElement,"Please supply a valid email address.");errorFound=true;}}}
if(hasClassName(this.myForm.elements[i],"custom")){var customRegExp=this.myForm.elements[i].rel;if(!(!isMandatory&&this.myForm.elements[i].value=="")){var myTempValue=this.myForm.elements[i].value;if(!customRegExp.test(myTempValue)){this.showError(myErrorElement,"Custom error");errorFound=true;}}}}catch(Exception){}}
if(errorFound){var errorObj=document.getElementById(this.myForm.id+"_error");if(showGenericError&&errorObj)this.showError(errorObj,"Please fill out all fields as marked below.");return false;}
return true;}}
function qp_changeRegionDesc(myObj){if((myObj.value=='Worldwide including')||(myObj.value=='Worldwide excluding')){document.getElementById('qp5_regionDesc').innerHTML="USA, Canada, Japan & the Caribbean";}else if(myObj.value=='Europe'){document.getElementById('qp5_regionDesc').innerHTML="Countries of both Eastern & Western Europe";}}
function initDates(){var myStartDate=getQueryStringValue(location.href,"startdate");if(myStartDate==null||myStartDate==""){myStartDate=new Date();}
var myStartDay=myStartDate.getDate();var myStartMonth=myStartDate.getMonth()+1;var myStartYear=myStartDate.getFullYear();var myEndDate=getQueryStringValue(location.href,"enddate");if(myEndDate==null||myEndDate==""){myEndDate=new Date();myEndDate.setDate(myEndDate.getDate()+13);}
var myEndDay=myEndDate.getDate();var myEndMonth=myEndDate.getMonth()+1;var myEndYear=myEndDate.getFullYear();if(document.getElementById("qp1_startday")!=null){setDateObjects(document.getElementById("qp1_startday"),document.getElementById("qp1_startmonth"),document.getElementById("qp1_startyear"),myStartDay,myStartMonth,myStartYear);}
if(document.getElementById("qp1_endday")!=null){setDateObjects(document.getElementById("qp1_endday"),document.getElementById("qp1_endmonth"),document.getElementById("qp1_endyear"),myEndDay,myEndMonth,myEndYear);}
if(document.getElementById("qp3_startday")!=null){setDateObjects(document.getElementById("qp3_startday"),document.getElementById("qp3_startmonth"),document.getElementById("qp3_startyear"),myStartDay,myStartMonth,myStartYear);}
if(document.getElementById("qp3_endday")!=null){setDateObjects(document.getElementById("qp3_endday"),document.getElementById("qp3_endmonth"),document.getElementById("qp3_endyear"),myEndDay,myEndMonth,myEndYear);}
if(document.getElementById("qp5_startday")!=null){setDateObjects(document.getElementById("qp5_startday"),document.getElementById("qp5_startmonth"),document.getElementById("qp5_startyear"),myStartDay,myStartMonth,myStartYear);}
if(document.getElementById("qp5_endday")!=null){setDateObjects(document.getElementById("qp5_endday"),document.getElementById("qp5_endmonth"),document.getElementById("qp5_endyear"),myEndDay,myEndMonth,myEndYear);}}
function setDateObjects(myDayObj,myMonthObj,myYearObj,myDayValue,myMonthValue,myYearValue){for(i=0;i<myDayObj.options.length;i++){if(myDayObj.options[i].value==myDayValue){myDayObj.options[i].selected=true;break;}}
for(i=0;i<myMonthObj.options.length;i++){if(myMonthObj.options[i].value==myMonthValue){myMonthObj.options[i].selected=true;break;}}
for(i=0;i<myYearObj.options.length;i++){if(myYearObj.options[i].value==myYearValue){myYearObj.options[i].selected=true;break;}}}
function qp_setRegionOptions(myValue){myObj=document.getElementById("qp1_region");if(myObj!=null&&typeof(myObj)!="undefined"){if(myValue=="australia"){for(i=0;i<myObj.options.length;i++){if(myObj.options[i].value=="newzealand"){myObj.options[i].value="australia";myObj.options[i].text="Australia Only";break;}}}else{if(myValue=="newzealand"){for(i=0;i<myObj.options.length;i++){if(myObj.options[i].value=="australia"){myObj.options[i].value="newzealand";myObj.options[i].text="New Zealand Only";break;}}}}}}
function initRegion(){myObj=document.getElementById("qp1_country_aus");if(myObj!=null&&typeof(myObj)!="undefined"){if(myObj.checked){qp_setRegionOptions('australia');}else{myObj=document.getElementById("qp1_country_nz");if(myObj!=null&&typeof(myObj)!="undefined"&&myObj.checked){qp_setRegionOptions('newzealand');}}}}
function qp_initForm(myFormId){myForm=document.getElementById(myFormId);for(i=0;i<myForm.elements.length;i++){myElement=myForm.elements[i];myQSValue=getQueryStringValue(location.href,myElement.name);if(myQSValue!=null&&myQSValue!=""){try{switch(myElement.type){case"select":case"select-one":for(j=0;j<myElement.options.length;j++){if(myElement.options[j].value==myQSValue){myElement.options[j].selected="selected";break;}}
break;case"radio":case"checkbox":if(myElement.value==myQSValue){myElement.checked="checked";}
break;case"text":case"hidden":default:myElement.value=myQSValue;}}catch(Exception){}}}}
function qp_addToQS(myQS,myElement){try{switch(myElement.type){case"select":case"select-one":myQS+="&"+escape(myElement.name)+"="+escape(myElement.options[myElement.options.selectedIndex].value);break;case"radio":if(myElement.checked){myQS+="&"+escape(myElement.name)+"="+escape(myElement.value);}
break;case"checkbox":if(myElement.checked){myQS+="&"+escape(myElement.name)+"="+escape(myElement.value);}
break;case"text":case"hidden":default:myQS+="&"+escape(myElement.name)+"="+escape(myElement.value);}}catch(Exception){}
return myQS;}
function qp_jsSubmit(myFormTypeId,openInNewWindow){myFormExtension="qp"+myFormTypeId+"_";myForm=document.getElementById(myFormExtension+"form");if(openInNewWindow==null)openInNewWindow=true;myQS="?";if(myForm!=null&&typeof(myForm)!="undefined"){try{myValidator=eval(myFormExtension+"form_fv");}catch(exception){myValidator=null;}
if(myValidator!=null&&typeof(myValidator)!="undefined"){if(myValidator.checkForm()){myForm.submit(true);return;}else{return;}}else{myForm.submit(true);return;}}else{formFound=false;for(i=0;i<document.forms.length;i++){for(j=0;j<document.forms[i].elements.length;j++){if(document.forms[i].elements[j].id.substr(0,myFormExtension.length)==myFormExtension){formFound=true;myElement=document.forms[i].elements[j];myQS=qp_addToQS(myQS,myElement);}}
if(formFound){break;}}
if(!formFound){myElements=document.getElementsByTagName("input");for(i=0;i<myElements.length;i++){if(myElements[i].id.substr(0,myFormExtension.length)==myFormExtension){myElement=myElements[i];myQS=qp_addToQS(myQS,myElement);}}}
if(myQS!="?"){mySubmitUrlObj=document.getElementById(myFormExtension+"submiturl");myUrl="";if(mySubmitUrlObj!=null&&mySubmitUrlObj!="undefined"){myUrl=mySubmitUrlObj.value;if(myUrl.indexOf("?")>0){myUrl+="&"+myQS.substr(1);}else{myUrl+=myQS;}}else{alert("No submit url is found in page. Field must have id = '"+myFormExtension+"submiturl' and value of the insurance quote path.");return false;}
try{myValidator=eval(myFormExtension+"form_fv");}catch(exception){myValidator=null;}
if(myValidator!=null&&typeof(myValidator)!="undefined"){if(myValidator.checkForm()){if(openInNewWindow){myWin=window.open(myUrl,"myWin","");}else{location.href=myUrl;}
return;}}else{if(openInNewWindow){myWin=window.open(myUrl,"myWin","");}else{location.href=myUrl;}
return;}}else{alert("Could not build request string for quote path.  Please check all fields are correct in page for the insurance system.");return;}}}
var qp_durationKeys=Array();qp_durationKeys[3]=Array();qp_durationKeys[3]['1d']="1 day";qp_durationKeys[3]['2d']="2 days";qp_durationKeys[3]['3d']="3 days";qp_durationKeys[3]['4d']="4 days";qp_durationKeys[3]['5d']="5 days";qp_durationKeys[3]['6d']="6 days";qp_durationKeys[3]['1w']="1 week";qp_durationKeys[3]['2w']="2 weeks";qp_durationKeys[3]['3w']="3 weeks";qp_durationKeys[3]['4w']="4 weeks";qp_durationKeys[3]['5w']="5 weeks";qp_durationKeys[3]['6w']="6 weeks";qp_durationKeys[3]['7w']="7 weeks";qp_durationKeys[3]['2m']="2 months";qp_durationKeys[3]['3m']="3 months";qp_durationKeys[3]['4m']="4 months";qp_durationKeys[3]['5m']="5 months";qp_durationKeys[3]['6m']="6 months";qp_durationKeys[3]['7m']="7 months";qp_durationKeys[3]['8m']="8 months";qp_durationKeys[3]['9m']="9 months";qp_durationKeys[3]['10m']="10 months";qp_durationKeys[3]['11m']="11 months";qp_durationKeys[3]['12m']="12 months";qp_durationKeys[3]['13m']="13 months";qp_durationKeys[3]['14m']="14 months";qp_durationKeys[3]['15m']="15 months";qp_durationKeys[3]['16m']="16 months";qp_durationKeys[3]['17m']="17 months";qp_durationKeys[3]['18m']="18 months";var qp_durations=Array();qp_durations[3]=Array();qp_durations[3]['USA']=Array('1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m');qp_durations[3]['CAN']=Array('2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m');qp_durations[3]['NZL']=Array('1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m','13m','14m','15m','16m','17m','18m');qp_durations[3]['AUS']=Array('1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m','13m','14m','15m','16m','17m','18m');qp_durations[3]['GBR']=Array('1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m','13m','14m','15m','16m','17m','18m');qp_durations[3]['IRL']=Array('3d','5d','1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m','13m','14m','15m','16m','17m','18m');qp_durations[3]['default']=Array('2d','3d','5d','1w','2w','3w','4w','5w','6w','7w','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m');var qp_coverageKeys=Array();qp_coverageKeys[3]=Array();qp_coverageKeys[3]['including']="Worldwide - inc. USA, Canada & Japan";qp_coverageKeys[3]['excluding']="Worldwide - ex. USA, Canada & Japan";qp_coverageKeys[3]['including2']="Worldwide - inc. USA, Canada, The Caribbean & Japan";qp_coverageKeys[3]['excluding2']="Worldwide - ex. USA, Canada, The Caribbean & Japan";var qp_coverage=Array();qp_coverage[3]=Array();qp_coverage[3]['AUS']=Array('including','excluding');qp_coverage[3]['NZL']=Array('including','excluding');qp_coverage[3]['GBR']=Array('including2','excluding2');qp_coverage[3]['IRL']=Array('including2','excluding2');qp_coverage[3]['default']=Array();var qp_provinceKeys=Array();qp_provinceKeys[3]=Array();qp_provinceKeys[3][""]="Select your Province";qp_provinceKeys[3]["AB"]="Alberta";qp_provinceKeys[3]["BC"]="British Columbia";qp_provinceKeys[3]["MB"]="Manitoba";qp_provinceKeys[3]["NB"]="New Brunswick";qp_provinceKeys[3]["NL"]="Newfoundland and Labrador";qp_provinceKeys[3]["NT"]="Northwest Territories";qp_provinceKeys[3]["NS"]="Nova Scotia";qp_provinceKeys[3]["NU"]="Nunavut";qp_provinceKeys[3]["ON"]="Ontario";qp_provinceKeys[3]["PE"]="Prince Edward Island";qp_provinceKeys[3]["QC"]="Quebec";qp_provinceKeys[3]["SK"]="Saskatchewan";qp_provinceKeys[3]["YT"]="Yukon";var qp_province=Array();qp_province[3]=Array();qp_province[3]['CAN']=Array('AB','BC','MB','NB','NL','NT','NS','NU','ON','PE','QC','SK','YT');qp_province[3]['default']=Array();function qp_getQuotePanelTypeId(myObj){var myId=myObj.id.substr(2,(myObj.id.indexOf('_')-2));return myId;}
function qp_setDurationsBasedOnCountry(myObj){myId=qp_getQuotePanelTypeId(myObj);var myDurationObj=document.getElementById('qp'+myId+'_duration');var myCurrentSelectedValue=myDurationObj.options[myDurationObj.options.selectedIndex].value;myTotal=myDurationObj.options.length;for(i=0;i<myTotal;i++){myDurationObj.options[0]=null;}
if(qp_durations[myId]!=null){myOptions=qp_durations[myId][myObj.options[myObj.options.selectedIndex].value];if(myOptions==null){myOptions=qp_durations[myId]['default'];}
for(i=0;i<myOptions.length;i++){myOption=new Option;myOption.value=myOptions[i];myOption.text=qp_durationKeys[myId][myOptions[i]];if(myOption.value==myCurrentSelectedValue){myOption.selected="selected";}
myDurationObj.options.add(myOption);}}}
function qp_setCoverageBasedOnCountry(myObj){myId=qp_getQuotePanelTypeId(myObj);var myCoverageObj=document.getElementById('qp'+myId+'_coverage');try{var myCurrentSelectedValue=myCoverageObj.options[myCoverageObj.options.selectedIndex].value;myTotal=myCoverageObj.options.length;for(i=0;i<myTotal;i++){myCoverageObj.options[0]=null;}}catch(exception){}
if(qp_coverage[myId]!=null){myOptions=qp_coverage[myId][myObj.options[myObj.options.selectedIndex].value];if(myOptions==null){myOptions=qp_coverage[myId]['default'];}
if(myOptions.length==0){switchClassName(myCoverageObj.parentNode,"show","hide");}else{switchClassName(myCoverageObj.parentNode,"hide","show");for(i=0;i<myOptions.length;i++){myOption=new Option;myOption.value=myOptions[i];myOption.text=qp_coverageKeys[myId][myOptions[i]];if(myOption.value==myCurrentSelectedValue){myOption.selected="selected";}
myCoverageObj.options.add(myOption);}}}}
function qp_setProvinceBasedOnCountry(myObj){myId=qp_getQuotePanelTypeId(myObj);var myProvinceObj=document.getElementById('qp'+myId+'_province');try{var myCurrentSelectedValue=myProvinceObj.options[myProvinceObj.options.selectedIndex].value;myTotal=myProvinceObj.options.length;for(i=0;i<myTotal;i++){myProvinceObj.options[0]=null;}}catch(exception){}
if(qp_province[myId]!=null){myOptions=qp_province[myId][myObj.options[myObj.options.selectedIndex].value];if(myOptions==null){myOptions=qp_province[myId]['default'];}
if(myOptions.length==0){switchClassName(myProvinceObj.parentNode,"show","hide");}else{switchClassName(myProvinceObj.parentNode,"hide","show");for(i=0;i<myOptions.length;i++){myOption=new Option;myOption.value=myOptions[i];myOption.text=qp_provinceKeys[myId][myOptions[i]];if(myOption.value==myCurrentSelectedValue){myOption.selected="selected";}
myProvinceObj.options.add(myOption);}}}}
function qp_setInfoBasedOnCountry(myObj){myId=qp_getQuotePanelTypeId(myObj);myCountryCode=myObj.options[myObj.options.selectedIndex].value;myInfoContainer=document.getElementById("qp"+myId+"_info");if(myInfoContainer!=null&&typeof(myInfoContainer)!="undefined"){for(i=0;i<myInfoContainer.childNodes.length;i++){tempObj=myInfoContainer.childNodes[i];if(tempObj.nodeType!=3&&tempObj.className!=""){if(hasClassName(tempObj,"qp_info_"+myCountryCode+"_not")){try{$(tempObj).hide();}catch(exception){addClassName(tempObj,"hide");}}else if(hasClassName(tempObj,"qp_info_"+myCountryCode)){try{$(tempObj).show();var collapseElement=$(tempObj).nextAll('.collapse');collapseElement.slideDown('normal');}catch(exception){removeClassName(tempObj,"hide");}}else if(hasClassName(tempObj,"qp_info_all_not")){try{$(tempObj).hide();}catch(exception){addClassname(tempObj,"hide");}}else{try{$(tempObj).show();}catch(exception){removeClassName(tempObj,"hide");}}}}}}
function toggleExtra(myClickedItem,keepOpen){var myObj=document.getElementById(myClickedItem.id+"_extra");if(myObj!=null&&typeof(myObj)!="undefined"){if(keepOpen==null){keepOpen=true;}else{if(!keepOpen){if(myClickedItem.id.indexOf("_")>0){var groupId=myClickedItem.id.substr(0,myClickedItem.id.indexOf("_"));var groupIdLength=groupId.length;var myElements=document.getElementsByTagName(myObj.nodeName);for(i=0;i<myElements.length;i++){if(myElements[i].id!=null){if(myElements[i]!=myObj&&myElements[i].id.substr(0,groupIdLength)==groupId){if(myElements[i].id.substr(myElements[i].id.length-6)=="_extra"){switchClassName(myElements[i],"show","hide");}}}}}}}
if(myClickedItem.checked==null){if(hasClassName(myObj,"hide")){switchClassName(myObj,"hide","show");}else{switchClassName(myObj,"show","hide");}}else{if(myClickedItem.checked==true){switchClassName(myObj,"hide","show");}else{switchClassName(myObj,"show","hide");}}}}
var A_TCALDEF={'months':['January','February','March','April','May','June','July','August','September','October','November','December'],'weekdays':['Su','Mo','Tu','We','Th','Fr','Sa'],'yearscroll':true,'weekstart':0,'centyear':70,'imgpath':'common/images/calendar/'}
function f_tcalParseDate(s_date){var re_date=/^\s*(\d{1,2})\/(\d{1,2})\/(\d{2,4})\s*$/;if(!re_date.exec(s_date))
return alert("Invalid date: '"+s_date+"'.\nAccepted format is mm/dd/yyyy.")
var n_day=Number(RegExp.$2),n_month=Number(RegExp.$1),n_year=Number(RegExp.$3);if(n_year<100)
n_year+=(n_year<this.a_tpl.centyear?2000:1900);if(n_month<1||n_month>12)
return alert("Invalid month value: '"+n_month+"'.\nAllowed range is 01-12.");var d_numdays=new Date(n_year,n_month,0);if(n_day>d_numdays.getDate())
return alert("Invalid day of month value: '"+n_day+"'.\nAllowed range for selected month is 01 - "+d_numdays.getDate()+".");return new Date(n_year,n_month-1,n_day);}
function f_tcalGenerDate(d_date){return((d_date.getMonth()<9?'0':'')+(d_date.getMonth()+1)+"/"
+(d_date.getDate()<10?'0':'')+d_date.getDate()+"/"
+d_date.getFullYear());}
function tcal(a_cfg,a_tpl){if(!a_tpl)
a_tpl=A_TCALDEF;if(!window.A_TCALS)
window.A_TCALS=[];if(!window.A_TCALSIDX)
window.A_TCALSIDX=[];this.s_id=a_cfg.id?a_cfg.id:A_TCALS.length;window.A_TCALS[this.s_id]=this;window.A_TCALSIDX[window.A_TCALSIDX.length]=this;this.f_show=f_tcalShow;this.f_hide=f_tcalHide;this.f_toggle=f_tcalToggle;this.f_update=f_tcalUpdate;this.f_relDate=f_tcalRelDate;this.f_parseDate=f_tcalParseDate;this.f_generDate=f_tcalGenerDate;this.s_iconId='tcalico_'+this.s_id;this.e_icon=f_getElement(this.s_iconId);if(!this.e_icon){document.write('<img src="'+a_tpl.imgpath+'cal.gif" id="'+this.s_iconId+'" onclick="A_TCALS[\''+this.s_id+'\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');this.e_icon=f_getElement(this.s_iconId);}
this.a_cfg=a_cfg;this.a_tpl=a_tpl;}
function f_tcalShow(d_date){if(!this.a_cfg.controlname)
throw("TC: control name is not specified");if(this.a_cfg.formname){var e_form=document.forms[this.a_cfg.formname];if(!e_form)
throw("TC: form '"+this.a_cfg.formname+"' can not be found");this.e_input=e_form.elements[this.a_cfg.controlname];}
else
this.e_input=f_getElement(this.a_cfg.controlname);if(!this.e_input||!this.e_input.tagName||this.e_input.tagName!='INPUT')
throw("TC: element '"+this.a_cfg.controlname+"' does not exist in "
+(this.a_cfg.formname?"form '"+this.a_cfg.controlname+"'":'this document'));this.e_div=f_getElement('tcal');if(!this.e_div){this.e_div=document.createElement("DIV");this.e_div.id='tcal';document.body.appendChild(this.e_div);}
this.e_shade=f_getElement('tcalShade');if(!this.e_shade){this.e_shade=document.createElement("DIV");this.e_shade.id='tcalShade';document.body.appendChild(this.e_shade);}
this.e_iframe=f_getElement('tcalIF')
if(b_ieFix&&!this.e_iframe){this.e_iframe=document.createElement("IFRAME");this.e_iframe.style.filter='alpha(opacity=0)';this.e_iframe.id='tcalIF';this.e_iframe.src=this.a_tpl.imgpath+'pixel.gif';document.body.appendChild(this.e_iframe);}
f_tcalHideAll();this.e_icon=f_getElement(this.s_iconId);if(!this.f_update())
return;this.e_div.style.visibility='visible';this.e_shade.style.visibility='visible';if(this.e_iframe)
this.e_iframe.style.visibility='visible';this.e_icon.src=this.a_tpl.imgpath+'no_cal.gif';this.e_icon.title='Close Calendar';this.b_visible=true;}
function f_tcalHide(n_date){if(n_date)
this.e_input.value=this.f_generDate(new Date(n_date));if(!this.b_visible)
return;if(this.e_iframe)
this.e_iframe.style.visibility='hidden';if(this.e_shade)
this.e_shade.style.visibility='hidden';this.e_div.style.visibility='hidden';this.e_icon=f_getElement(this.s_iconId);this.e_icon.src=this.a_tpl.imgpath+'cal.gif';this.e_icon.title='Open Calendar';this.b_visible=false;}
function f_tcalToggle(){return this.b_visible?this.f_hide():this.f_show();}
function f_tcalUpdate(d_date){var d_client=new Date();d_client.setHours(0);d_client.setMinutes(0);d_client.setSeconds(0);d_client.setMilliseconds(0);var d_today=this.a_cfg.today?this.f_parseDate(this.a_cfg.today):d_client;var d_selected=this.e_input.value==''?(this.a_cfg.selected?this.f_parseDate(this.a_cfg.selected):d_today):this.f_parseDate(this.e_input.value);if(!d_date)
d_date=d_selected;else if(typeof(d_date)=='number')
d_date=new Date(d_date);else if(typeof(d_date)=='string')
this.f_parseDate(d_date);if(!d_date)return false;var d_firstday=new Date(d_date);d_firstday.setDate(1);d_firstday.setDate(1-(7+d_firstday.getDay()-this.a_tpl.weekstart)%7);var a_class,s_html='<table class="ctrl"><tbody><tr>'
+(this.a_tpl.yearscroll?'<td'+this.f_relDate(d_date,-1,'y')+' title="Previous Year"><img src="'+this.a_tpl.imgpath+'prev_year.gif" /></td>':'')
+'<td'+this.f_relDate(d_date,-1)+' title="Previous Month"><img src="'+this.a_tpl.imgpath+'prev_mon.gif" /></td><th>'
+this.a_tpl.months[d_date.getMonth()]+' '+d_date.getFullYear()
+'</th><td'+this.f_relDate(d_date,1)+' title="Next Month"><img src="'+this.a_tpl.imgpath+'next_mon.gif" /></td>'
+(this.a_tpl.yearscroll?'<td'+this.f_relDate(d_date,1,'y')+' title="Next Year"><img src="'+this.a_tpl.imgpath+'next_year.gif" /></td></td>':'')
+'</tr></tbody></table><table><tbody><tr class="wd">';for(var i=0;i<7;i++)
s_html+='<th>'+this.a_tpl.weekdays[(this.a_tpl.weekstart+i)%7]+'</th>';s_html+='</tr>';var d_current=new Date(d_firstday);while(d_current.getMonth()==d_date.getMonth()||d_current.getMonth()==d_firstday.getMonth()){s_html+='<tr>';for(var n_wday=0;n_wday<7;n_wday++){a_class=[];if(d_current.getMonth()!=d_date.getMonth())
a_class[a_class.length]='othermonth';if(d_current.getDay()==0||d_current.getDay()==6)
a_class[a_class.length]='weekend';if(d_current.valueOf()==d_today.valueOf())
a_class[a_class.length]='today';if(d_current.valueOf()==d_selected.valueOf())
a_class[a_class.length]='selected';s_html+='<td onclick="A_TCALS[\''+this.s_id+'\'].f_hide('+d_current.valueOf()+')"'+(a_class.length?' class="'+a_class.join(' ')+'">':'>')+d_current.getDate()+'</td>'
d_current.setDate(d_current.getDate()+1);}
s_html+='</tr>';}
s_html+='</tbody></table>';this.e_div.innerHTML=s_html;var n_width=this.e_div.offsetWidth;var n_height=this.e_div.offsetHeight;var n_top=f_getPosition(this.e_icon,'Top')+this.e_icon.offsetHeight;var n_left=f_getPosition(this.e_icon,'Left')-n_width+this.e_icon.offsetWidth;if(n_left<0)n_left=0;this.e_div.style.left=n_left+'px';this.e_div.style.top=n_top+'px';this.e_shade.style.width=(n_width+8)+'px';this.e_shade.style.left=(n_left-1)+'px';this.e_shade.style.top=(n_top-1)+'px';this.e_shade.innerHTML=b_ieFix?'<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.a_tpl.imgpath+'shade_tr.png\', sizingMethod=\'scale\');"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td></tr><tr><td height="'+(n_height-7)+'" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.a_tpl.imgpath+'shade_mr.png\', sizingMethod=\'scale\');"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.a_tpl.imgpath+'shade_bl.png\', sizingMethod=\'scale\');"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.a_tpl.imgpath+'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this.a_tpl.imgpath+'shade_br.png\', sizingMethod=\'scale\');"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td></tr><tbody></table>':'<table><tbody><tr><td rowspan="2" width="6"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td rowspan="2"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td width="7" height="7"><img src="'+this.a_tpl.imgpath+'shade_tr.png"></td></tr><tr><td background="'+this.a_tpl.imgpath+'shade_mr.png" height="'+(n_height-7)+'"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td></tr><tr><td><img src="'+this.a_tpl.imgpath+'shade_bl.png"></td><td background="'+this.a_tpl.imgpath+'shade_bm.png" height="7" align="left"><img src="'+this.a_tpl.imgpath+'pixel.gif"></td><td><img src="'+this.a_tpl.imgpath+'shade_br.png"></td></tr><tbody></table>';if(this.e_iframe){this.e_iframe.style.left=n_left+'px';this.e_iframe.style.top=n_top+'px';this.e_iframe.style.width=(n_width+6)+'px';this.e_iframe.style.height=(n_height+6)+'px';}
return true;}
function f_getPosition(e_elemRef,s_coord){var n_pos=0,n_offset,e_elem=e_elemRef;while(e_elem){n_offset=e_elem["offset"+s_coord];n_pos+=n_offset;e_elem=e_elem.offsetParent;}
if(b_ieMac)
n_pos+=parseInt(document.body[s_coord.toLowerCase()+'Margin']);else if(b_safari)
n_pos-=n_offset;e_elem=e_elemRef;while(e_elem!=document.body){n_offset=e_elem["scroll"+s_coord];if(n_offset&&e_elem.style.overflow=='scroll')
n_pos-=n_offset;e_elem=e_elem.parentNode;}
return n_pos;}
function f_tcalRelDate(d_date,d_diff,s_units){var s_units=(s_units=='y'?'FullYear':'Month');var d_result=new Date(d_date);d_result['set'+s_units](d_date['get'+s_units]()+d_diff);if(d_result.getDate()!=d_date.getDate())
d_result.setDate(0);return' onclick="A_TCALS[\''+this.s_id+'\'].f_update('+d_result.valueOf()+')"';}
function f_tcalHideAll(){try{for(var i=0;i<window.A_TCALSIDX.length;i++)
window.A_TCALSIDX[i].f_hide();}catch(exception){}}
try{f_getElement=document.all?function(s_id){return document.all[s_id]}:function(s_id){return document.getElementById(s_id)};if(document.addEventListener)
window.addEventListener('scroll',f_tcalHideAll,false);if(window.attachEvent)
window.attachEvent('onscroll',f_tcalHideAll);var s_userAgent=navigator.userAgent.toLowerCase(),re_webkit=/WebKit\/(\d+)/i;var b_mac=s_userAgent.indexOf('mac')!=-1,b_ie5=s_userAgent.indexOf('msie 5')!=-1,b_ie6=s_userAgent.indexOf('msie 6')!=-1&&s_userAgent.indexOf('opera')==-1;var b_ieFix=b_ie5||b_ie6,b_ieMac=b_mac&&b_ie5,b_safari=b_mac&&re_webkit.exec(s_userAgent)&&Number(RegExp.$1)<500;}catch(exception){}