var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var monthNames=new Array("January","February","March","April","May","June","July","August","September","October","November","December");function DateRange(c,b,a){this.master=c;this.slave=b;this.range=a;this.master.onDateChange=function(d){slaveStart=new Date(d.getTime()+24*3600000);b.setDateRange(slaveStart,new Date(d.getTime()+a*24*3600000));b.setMonth(slaveStart.getMonth(),slaveStart.getFullYear());b.forced=true;b.text.value=_dateToString(slaveStart)}}function getMonthDays(b,a){if(b==1&&a%4==0){return 29}else{return monthDays[b]}}function _strToInt(a){while(a.charAt(0)==("0")){a=a.substring(1)}while(a.charAt(a.length-1)==" "){a=a.substring(0,a.length-1)}return parseInt(a)}function format_date(d){if(d!=""&&d!="mm/dd/yy"){var c=/\d{1,2}\/\d{1,2}\/\d{1,4}$/;if(!c.test(d)){return"mm/dd/yy"}var b=d.split("/");var e=_strToInt(b[2]);if(e<100){e=e+2000}var a=new Date(e,_strToInt(b[0])-1,_strToInt(b[1]));if((a.getFullYear()!=e)||(a.getDate()!=b[1])||(a.getMonth()!=(_strToInt(b[0])-1))){return"mm/dd/yy"}else{return _dateToString(a)}}else{return"mm/dd/yy"}}function _dateToString(a){return((a.getMonth()+101)+"").substring(1,3)+"/"+((a.getDate()+100)+"").substring(1,3)+"/"+(a.getFullYear()+"").substring(2,4)}function elg_contains(a,b){if(!b||b.tagName=="BODY"){return false}if(a==b){return true}return elg_contains(a,b.parentNode)}function getEventElement(a){var b;a=(a)?a:((window.event)?window.event:null);b=a.target;if(b){if(a.target.nodeType==3){b=a.target.parentNode}}else{if(a.srcElement){b=a.srcElement}}return b}function findCell(a){if(!a){return null}if(a.tagName=="TD"){return a}else{if(a.tagName=="BODY"){return null}else{return findCell(a.parentElement)}}}function findPos(d){var c=0;var b=0;for(var a=d;a&&a.tagName!="BODY";a=a.offsetParent){c+=a.offsetLeft;b+=a.offsetTop}return new Array(c,b)}var loaded=false;function windowLoaded(){loaded=true}if(navigator.appName=="Microsoft Internet Explorer"){if(typeof jQuery!="undefined"){jQuery(document).ready(function(){loaded=true})}else{window.onload=windowLoaded}}else{loaded=true}function ElgCalendar(a){this.id=a;this.posXOffset=0;this.posYOffset=0;function j(t){if(loaded){this.onshowing();if(!this.popup.parentElement){document.body.appendChild(this.popup);this.refresh()}var v=findPos(this.img);this.popup.style.top=(v[1]+24+this.posYOffset)+"px";this.popup.style.left=(v[0]+3+this.posXOffset)+"px";if(this.text.value!=""&&!this.forced){var x=/\d{1,2}\/\d{1,2}\/\d{1,4}$/;if(x.test(this.text.value)){var s=this.text.value.split("/");var w=_strToInt(s[2]);if(w<100){w+=2000}var q=_strToInt(s[0])-1;var u=_strToInt(s[1]);var r=new Date(w,q,u);var p=r.getFullYear();this.year=p;this.month=r.getMonth();this.date=r.getDate();this.selectedDate=r;this.setMonth(this.month,this.year)}}this.popup.style.display="block";if(window.last_popup_calendar&&window.last_popup_calendar!=this){window.last_popup_calendar.close()}window.last_popup_calendar=this}else{alert("Please wait while the calendar initializes.")}}function b(){this.onclosing();this.popup.style.display="none";window.last_popup_calendar=null}function o(){this.clear_selected_cell();this.selectedDate=null;if(this.text){this.text.value=""}}this.calendar=document.getElementById(a);this.calendar.owner=this;this.img=document.getElementById(a+"_img");if(this.img){this.img.owner=this;this.img.onclick=function(q){q=(q)?q:((window.event)?window.event:null);var p=getEventElement(q);p.owner.show(q)}}this.text=document.getElementById(a+"_date");if(this.text){this.text.value="mm/dd/yy";this.text.owner=this;this.text.onfocus=function(q){q=(q)?q:((window.event)?window.event:null);var p=getEventElement(q);p.owner.show(q)};this.text.onkeydown=function(r){r=(r)?r:((window.event)?window.event:null);var q=getEventElement(r);if(r.keyCode==9){q.value=format_date(q.value);q.owner.close();if(q.value!="mm/dd/yy"&&q.owner.onDateChange){var p=q.value.split("/");var s=_strToInt(p[2]);if(s<100){s+=2000}q.owner.onDateChange(new Date(s,_strToInt(p[0])-1,p[1]))}else{if(q.owner.onDateChange){q.owner.onDateChange(new Date())}}}}}this.show=j;this.close=b;this.onshowing=function(){};this.onclosing=function(){};this.popup=document.getElementById(a+"_popup");this.popup.owner=this;this.days=document.getElementById(a+"_days");this.days.owner=this;this.caption=document.getElementById(a+"_header_text");this.prev=document.getElementById(a+"_prev");this.prev.owner=this;this.next=document.getElementById(a+"_next");this.next.owner=this;this.from=this.till=this.selectedCell=null;var c=new Date();this.day=c.getDay();this.date=c.getDate();this.month=c.getMonth();this.year=c.getFullYear();function n(q,p){this.from=q;this.till=p;this.refresh()}function m(r,q,p){this.year=r;this.month=q-1;this.date=p;this.selectedDate=new Date(this.year,this.month,this.date);this.setMonth(this.month,this.year);if(this.text){this.text.value=_dateToString(this.selectedDate)}this.refresh()}function k(){var p=this.selectedCell;if(p){p.style.backgroundColor="#FFFFFF";p.style.cursor="pointer";p.style.fontWeight="normal";this.selectedCell=null}}this.clear_selected_cell=k;function l(p){this.selectedCell=p;p.style.backgroundColor="#AAFFAA";p.style.cursor="default";p.style.fontWeight="bold"}this.select_cell=l;function f(p){var q,r;q=getEventElement(p);if(!q){return}r=findCell(q);if(r!=null&&r!=this.owner.selectedCell&&r.style.cursor=="pointer"){r.style.backgroundColor="#DDDDFF"}}function h(p){var q,r;q=getEventElement(p);if(!q){return}r=findCell(q);if(r!=null&&r!=this.owner.selectedCell&&r.style.cursor=="pointer"){r.style.backgroundColor="#FFFFFF"}}function g(p){var r,s;r=getEventElement(p);if(!r){return}var q=this.owner;q.maybeclose=false;s=findCell(r);if(s!=null&&s!=q.selectedCell&&s.style.cursor=="pointer"){if(q.selectedCell){q.clear_selected_cell()}q.select_cell(s);q.selectedDate=new Date(q.year,q.month,parseInt(s.innerHTML,10));if(q.text){q.text.value=_dateToString(q.selectedDate)}if(q.popup){q.close()}if(q.onDateChange){q.onDateChange(q.selectedDate)}}}function e(p){var q=getEventElement(p);if(!q){return}this.owner.maybeclose=false;if(q.id==this.owner.id+"_prev"){this.owner.setMonth(this.owner.month-1,null)}else{this.owner.setMonth(this.owner.month+1,null)}}function d(q,p){if(p){this.year=p}if(q<0){q=11;this.year--}else{if(q>11){q=0;this.year++}}this.month=q;this.refresh()}function i(){var r;var q=false;var u=new Date(this.year,this.month,1);var p=u.getDay();var w=getMonthDays(this.month,this.year);r=u.getTime()-24*3600000;if(this.from.getTime()&&r<this.from.getTime()){this.prev.style.visibility="hidden"}else{this.prev.style.visibility="visible"}r=u.getTime()+w*24*3600000;if(this.till.getTime()&&r>this.till.getTime()){this.next.style.visibility="hidden"}else{this.next.style.visibility="visible"}this.clear_selected_cell();if(this.selectedDate&&this.month==this.selectedDate.getMonth()&&this.year==this.selectedDate.getFullYear()){q=true}u=1;for(var t=1;t<7;t++){for(var s=0;s<7;s++){var v=this.days.rows[t].cells[s];if((t==1&&s<p)||u>w){v.innerHTML="&nbsp;";v.style.cursor="default";v.style.backgroundImage=""}else{r=new Date(this.year,this.month,u);v.innerHTML=u.toString();if((this.from.getTime()&&r.getTime()<this.from.getTime())||(this.till.getTime()&&r.getTime()>this.till.getTime())){v.style.cursor="default";v.style.backgroundImage="url("+xday+")"}else{v.style.cursor="pointer";v.style.backgroundImage="";if(q&&u==this.selectedDate.getDate()){this.select_cell(v)}}u++}}}this.caption.innerHTML=monthNames[this.month]+", "+this.year}this.refresh=i;this.setMonth=d;this.onDateChange=null;this.setDateRange=n;this.setSelectedDate=m;this.clearSelectedDate=o;this.popup=this.calendar.removeChild(this.popup);this.popup.style.position="absolute";this.popup.style.zIndex="200000";this.days.onmouseover=f;this.days.onmouseout=h;this.days.onclick=g;this.prev.onclick=e;this.next.onclick=e};