

var DateSelectorSelectButton='<img src="Images/DateSelector/Calendar.gif" border="0" widdth="16" height="16" >';
var DateSelectorBackButton='<img src="Images/DateSelector/Back.gif" border="0" widdth="4" height="7" >';
var DateSelectorNextButton='<img src="Images/DateSelector/Next.gif" border="0" widdth="4" height="7" >';
var DateSelectorFirstButton='<img src="Images/DateSelector/First.gif" border="0" widdth="8" height="9" >';
var DateSelectorLastButton='<img src="Images/DateSelector/Last.gif" border="0" widdth="8" height="9" >';

var DateSelectors=new Array();
var today=new Date()
var DateSelectorMinYear=today.getFullYear() - 1;
var DateSelectorMaxYear=today.getFullYear() + 1;

var DateSelectorsCount=0;
var DateSelectorFormat=0;


function DateSelector(FieldName,SelDate,MinDate,MaxDate,AvbDates,AllowNone,F,TimeSel){

TimeSel=(TimeSel==true)


var STime=null
if (TimeSel)
{
    var s=str2time(SelDate);
    if (s){
        STime=s
    } else {
        STime='00:00'
    }
}
if (SelDate){ 
    var s=str2date(SelDate);
    if (s){
        SelDate=s
    }else{
        SelDate=null
    }
}

if (!FieldName) FieldName='DateSelector' + DateSelectorsCount;

if (!SelDate) SelDate=null;
var SelDateTXT=date2str(SelDate)
if (!MinDate) MinDate=null;
if (!MaxDate) MaxDate=null;

if (!AvbDates) AvbDates=null;

var txt='';
txt +='<table border="0" cellspacing="0" cellpadding="0">';
var id='DateSelectorRow'+DateSelectorsCount

txt +='<tr>';
txt +='<td>';
txt +='<input type="text" name="' + FieldName + '" value="'+SelDateTXT;

if (STime!=null&& SelDateTXT!='')
{
    txt += ' ' + STime
}

if (TimeSel)
{
    txt +='" size="19" maxlength="16"'
} else {
    txt +='" size="12" maxlength="10"'
}

txt +=' onblur="DateSelectors['+DateSelectorsCount+'].hide();DateSelectors['+DateSelectorsCount+'].setDateFromText(this);" onkeypress="var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode==13){return false}" class="DateSelectorInput">';
txt +='</td>';
txt +='<td>&nbsp;';
txt +='</td>';
txt +='<td>';
txt +='<a href="javascript://" onclick="DateSelectors['+DateSelectorsCount+'].tolgate();return false;">';
txt +=DateSelectorSelectButton;
txt +='</a>';
txt +='</td>';
txt +='</tr>';

txt +='<tr name="'+ id +'" id="'+ id +'" >';
txt +='<td colspan="3">';
txt +='<DIV id="Selector" style="position:absolute;visibility:hidden;" class="Selector"></DIV>';
txt +='</td>';
txt +='</tr>';


txt +='</table>';
document.write(txt)

DateSelectors[DateSelectorsCount]=new DateSelectorObj(FieldName,SelDate,MinDate,MaxDate,AvbDates,AllowNone,id,F,TimeSel,STime);
DateSelectorsCount++;
}

