
function UA()
{
    var a=navigator.userAgent.toLowerCase(),b=parseInt(navigator.appVersion);
    var g=navigator.appName=="Netscape";
    this.DOM=document.getElementById?true:false;
    this.ie3down=a.indexOf('msie')!=-1&&b<4&&!this.opera;
    this.ie4up=!this.ie3down&&document.all&&document.all.item&&!this.opera;
    this.ie5up=this.DOM&&this.ie4up;this.ie6=this.ie5up&&a.indexOf('msie 6.')>0;
    this.ie=this.ie4up||this.ie5up;this.nn4=g&&!this.DOM&&!this.opera;
    this.aol4up=this.aol&&this.ie4up;this.supp=this.supported=this.ie||this.nn4||this.DOM;
};

var ua=new UA();

function CodeThatSetMY(m,y,f)
{
switch(f){case 0:
{
++m;
if(m==12)
{
m=0;
y++;
}
break;
}
case 1:
{
--m;
if(m==-1)
{
m=11;
y--;
}
break;
}
case 2:
{
++y;
break;
}
case 3:
{
--y;
break;
}
case 4:
{
break;
}
}

var h=window.opener||window;
if(h&&h.codethatcalendar)
{
h.codethatcalendar.date.setYear(y);
h.codethatcalendar.date.setMonth(m);
}
location.reload();
};

function CodeThatFind(d,f)
{
if(d.getElementById&&d.getElementById(f)!=null)
{
return d.getElementById(f);
}
else if(ua.ie4up)
{
return d.all[f];
}
else
{
if(d.forms.item)for(var j=0;d.forms.item(j)!=null;++j)
{
if(d.forms.item(j).namedItem&&d.forms.item(j).namedItem(f))
return d.forms.item(j).namedItem(f);
if(d.forms.item(j).elements&&d.forms.item(j).elements[f])
return d.forms.item(j).elements[f];
}
for(var k in d.forms)if(d.forms[k].elements&&d.forms[k].elements[f])
return d.forms[k].elements[f];
}
return null;
};

function CodeThatAlign(n)
{
return n<10?("0"+n):(""+n);;
};

function CodeThatDateFormat(f,d,m,y)
{
var o=f;d=d<10?("0"+d):d;o=o.replace("dd",d);
m++;
m=m<10?("0"+m):m;
o=o.replace("MM",m);
o=o.replace("yyyy",y);
if(CodeThatFind(document,'time'))
{
var q=CodeThatFind(document,'time').value;
var r=parseInt(q.substring(0,2)-0);
if(r<0||r>23)
{
r=r%24;
r+=(r<0?24:0);
}
o=o.replace("HH",CodeThatAlign(r));
var u=parseInt(q.substring(3,5)-0);
if(u<0||u>59)
{
u=u%60;
u+=(u<0?60:0);
}
o=o.replace("mm",CodeThatAlign(u));
var x=parseInt(q.substring(6,8)-0);
if(x<0||x>59){
x=x%60;
x+=(x<0?60:0);
}
o=o.replace("ss",CodeThatAlign(x));
}
return o;
};

function CodeThatSetDay(c,f,d,m,y,i,ifr)
{
var z;
if(window.opener&&!i)z=window.opener.document;
else z=document;
var a1=CodeThatFind(z,c);
if(a1)a1.value=CodeThatDateFormat(f,d,m,y);
if(window.opener&&!i)
{
window.close();
if(window.parent&&ifr)
{
var b1=CodeThatFind(window.parent.document,ifr);
if(b1)b1.style.visibility='hidden';
}
}
};

