controls.DTPicker=function(id,parentElement)
{
    this.format='dmy';
    
    if (window.jsFileRegistered_DTPicker==null)
    {
        JScriptPage.addJSFile('js/anotherdtpicker/lang.ashx');
        Common.addCSSFile('js/anotherdtpicker/style.css');
    }

    var table=document.createElement('table');
    var cell=table.insertRow().insertCell();
    
    parentElement.appendChild(table);
    
    var textBox=document.createElement('<input name=\''+id+'_textBox'+'\' type=\'text\' value=\''+this.getStrValue()+'\'>');
    cell.appendChild(textBox);
    textBox.readOnly=true;
    textBox.size=12;
    this.textBox=textBox;
    
    cell.appendChild(document.createElement('<span>')).innerHTML='&nbsp;';
    
    var img=document.createElement('image');
    cell.appendChild(img);
    img.src='js/anotherdtpicker/calendaricon.gif';
    img.border=0;
    img.id=id+'_img';
    img.style.cursor='pointer';
    
    var thisInstance=this;
    img.onclick=function()
    {
        displayDatePicker(textBox.name,false,thisInstance.format);
    }
}
controls.DTPicker.prototype.getValue=function()
{
    if (this.textBox==null)
        return new Date();
    var strValues= this.textBox.value.split('/');
    if (strValues.length<2)
        return new Date();
    var date=new Date(strValues[this.format.indexOf('y')],strValues[this.format.indexOf('m')]-1,strValues[this.format.indexOf('d')]);
    return date;
}
controls.DTPicker.prototype.setValue=function(value)
{
    this.textBox.value=this.getStrValue(value);
}
controls.DTPicker.prototype.getStrValue=function(date)
{
    var v=date==null?this.getValue():date;
    var dia="0"+v.getDate();
    var month="0"+(v.getMonth()+1);
    var ano=v.getFullYear();
    
    dia=dia.substring(dia.length-2);
    month=month.substring(month.length-2);
    return dia+"/"+month+"/"+ano;
}