function DateSelectorObj(FieldName,SelDate,MinDate,MaxDate,AvbDates,AllowNone,id,F,TimeSel,STime){
var i=0;

var today=new Date()

this.num=DateSelectorsCount;

if (F){
	if (F.elements){
	this.FormElement=F.elements[FieldName]
}}


this.CValue=this.FormElement.value

this.FieldName=FieldName;
this.SelDate=SelDate;
this.TimeSel=TimeSel
this.STime=STime


this.date=today
this.thisyear=today.getFullYear()
this.thismonth=today.getMonth();
this.thisday=today.getDate();

 if (!MinDate){
	if (!AvbDates) {
	 MinDate=new Date(DateSelectorMinYear, 0, 1)
	} else {
	 MinDate=AvbDates[0]
	}
 } 

 if (!MaxDate){
	if (!AvbDates) {
	 MaxDate=new Date(DateSelectorMaxYear, 11, 31)
	} else {
	 MaxDate=AvbDates[0]
	}
 } 



this.Day=0;

if (AvbDates){
 for(i=0;i<AvbDates.length;i++){
  if (AvbDates[i]<MinDate||MinDate==null) MinDate=AvbDates[i]
  if (AvbDates[i]>MaxDate||MaxDate==null) MaxDate=AvbDates[i]
 }
}

if (SelDate){
 this.Year=SelDate.getFullYear();
 this.Month=SelDate.getMonth();
 this.Day=SelDate.getDate();

 if (SelDate<MinDate) MinDate=SelDate 
 if (SelDate>MaxDate) MaxDate=SelDate 
}

this.MinDate=MinDate;
this.MaxDate=MaxDate;


 this.MinYear=MinDate.getFullYear();
 this.MinMonth=MinDate.getMonth();
 this.MinDay=MinDate.getDate();



 this.MaxYear=MaxDate.getFullYear();
 this.MaxMonth=MaxDate.getMonth();
 this.MaxDay=MaxDate.getDate();

 this.todayEnabled=false;
 if (today>=MinDate&&MaxDate>=today){
    this.todayEnabled=true;
 }

if (!SelDate&&MinDate>today){
today=MinDate
}

if (!SelDate&&MaxDate<today){
today=MaxDate
}

if (!SelDate){
 this.Year=today.getFullYear()
 this.Month=today.getMonth();
}

this.AvbDates=AvbDates;
this.AvbDatesSTR=null
if (AvbDates) this.AvbDatesSTR=AvbDates.join(';')
this.AllowNone=AllowNone;
this.visible=false;
this.id=id;
this.enabled=true;
this.initObjects()
}

DateSelectorObj.prototype.initObjects=function (d)
{
 if (!d) d=document
 if (d.all){
  this.Row=d.all(this.id);
  this.RowStyle=d.all(this.id).style
  this.Selector=this.Row.all('Selector')
  this.SelectorStyle=this.Selector.style
 }else if (d.getElementById){
  this.Row=d.getElementById(this.id); 
  this.RowStyle=this.Row.style
  this.Selector=this.Row.getElementsByTagName("DIV")[0]
  this.SelectorStyle=this.Selector.style
 } else {
  this.enabled=false
 }
}


DateSelectorObj.prototype.setDateFromText=function (obj)
{

var v=obj.value
if (this.CValue==v) return

if (v=='' && this.AllowNone==true){
    this.CValue=v
    return
}


var STime=null
var SelDate=null

if (this.TimeSel)
{
    var s=str2time(v);
    if (s){
        STime=s
    } else {
        STime='00:00'
    }
}

    var s=str2date(v);
    if (s){
        SelDate=s
    }else{
        SelDate=null
    }

var SelDateTXT=date2str(SelDate)


if (STime!=null&& SelDateTXT!='')
{
    SelDateTXT += ' ' + STime
}
    var newV=SelDateTXT


if (newV==v) {
    

    var v1=this.isEnabledDate(SelDate)
    if (v1){

        this.Year=SelDate.getFullYear();
        this.Month=SelDate.getMonth();
        this.Day=SelDate.getDate();

        this.STime=STime
        this.CValue=v
    } else {
        obj.value=this.CValue
    }

} else {
    obj.value=this.CValue
}
}

DateSelectorObj.prototype.tolgate= function (){
if (this.enabled){
 if (this.visible==false){
     var i;
     for(i=0;i<DateSelectorsCount;i++){
     if (i!=this.num&&DateSelectors[i].visible)
        DateSelectors[i].tolgate();
     }    
 	 this.draw(true);
	 this.SelectorStyle.visibility='visible';
	 this.visible=true;
 } else {
	 this.SelectorStyle.visibility='hidden';
 	 this.draw(false);	 
	 this.visible=false;
 }}
}

DateSelectorObj.prototype.hide= function (){
if (this.enabled){
	 this.SelectorStyle.visibility='hidden';
 	 this.draw(false);	 
	 this.visible=false;
 }
}