function CodeThatCalendar(def)
{
this.def=def;
this.links={};
this.styles={};
};
{
var c1=CodeThatCalendar.prototype;
c1.getCss=function(key,d)
{
return "";
};
c1.create=function(d,ctl)
{
var d1=false;
this.i=d1;
if(!this.date)this.date=window.date||new Date();
var e1=this.def;
d.write("<table align=center cellspacing=0 cellpadding=0 width=270 border=1>");
d.write("<tr>");
if(d1)this.createButtons(d,d1);
else
{
if(e1.headerstyle.type=="buttons")this.createButtons(d,d1);
else if(e1.headerstyle.type=="comboboxes")this.createCombos(d);
}
d.write("</tr>");
var f1=0;
d.write("<tr>");
this.createWeekdays(d);
d.write("</tr>");
var g1=this.createMonth(d);
if(e1.showtime)
{
this.createTime(d);
}
if(ua.opera&&g1==4)
{
d.write("<tr><td colspan=7>&nbsp;<td></tr>");
}
d.write("</table>");
};

c1.createTime=function(d)
{
d.write("<tr><td colspan=7 align=center>"+(ua.nn4?"<form>":"")+"<input "+(ua.nn4?"name":"id")+"='time' type=textarea value='"+CodeThatAlign(this.date.getHours())+":"+CodeThatAlign(this.date.getMinutes())+":"+CodeThatAlign(this.date.getSeconds())+"'>"+(ua.nn4?"</form>":"")+"</td></tr>");
};

c1.createMonth=function(d)
{
var h1=this.date.getDate();
var i1=this.date.getMonth();
var j1=this.date.getYear();
var k1=this.date.getDay();
var l1=this.def;
var m1=1;this.date.setDate(m1);
var n1=false;
var o1=(this.date.getDay()-l1.firstday);
o1+=(o1<0?7:0);
m1-=o1;
var p1,q1=false,r1,s1;
var t1;
for(t1=0;t1<6;++t1)
{
d.write("<tr>");
for(var u1=0;u1<7;++u1)
{
r1=u1+l1.firstday;
r1-=(r1<7?0:7);
r1=r1==0||r1==6;
this.date.setDate(m1);
if(this.date.getDate()==1)q1=!q1;if(u1==0)
{
if(t1!=0)
{
n1=h1-this.date.getDate();
if(n1<7&&n1>=0)n1=true;
else n1=false;
}
else n1=(o1+h1)<8;
}
if(u1==7&&n1)n1=false;
s1=this.date.getDate()==h1&&q1;
p1=s1?"cd_css":(n1?"tw_css":(q1?(r1?"we_css":"wd_css"):(r1?"weom_css":"wdom_css")));
//d.write("<td align=center width=14% "+this.getCss(p1)+"><A "+this.getCss(p1)+this.getRef()+">");
//d.write(this.date.getDate());
//d.write("</A></td>");
if (p1!="wdom_css" && p1!="weom_css")
{
if (p1=s1)
{
d.write("<td align=center class=clscurrentday width=14%><b><A "+this.getRef()+">");
d.write(this.date.getDate());
d.write("</A></b></td>");
} else {
d.write("<td align=center class=clsdayname width=14%><b><A "+this.getRef()+">");
d.write(this.date.getDate());
d.write("</A></b></td>");
}
} else {
d.write("<td align=center class=clsdayname width=14%>&nbsp;</td>");
}
m1=this.date.getDate()+1;
}
d.write("</tr>");
this.date.setDate(m1);
if(this.date.getDate()<8&&t1>3)break;
}
this.date.setDate(h1);
this.date.setMonth(i1);
this.date.setYear(j1);
return t1;
};
c1.setLink=function(s,l)
{
this.links[s]=l;
};
c1.setStyle=function(s,l)
{
this.styles[s]=l;
};
c1.getStyle=function()
{
var v1;
if(this.i)
{var w1=CodeThatDateFormat(this.def.dtype,this.date.getDate(),this.date.getMonth(),this.date.getFullYear());
if(this.styles[w1])v1=this.styles[w1];
}
return v1;
};
c1.getRef=function()
{
var x1;
if(this.i)
{
var y1=CodeThatDateFormat(this.def.dtype,this.date.getDate(),this.date.getMonth(),this.date.getFullYear());
if(this.links[y1])x1=" href='"+this.links[y1]+"'";
}
x1=x1||(" href='javascript:CodeThatSetDay(\""+this.ctl+"\",\""+this.def.dtype+"\","+this.date.getDate()+","+this.date.getMonth()+","+this.date.getFullYear()+","+this.i+",\""+this.ifr+"\")'");
return x1;
};
c1.createWeekdays=function(d)
{
var z1=this.def;
var a2;
for(var b2=0;b2<7;++b2)
{
a2=b2+z1.firstday;
a2-=(a2<7?0:7);
d.write("<td class=clsWeekEndOtherMonth align=center "+this.getCss("dn_css")+">"+z1.daynames[a2]+"</td>");
}
};
c1.createButtons=function(d,i)
{
var c2=9,d2=this.def.headerstyle;
for(var e2 in d2)--c2;
if(d2.imgprevy&&!i)d.write("<td width=14% align=left><a href='javascript:CodeThatSetMY("+this.date.getMonth()+","+this.date.getFullYear()+",3)'><IMG border=0 src='"+d2.imgprevy+"'</IMG></A>");
if(d2.imgprevm&&!i)d.write("<td width=14% align=left><a href='javascript:CodeThatSetMY("+this.date.getMonth()+","+this.date.getFullYear()+",1)'><IMG border=0 src='"+d2.imgprevm+"'</IMG></A>");
d.write("<td colspan="+c2+" align=center "+this.getCss("css",d2)+">"+this.def.monthnames[this.date.getMonth()]+"&nbsp;"+this.date.getFullYear()+"</td>");
if(d2.imgnextm&&!i)d.write("<td width=14% align=right><a href='javascript:CodeThatSetMY("+this.date.getMonth()+","+this.date.getFullYear()+",0)'><IMG border=0 src='"+d2.imgnextm+"'</IMG></A></td>");
if(d2.imgnexty&&!i)d.write("<td width=14% align=right><a href='javascript:CodeThatSetMY("+this.date.getMonth()+","+this.date.getFullYear()+",2)'><IMG border=0 src='"+d2.imgnexty+"'</IMG></A></td>");
};
c1.createCombos=function(d,l)
{
var f2=this.def.headerstyle;
d.write("<td colspan=7 "+this.getCss("css",f2)+">");
if(ua.nn4)d.write("<form>");
d.write("<select align=left "+this.getCss("css",f2)+" "+(ua.nn4?"name":"id")+"='month' onchange='CodeThatSetMY(CodeThatFind(document,\"month\").selectedIndex,"+f2.yearrange[0]+"+CodeThatFind(document,\"year\").selectedIndex,4);'>");
var g2=0;
for(;g2<12;++g2)d.write("<option "+(g2==this.date.getMonth()?"selected='selected'":"")+" value='"+g2+"'>"+this.def.monthnames[g2]+"</option>");d.write("</select>");
d.write("<select align=right "+this.getCss("css",f2)+" "+(ua.nn4?"name":"id")+"='year' onchange='CodeThatSetMY(CodeThatFind(document,\"month\").selectedIndex,"+f2.yearrange[0]+"+CodeThatFind(document,\"year\").selectedIndex,4);'>");
for(g2=f2.yearrange[0];g2<=f2.yearrange[1];++g2)d.write("<option "+(g2==this.date.getFullYear()?"selected='selected'":"")+" value='"+g2+"'>"+g2+"</option>");
d.write("</select>");
if(ua.nn4)d.write("</form>");
d.write("</td>");
};
c1.parseValue=function(s,d)
{
var h2=this.def.dtype;
d=d||this.date;
var i2;
if(h2.indexOf("dd")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("dd"),2)-0);
if(!isNaN(i2)&&i2!=undefined)d.setDate(i2);
}
if(h2.indexOf("MM")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("MM"),2)-1);
if(!isNaN(i2)&&i2!=undefined)d.setMonth(i2);
}
if(h2.indexOf("yyyy")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("yyyy"),4)-0);
if(!isNaN(i2)&&i2!=undefined)d.setYear(i2);
}
if(h2.indexOf("HH")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("HH"),2)-0);
if(!isNaN(i2)&&i2!=undefined)d.setHours(i2);
}
if(h2.indexOf("mm")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("mm"),2)-0);
if(!isNaN(i2)&&i2!=undefined)d.setMinutes(i2);
}
if(h2.indexOf("ss")!=-1)
{
i2=parseInt(s.substr(h2.indexOf("ss"),2)-0);
if(!isNaN(i2)&&i2!=undefined)d.setSeconds(i2);
}
};
c1.popup=function(ctl)
{
window.codethatcalendar=this;
this.ctl=ctl;
var j2=CodeThatFind(document,ctl);
this.date=new Date();
if(j2.value!="")this.parseValue(j2.value);
var k2=window.open("calendar.html","",'width='+this.def.windoww+',height='+this.def.windowh+',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes');
k2.opener=window;k2.focus();
};
c1.innerpopup=function(ctl,ifr)
{
window.codethatcalendar=this;
this.ctl=ctl;
this.ifr=ifr;
var l2=CodeThatFind(document,ctl);
this.date=new Date();
if(l2.value!="")this.parseValue(l2.value);
var m2=CodeThatFind(document,ifr);
m2.opener=window;m2.src="calendar.html";
m2.height=this.def.windowh;
m2.width=this.def.windoww;
m2.style.visibility='visible';
};
}