
function hx_gb_calendar2(){this.editable=false;}
hx_gb_calendar2.prototype={leapYear:false,sday:null,smonth:null,syear:null,month:null,year:null,firstDay:null,upMonth:false,upYear:false,monthNames:new Array(loc_js.jan,loc_js.feb,loc_js.mar,loc_js.apr,loc_js.may,loc_js.jun,loc_js.jul,loc_js.aug,loc_js.sep,loc_js.oct,loc_js.nov,loc_js.dec),normalMonths:new Array(31,28,31,30,31,30,31,31,30,31,30,31),leapMonths:new Array(31,29,31,30,31,30,31,31,30,31,30,31),create:function(_id,_layer,_editable){this.id=_id;this.editable=_editable;this.element=_layer;this.composeCalendar();this.working(false);},destroy:function(){monthNames=null;normalMonths=null;leapMonths=null;return null;},composeCalendar:function(){var i=ge(this.element);if(i){var code='';code+='<table class="calt">';code+=this.composeControls();code+=this.composeWeekHeader();for(var week=0;week<6;week++)code+=this.composeWeek(week);code+='</table>';re(i,code);var f=ge(this.id+'.cnt.day');this.enableControls();}},composeControls:function(){var thisPtr=this;var code='<tr class="controls">';if(this.editable){code+='<td><a class="clickable" id="'+this.id+'.ylclick" href="#"><span>&lt;&lt;</span></a></td>';code+='<td><a class="clickable" id="'+this.id+'.mlclick" href="#"><span>&lt;</span></a></td>';code+='<td id="'+this.id+'.cnt.day" colspan=4>-</td>';code+='<td><a class="clickable" id="'+this.id+'.mmclick" href="#"><span>&gt;</span></a></td>';code+='<td><a class="clickable" id="'+this.id+'.ymclick" href="#"><span>&gt;&gt;</span></a></td>';}else{code+='<td id="'+this.id+'.cnt.day" colspan=8>-</td>';}
code+='</tr>';return code;},enableControls:function(){var t=null;t=ge(this.id+'.ylclick');var thisPtr=this;if(t)t.onclick=function(evt){thisPtr.move(evt,thisPtr,'-y');return false;};t=ge(this.id+'.mlclick');if(t)t.onclick=function(evt){thisPtr.move(evt,thisPtr,'-m');return false;};t=ge(this.id+'.mmclick');if(t)t.onclick=function(evt){thisPtr.move(evt,thisPtr,'+m');return false;};t=ge(this.id+'.ymclick');if(t)t.onclick=function(evt){thisPtr.move(evt,thisPtr,'+y');return false;};},composeWeekHeader:function(){var code='<tr class="header"><td>'+loc_js.week+'</td><td>'+loc_js.monday+'</td><td>'+loc_js.tuesday+'</td><td>'+loc_js.wednesday+'</td><td>'+loc_js.thursday+'</td><td>'+loc_js.friday+'</td><td>'+loc_js.saturday+'</td><td>'+loc_js.sunday+'</td></tr>';return code;},composeWeek:function(_wid){var code='<tr id="'+this.id+'.week.'+_wid+'">';code+='<td class="wnum" id="'+this.id+'.wid.'+_wid+'"></td>';for(var j=0;j<7;j++){code+='<td id="'+this.id+'.day.'+_wid+'.'+j+'"></td>';}
code+='</tr>';return code;},working:function(_w){},update:function(){this.upMonth=false;this.upYear=false;this.composeMonth();},moveDate:function(_month,_year){this.month=_month;this.year=_year;this.setCaption();if(this.upYear)this.getYearData();this.update();},setDate:function(_day,_month,_year){this.upMonth=(_month!=this.month);this.upYear=(_year!=this.year);this.sday=_day;this.smonth=_month;this.syear=_year;this.month=this.smonth;this.year=this.syear;this.setCaption();if(this.upYear)this.getYearData();this.update();this.onDateChanged();},setCaption:function(){var txt='<p style="padding-top: 1em; height: 2em; display: block">'+this.monthNames[this.month]+' '+this.year+'</p>';re(ge(this.id+'.cnt.day'),txt);},getYearData:function(){var d=new Date;d.setDate(1);d.setMonth(0);d.setFullYear(this.year);d.setHours(0);d.setMinutes(0);d.setSeconds(0);this.firstDay=d.getDay();d.setDate(29);d.setMonth(1);d.setFullYear(this.year);d.setHours(0);d.setMinutes(0);d.setSeconds(0);this.leapYear=(d.getDate()==29);},composeMonth:function(){var ma=null;if(this.leapYear)ma=this.leapMonths;else ma=this.normalMonths;var offset=0;for(var m=0;m<this.month;m++)
offset+=ma[m];var firstDay=(this.firstDay+offset)%7;if(firstDay==0)firstDay=7;var thisPtr=this;var firstWeek=Math.floor(offset/7)+1;var monthCount=-firstDay+2;var monthTotal=ma[this.month];for(var w=0;w<6;w++){re(ge(this.id+'.wid.'+w),firstWeek++);for(var d=0;d<7;d++){var id=this.id+'.day.'+w+'.'+d;var el=ge(id);if(gfc(el))el.removeChild(gfc(el));var ddiv=null;if(monthCount>0&&monthCount<=monthTotal){ddiv=this.getDayLink(monthCount);}else{ddiv=document.createElement('p');}
el.appendChild(ddiv);monthCount++;}}},getDayLink:function(_n){var a=document.createElement('a');a.className='clickable';if(_n==this.sday&&this.month==this.smonth&&this.year==this.syear)a.className+=' currentday';this.getDay(a,_n);if(this.editable)a.onclick=bargs(this.clickDay,this,_n);return a;},clickDay:function(_parent,_day){_parent.sday=_day;_parent.smonth=_parent.month;_parent.syear=_parent.year;_parent.onDateChanged();},onDateChanged:function(){this.composeMonth();if(this.onPostDateChanged)this.onPostDateChanged();},move:function(_evt,_parent,_movement){var m=_parent.month;var y=_parent.year;if(_movement=='-m')m--;if(_movement=='+m')m++;if(_movement=='-y'){y--;this.upYear=true;}
if(_movement=='+y'){y++;this.upYear=true;}
if(m<0){m=11;y--;this.upYear=true;}
if(m>11){m=0;y++;this.upYear=true;}
_parent.moveDate(m,y);if(!_evt)window.event.cancelBubble=true;else _evt.stopPropagation();},getDay:function(_a,_day){st(_a,_day);},getDate:function(){var d=new Date();d.setUTCDate(this.sday);d.setUTCMonth(this.smonth);d.setUTCFullYear(this.syear);d.setUTCHours(0);d.setUTCMinutes(0);d.setUTCSeconds(0);d.setUTCMilliseconds(0);return{'d':this.sday,'m':this.smonth,'ml':this.monthNames[this.month],'y':this.syear,'ts':d.getTime()};},setTodayDate:function(){var d=new Date();this.setDate(d.getDate(),d.getMonth(),d.getFullYear());}}