
function showChooser(obj,inputId,divId,start,end,format,isTimeChooser){if(document.getElementById){var input=document.getElementById(inputId);var div=document.getElementById(divId);if(input!==undefined&&div!==undefined){if(input.DateChooser===undefined){thediv=document.createElement("div");thediv.id=divId;document.body.appendChild(thediv);input.DateChooser=new DateChooser(input,thediv,start,end,format,isTimeChooser);}
input.DateChooser.setDate(Date.parseDate(input.value,format));if(input.DateChooser.isVisible()){input.DateChooser.hide();}
else{input.DateChooser.show();}}}}
function dateChooserSetDate(inputId,value){var input=document.getElementById(inputId);if(input!==undefined&&input.DateChooser!==undefined){input.DateChooser.setDate(Date.parseDate(value,input.DateChooser._format));if(input.DateChooser.isTimeChooser()){var theForm=input.form;this.form=theForm;var prefix=input.DateChooser._prefix;var lhour=document.getElementById(prefix+'hour');var lmin=document.getElementById(prefix+'min');var lampm=document.getElementById(prefix+'ampm');input.DateChooser.setTime(parseInt(lhour.value)+parseInt(lampm.value),parseInt(lmin.value));}
input.value=input.DateChooser.getValue();input.DateChooser.hide();}}
function dateChooserClose(prefix){var input=document.getElementById(document.getElementById(prefix+'inputId').value);input.DateChooser.hide();}
function dateChooserDateChange(prefix){var input=document.getElementById(document.getElementById(prefix+'inputId').value);var lyear=document.getElementById(prefix+'year');var lmonth=document.getElementById(prefix+'month');var newDate=new Date(lyear.value,lmonth.value,1);input.DateChooser.setDate(newDate);if(input.DateChooser.isTimeChooser()){var lhour=document.getElementById(prefix+'hour');var lmin=document.getElementById(prefix+'min');var lampm=document.getElementById(prefix+'ampm');input.DateChooser.setTime(parseInt(lhour.value)+parseInt(lampm.value),parseInt(lmin.value));}
input.DateChooser.show();}
function getAbsolutePosition(obj){var result=[0,0];while(obj!=null){result[0]+=obj.offsetTop;result[1]+=obj.offsetLeft;obj=obj.offsetParent;}
return result;}
function DateChooser(input,div,start,end,format,isTimeChooser){this._input=input;this._div=div;this._start=start;this._end=end;this._format=format;this._date=new Date();this._isTimeChooser=isTimeChooser;this._prefix="";var letters=["a","b","c","d","e","f","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];for(var i=0;i<10;++i){this._prefix+=letters[Math.floor(Math.random()*letters.length)];}}
DateChooser.prototype._isVisible=false;DateChooser.prototype.isVisible=function(){return this._isVisible;}
DateChooser.prototype.isTimeChooser=function(){return this._isTimeChooser;}
DateChooser.prototype.getValue=function(){return this._date.dateFormat(this._format);}
DateChooser.prototype.hide=function(){this._div.style.visibility="hidden";this._div.style.display="none";this._div.innerHTML="";this._isVisible=false;}
DateChooser.prototype.show=function(){var inputPos=getAbsolutePosition(this._input);this._div.style.top=(inputPos[0]+this._input.offsetHeight)+"px";this._div.style.left=(inputPos[1]+this._input.offsetWidth)+"px";this._div.innerHTML=this.createChooserHtml();this._div.style.display="block";this._div.style.visibility="visible";this._div.style.position="absolute";this._isVisible=true;}
DateChooser.prototype.initializeDate=function(){if(this._input.value!=null&&this._input.value!=""){this._date=Date.parseDate(this._input.value,this._format);}
else{this._date=new Date();}}
DateChooser.prototype.setDate=function(date){this._date=date?date:new Date();}
DateChooser.prototype.setTime=function(hour,minute){this._date.setHours(hour);this._date.setMinutes(minute);}
DateChooser.prototype.createChooserHtml=function(){var formHtml="<div class=\"dateChooserMain select-free\">";formHtml+="<div class=\"dateChooserHeader\"><img src=\"close.png\" class=\"close\" onClick=\"dateChooserClose('"+this._prefix+"');\"/></div>"
+"<input type=\"hidden\" name=\""+this._prefix+"inputId\" id=\""+this._prefix+"inputId\" value=\""+this._input.getAttribute('id')+"\">";formHtml+="\r\n <select name=\""+this._prefix
+"month\" id=\""+this._prefix+"month\" onChange=\"dateChooserDateChange('"+this._prefix+"');\">";for(var monIndex=0;monIndex<=11;monIndex++){formHtml+="\r\n <option value=\""+monIndex+"\""
+(monIndex==this._date.getMonth()?" selected=\"1\"":"")
+">"+Date.monthNames[monIndex]+"</option>";}
formHtml+="\r\n  </select>\r\n  <select name=\""
+this._prefix+"year\"  id=\""+this._prefix+"year\" onChange=\"dateChooserDateChange('"+this._prefix+"');\">";for(var i=this._start;i<=this._end;++i){formHtml+="\r\n    <option value=\""+i+"\""
+(i==this._date.getFullYear()?" selected=\"1\"":"")
+">"+i+"</option>";}
formHtml+="\r\n</select>";formHtml+=this.createCalendarHtml();if(this._isTimeChooser){formHtml+=this.createTimeChooserHtml();}
formHtml+="</div>";return formHtml;}
DateChooser.prototype.createTimeChooserHtml=function(){var result="\r\n  <select name=\""+this._prefix+"hour\" id=\""+this._prefix+"hour\">";for(var i=0;i<12;++i){result+="\r\n    <option value=\""+i+"\""
+(((this._date.getHours()%12)==i)?" selected=\"1\">":">")
+i+"</option>";}
result+="\r\n    <option value=\"0\">12</option>";result+="\r\n  </select>";result+="\r\n  <select name=\""+this._prefix+"min\" id=\""+this._prefix+"min\">";for(var i=0;i<60;i+=15){result+="\r\n    <option value=\""+i+"\""
+((this._date.getMinutes()==i)?" selected=\"1\">":">")
+String.leftPad(i,2,'0')+"</option>";}
result+="\r\n  </select>";result+="\r\n  <select name=\""+this._prefix+"ampm\" id=\""+this._prefix+"ampm\">";result+="\r\n  <option value=\"0\""
+(this._date.getHours()<12?" selected=\"1\">":">")
+"AM</option>";result+="\r\n    <option value=\"12\""
+(this._date.getHours()>=12?" selected=\"1\">":">")
+"PM</option>";result+="\r\n  </select>";return result;}
DateChooser.prototype.createCalendarHtml=function(){var result="\r\n<table cellspacing=\"0\" class=\"dateChooser\">"
+"\r\n  <tr><th>Dim</th><th>Lun</th><th>Mar</th>"
+"<th>Mer</th><th>Jeu</th><th>Ven</th><th>Sam</th></tr>\r\n  <tr>";var firstDay=this._date.getFirstDayOfMonth();var lastDay=this._date.getLastDayOfMonth();var amonth=this._date.getMonth();if(firstDay!=0){result+="<td colspan=\""+firstDay+"\">&nbsp;</td>";}
var i=0;while(i<this._date.getDaysInMonth()){if(((i+++firstDay)%7)==0){result+="</tr>\r\n  <tr>";}
var thisDay=new Date(this._date.getFullYear(),this._date.getMonth(),i);var js='"dateChooserSetDate(\''
+this._input.getAttribute('id')+"', '"
+thisDay.dateFormat(this._format)+'\');"'
result+="\r\n    <td class=\"dateChooserActive"
+(i==this._date.getDate()?" dateChooserActiveToday":"")
+"\" onClick="+js+">"+i+"</td>";}
if(lastDay!=6){result+="<td colspan=\""+(6-lastDay)+"\">&nbsp;</td>";}
return result+"\r\n  </tr>\r\n</table><!--[if lte IE 6.5]><iframe></iframe><![endif]-->";}