DateSelectorObj.prototype.draw= function (d){
var txt='';
	if (this.enabled){
		if (d) txt=this.getHTML()
		this.Selector.innerHTML=txt
	}
}
DateSelectorObj.prototype.getHTML= function (){
var txt=''
txt +='<table border="0" cellspacing="0" cellpadding="0" class="SelectorTable">';
txt +='<tr>';
txt +='<td>';
txt +='<table border="0" cellspacing="0" cellpadding="0" class="SelectorInTable">';
txt +='<tr>';
txt +='<td align="center" class="SelectorHead" width="100%">';
txt +=this.getHead()
txt +='</td>';
txt +='</tr>';
txt +='<tr>';
txt +='<td align="center" class="SelectorDays" width="100%">';
txt +=this.getDaysHTML()
txt +='</td>';
txt +='</tr>';
txt +='<tr>';
txt +='<td align="center" class="ToDayText" width="100%">';

txt += '<span';
if (this.todayEnabled) {
    txt += ' onclick="DateSelectors['+this.num+'].setDay(-1);" style="cursor:hand;"'
}
txt += '>'
txt += date2str(this.date);
txt += '</span>';
//txt += date2str(new Date(this.thisyear, this.thismonth, this.thisday));
txt +='</td>';
txt +='</tr>';


if (this.TimeSel)
{
    txt +='<tr>'
    txt +='<td class="SelectorTime" >'

    txt +='<table border="0" width="100%">'    
    txt +='<tr>'    
    txt +='<td style="text-align:right;width:100%">'    
    txt +=TimeTXT + ':';
    txt +='<input class="" size="5" maxlength="5" type=text value="' + this.STime + '" onblur="DateSelectors['+this.num+'].setTime(this,true,event);" onkeypress="return DateSelectors['+this.num+'].setTime(this,false,event);">';
    txt +='</td>'    
    txt +='</tr>'    
    txt +='</table>'    

    txt +='</td></tr>'
}

txt +='<tr>';
txt +='<td align="center" class="bottom_select">';
txt +=this.getMonthHTML();
txt +='</td>';
txt +='</tr>';
txt +='<tr>';
txt +='<td align="center" class="FootTable" width="100%">';
txt +=this.getFootHTML()
txt +='</td>';
txt +='</tr>';
txt +='</table>';
txt +='</td>';
txt +='</tr>';
txt +='</table>';
return txt;
}

DateSelectorObj.prototype.getHead= function (){
var txt=''
txt +='<table border="0" cellspacing="0" cellpadding="0" align="center">';
txt +='<tr>';
txt +='<td align="center">';
txt +=this.getYearHTML();
txt +='</td>';
txt +='</tr>';
txt +='</table>';
return txt;
}

DateSelectorObj.prototype.getYearHTML= function (){
var txt=''
var i;
txt +='<table border="0" cellspacing="1" cellpadding="1" align="center">';
txt +='<tr>';
txt +='<td>';
if (this.MinYear==this.MaxYear){
	txt +=this.Year;
}else{

if (this.Year>this.MinYear) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setYear(' + this.MinYear + ');return false;">';
txt +=DateSelectorFirstButton;
if (this.Year>this.MinYear) txt +='</a>';

txt +='</td>';
txt +='<td>';

if (this.Year>this.MinYear) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setYear(' + (parseInt(this.Year)-1) + ');return false;">';
txt +=DateSelectorBackButton;
if (this.Year>this.MinYear) txt +='</a>';

txt +='</td>';
txt +='<td>';

txt +='<select onchange="DateSelectors['+this.num+'].setYear(this.value);" class="SelectorSelect">';
for (i=this.MinYear;i<=this.MaxYear;i++){
txt +='<option value='+i
if (this.Year==i) txt +=' selected';
txt +='>'+i+'</option>';
}
txt +='</select>';


txt +='</td>';
txt +='<td>';

if (this.Year<this.MaxYear) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setYear(' + (parseInt(this.Year) + 1) + ');return false;">';
txt +=DateSelectorNextButton;
if (this.Year<this.MaxYear) txt +='</a>';

txt +='</td>';
txt +='<td>';

if (this.Year<this.MaxYear) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setYear(' + this.MaxYear + ');return false;">';
txt +=DateSelectorLastButton;
if (this.Year<this.MaxYear) txt +='</a>';
}

txt +='</td>';
txt +='</tr>';
txt +='</table>';
return txt;
}




DateSelectorObj.prototype.getMonthHTML= function (){
var txt=''
var i;
txt +='<table border="0" cellspacing="1" cellpadding="1" align="center">';
txt +='<tr>';
txt +='<td>';
if (this.MinYear==this.MaxYear&&this.MinMonth==this.MaxMonth){
	txt +=Months[this.Month];
}else{

var FirstMonth=0
if (this.Year==this.MinYear) FirstMonth=this.MinMonth
if (this.Year!=this.MinYear||(this.Year==this.MinYear&&this.Month!=this.MinMonth)) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setMonth(' + FirstMonth + ');return false;">';
txt +=DateSelectorFirstButton;
if (this.Year!=this.MinYear||(this.Year==this.MinYear&&this.Month!=this.MinMonth)) txt +='</a>';

txt +='</td>';
txt +='<td>';

if (this.Year!=this.MinYear||(this.Year==this.MinYear&&this.Month!=this.MinMonth)) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setMonth(' + (parseInt(this.Month)-1) + ');return false;">';
txt +=DateSelectorBackButton;
if (this.Year!=this.MinYear||(this.Year==this.MinYear&&this.Month!=this.MinMonth)) txt +='</a>';

txt +='</td>';
txt +='<td>';

var LastMonth=11;
if (this.Year==this.MaxYear) LastMonth=this.MaxMonth

txt +='<select onchange="DateSelectors['+this.num+'].setMonth(this.value);" class="SelectorSelect">';
for (i=FirstMonth;i<=LastMonth;i++){
txt +='<option value='+i
if (this.Month==i) txt +=' selected';
txt +='>'+Months[i]+'</option>';
}
txt +='</select>';


txt +='</td>';
txt +='<td>';

if (this.Year!=this.MaxYear||(this.Year==this.MaxYear&&this.Month!=this.MaxMonth)) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setMonth(' + (parseInt(this.Month) + 1) + ');return false;">';
txt +=DateSelectorNextButton;
if (this.Year!=this.MaxYear||(this.Year==this.MaxYear&&this.Month!=this.MaxMonth)) txt +='</a>';

txt +='</td>';
txt +='<td>';

if (this.Year!=this.MaxYear||(this.Year==this.MaxYear&&this.Month!=this.MaxMonth)) txt +='<a  href="javascript://" onclick="DateSelectors['+this.num+'].setMonth(' + LastMonth + ');return false;">';
txt +=DateSelectorLastButton;
if (this.Year!=this.MaxYear||(this.Year==this.MaxYear&&this.Month!=this.MaxMonth)) txt +='</a>';
}

txt +='</td>';
txt +='</tr>';
txt +='</table>';
return txt;
}

DateSelectorObj.prototype.getDaysHTML= function (){
var txt=''
var i;
var d;
var t;
var ii;
txt +='<table align="center" width="100%" class="DaysTable">';
txt +='<tr>';
for (i=0;i<7;i++){
txt +='<td';
if (i>4){ txt +=' class="DaysHeadWeekEnd"';} else { txt +=' class="DaysHeadNormal"' }
txt +='>'+ShortDays[i]+'</td>';
}
txt +='</tr>';

var maxday = Date.UTC(this.Year, parseInt(this.Month) + 1, 1, 0, 0, 0) - Date.UTC(this.Year, this.Month, 1, 0, 0, 0)
maxday /= 24*3600000

d=new Date(this.Year, this.Month, 1)
t=d.getDay()
if (t==0) t=7
t=t-1
txt +='<tr class="Days">';
for(i=0;i<t;i++){
txt +=this.DrawDayTD(0,i);
}
for(i=t;i<7;i++){
txt +=this.DrawDayTD(i - t + 1,i );
}
txt +='</tr>';
//var totalweeks=getWeekEuropa(this.Year, parseInt(this.Month), 1) - getWeekEuropa(this.Year, this.Month - 1, 1)


for(ii=0;(i - t + 1 )<=maxday;ii++){
 if (!((7+ii*7 - t + 1 )>maxday)){
txt +='<tr class="Days">';
for(i=7+ii*7;i<7+(ii+1)*7;i++){
 if ((i - t + 1 )>maxday){
  txt +=this.DrawDayTD(0,i-(7+ii*7)  );
 } else {
  txt +=this.DrawDayTD(i - t + 1,i-(7+ii*7));
 }
}
txt +='</tr>';
}}

txt +='</table>';
return txt;
}

DateSelectorObj.prototype.DrawDayTD= function (d,wd){
var txt=''
var clas='Day'
if (this.Year==this.thisyear&&this.Month==this.thismonth&&this.thisday==d) clas='ToDay'
var tday=''
var isEnabled=false;
if (d<1) {
	clas +='Disabled'
	if (wd>4) clas +='WeekEnd'
	    tday='&nbsp;';
	} else{
	    isEnabled=this.isEnabled(d);
	    if (isEnabled) {
		    clas +='Enabled'
		    if (wd>4) clas +='WeekEnd'
	    }else{
		    clas +='Disabled'
		    if (wd>4) clas +='WeekEnd'
	    }
	tday=d;
	}
txt +='<td  class="' + clas + '" ';

if (isEnabled) {
txt +='onmouseover="this.className=\''+ clas +'Over\';" onmouseout="this.className=\''+ clas +'\';"'
txt +=' onclick="DateSelectors['+this.num+'].setDay(' + d + ');"';
}
txt += '>'
txt += tday;

txt += '</td>';


return txt;
}

DateSelectorObj.prototype.isEnabled=function(d){
var r=true
var d=new Date(this.Year, this.Month, d)
if (d<this.MinDate||d>this.MaxDate){
r=false
return r;
}
if (this.AvbDatesSTR){
 d=''+d;
 r=(this.AvbDatesSTR.indexOf(d)>-1);
}
return r;
}

DateSelectorObj.prototype.isEnabledDate=function(d){
var r=true
if (d<this.MinDate||d>this.MaxDate){
r=false
return r;
}
if (this.AvbDatesSTR){
 d=''+d;
 r=(this.AvbDatesSTR.indexOf(d)>-1);
}
return r;
}


DateSelectorObj.prototype.getFootHTML= function (){
var txt=''

txt +='<table cellpadding="0" cellspacing="3" width="100%">';
/*
txt +='<tr>';
txt +='<td nowrap="nowrap" colspan="2">' + ToDay + ': ' ;

txt += '<span';
if (this.todayEnabled) {
    txt += ' onclick="DateSelectors['+this.num+'].setDay(-1);" style="cursor:hand;"'
}
txt += '>'
txt += date2str(this.date);
txt += '</span>';

txt += '</td>';
txt +='</tr>';
*/
if (this.AllowNone){
txt +='<tr>';

txt +='<td onclick="DateSelectors['+this.num+'].tolgate(false);" style="cursor:hand;text-align:left">' + CloseTXT + '</td>';

txt +='<td onclick="DateSelectors['+this.num+'].setDay(0);" style="cursor:hand;text-align:right">' + BlankDate + '</td>';
txt +='</tr>';
}

txt +='</table>';
return txt;
}

DateSelectorObj.prototype.setYear= function (y){
this.Year=y
this.Day=0
if (this.Year==this.MaxYear&&this.Month>this.MaxMonth) this.Month=this.MaxMonth
if (this.Year==this.MinYear&&this.Month<this.MinMonth) this.Month=this.MinMonth
this.draw(true);
}

DateSelectorObj.prototype.setMonth= function (m){
var need=true

this.Day=0

this.Month=parseInt(m)
if (parseInt(this.Month)<0) {
	need=false
	this.Year=parseInt(this.Year)-1
	this.setMonth(12+parseInt(this.Month))
   }
if (this.Month>11) {
	need=false
	this.Year=parseInt(this.Year)+1
	this.setMonth(parseInt(this.Month)-12)
   }
	
if	(need)  this.draw(true);
}

DateSelectorObj.prototype.setDay= function (d){
var seldateTXT;
var i;

this.Day=d

if (d>0){
    seldateTXT=date2str(new Date(this.Year, this.Month, d));
} else if (d==-1) {
    seldateTXT=date2str(new Date(this.thisyear, this.thismonth, this.thisday));
}else{
seldateTXT='';
}
if (seldateTXT!=''&&this.TimeSel)
{
    seldateTXT += ' ' + this.STime; 
}

var _F=this.getForm()

if (_F){
if (_F.name){
	_F.value=seldateTXT
}
this.tolgate();
}
}


DateSelectorObj.prototype.getForm= function (){
    var OBJ=this.Row
    while (OBJ.tagName!='FORM')
    {
        var OBJ=OBJ.parentNode
    }
    return OBJ.elements[this.FieldName]
    
}

DateSelectorObj.prototype.setTime= function (ob,b,e){
            
            var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            var v=ob.value
            
            if (keyCode==13||b)
            {
                var s=strtime2time(v)
                if (s!=null)
                {
                 this.STime=s   
                }
                ob.value=this.STime
                if (keyCode==13&&this.Day>0&&s!=null) this.setDay(this.Day) 
                return false
            }
            else {
                return true
            }
}


function date2str(objDate){
 var r='';
  if (objDate){
   var y=objDate.getFullYear();
   var m=objDate.getMonth() + 1;
   if (m<10) m='0' + m
   var d=objDate.getDate();
   if (d<10) d='0' + d

   switch (DateSelectorFormat) {
    case 0:
      r= y + '-' + m + '-' + d;
	  break;
	default :
      r= y + '.' + m + '.' + d;
  	  break;
   } 
  }
 return r;
}

	function getWeekEuropa(year, month, day)
	{
		var newYear = new Date(year,0,1);
		var modDay = newYear.getDay();
		if (modDay == 0)
			modDay=6;
		else
			modDay--;

		var daynum = getYeard(year, month, day);

		if (modDay < 4 )
			weeknum = Math.floor((daynum+modDay-1)/7)+1;
		else
		{
			weeknum = Math.floor((daynum+modDay-1)/7);
			if (weeknum == 0)
			{
				year--;
				var prevNewYear = new Date(year,0,1);
				var prevmodDay = prevNewYear.getDay();
				if (prevmodDay == 0)
					prevmodDay = 6;
				else
					prevmodDay--;
				if (prevmodDay < 4)
					weeknum = 1;
				else
					weeknum = 52;
			}
		}
		return weeknum;
	}
	
	function getYeard(year, month, day)
	{
		var daynum = new Date(year, month, day) - new Date(year, 0, 1)
		daynum = parseInt( daynum /(24*3600000))
		daynum += 1
		return daynum;
	}


	
function str2date(strdt) {
dt=null;
var y;
var m;
var d;
    
   switch (DateSelectorFormat) {
    case 0:
        y=strdt.substr(0,4)
        m=strdt.substr(5,2)
        d=strdt.substr(8,2)
        if (m.substr(0,1)=='0') m=m.substr(1,1)
        if (d.substr(0,1)=='0') d=d.substr(1,1)
        y=parseInt(y)
        m=parseInt(m)
        d=parseInt(d)

        if (!isNaN(y)&&!isNaN(m)&&!isNaN(d)) dt =new Date(y,m-1,d);
	  break;
	default :
        y=strdt.substr(0,4)
        m=strdt.substr(5,2)
        d=strdt.substr(8,2)
        if (m.substr(0,1)=='0') m=m.substr(1,1)
        if (d.substr(0,1)=='0') d=d.substr(1,1)
        y=parseInt(y)
        m=parseInt(m)
        d=parseInt(d)

        if (!isNaN(y)&&!isNaN(m)&&!isNaN(d)) dt =new Date(y,m-1,d);
  	  break;
   } 

return dt;
}


function str2time(strdt) {
    dt=null;



   switch (DateSelectorFormat) {
    case 0:
        var strdtA=strdt.split(' ')
	    var strdt=strdtA[strdtA.length-1]
	  break;
	default :
        var strdtA=strdt.split(' ')
	    var strdt=strdtA[strdtA.length-1]
  	  break;
   } 


        dt=strtime2time(strdt)
    return dt;
}


function strtime2time(strdt) {
dt=null;
var h;
var m;
var ih;
var im;

   switch (DateSelectorFormat) {
    case 0:
        var strdtA=strdt.split(':')
        if (strdtA.length!=2) return dt;
        h=strdtA[0]
        m=strdtA[1]

        if (h.substr(0,1)=='0') h=h.substr(1,1)
        if (m.substr(0,1)=='0') m=m.substr(1,1)

        ih=parseInt(h)
        im=parseInt(m)
        if (!isNaN(ih)&&!isNaN(im)){
         if (ih>-1&&ih<24&&im>-1&&im<61){
         if (ih<10 ) h= '0' + ih
         if (im<10 ) m= '0' + im
         dt = h + ':' + m
        }}
	  break;
	default :
        var strdtA=strdt.split(':')
        if (strdtA.length!=2) return dt;
        h=strdtA[0]
        m=strdtA[1]

        if (h.substr(0,1)=='0') h=h.substr(1,1)
        if (m.substr(0,1)=='0') m=m.substr(1,1)

        ih=parseInt(h)
        im=parseInt(m)
        if (!isNaN(ih)&&!isNaN(im)){
         if (ih>-1&&ih<24&&im>-1&&im<61){
         if (ih<10 ) h= '0' + ih
         if (im<10 ) m= '0' + im
         dt = h + ':' + m
        }}
  	  break;
   } 

return dt;
}
