function rlctrl()
{
// datectrl created by yyc 2000-6-18
// copyright (c) 2000.6 yyc, all rights reserved
// this is a free class,but you must be reserve this comments
// e-mail:yycmail@263.net
var varme,s,d,i;
var len= rlctrl.arguments.length;
if (len>0)
{
varme=rlctrl.arguments[0];
this.name=varme;
if (len>=4)
{
this.year=rlctrl.arguments[1];
this.month=rlctrl.arguments[2];
this.day=rlctrl.arguments[3];
}
else
{
today=new date();
this.year=today.getyear();
this.month=today.getmonth()+1;
this.day=today.getdate();
}
this.getdate=getcurdate;
document.writeln(<table width=160px border=0 cellpadding=0 cellspacing=0>);
document.writeln(<tr><td>);
d=new date(this.year,this.month-1,this.day);
i=d.getday();
s=getsweek(i);
s=this.year+"年"+this.month+"月"+this.day+"日–"+s
document.writeln(<input id=txt+varme+ name=txt+varme+ ondblclick=\opencls(+varme+);\ style="font-size: 9pt; font-style: normal; height: 20px; width:100%" value=+s+ readonly ></td>);
document.writeln(<td width=15px>);
document.writeln(<input type=button onclick=\opencls(+varme+);\ style=" cursor:hand;font-size: 8pt; font-style: normal;" value="▼">);
document.writeln(</td></tr>);
document.writeln("</table>");
document.writeln(<div id=div+varme+ name =div+varme+ style=" position:absolute;display:none; width: 160px">);
document.writeln(<table id=tbl+varme+ name=tbl+varme+ width=100% bgcolor=#c0c0c0 onkeyup=\dokey(+varme+,window.event.keycode) \ align=center style="color: blue; font-size: 9pt;" border=1 cellspacing=1 cellpadding=1>);
document.writeln("<tr><td colspan=7>");
document.writeln(<input id=year+varme+ name=year+varme+ value=+this.year+ style="background-color:transparent; border-bottom: green 0px solid;border-left: green 0px solid;border-right: green 0px solid; border-top: green 0px solid;color: blue;cursor: hand; font-size: 10pt; height: 15px; margin-top: 0pt; width: 35px" );
document.writeln(onmousemove =\javascript:if (this.readonly) {this.style.backgroundcolor=0xffffff; this.style.borderwidth=1;} \);
document.writeln(onmouseout =\javascript: if (this.readonly) { this.style.backgroundcolor ="transparent";this.style.borderwidth=0;} \ );
document.writeln(onclick=\javascript: this.style.cursor="default"; this.readonly=0; this.select(); this.focus(); \ );
document.writeln(onblur=\javascript:this.style.backgroundcolor="transparent"; this.style.borderwidth=0; this.style.cursor="hand"; this.readonly=1; this.value=+varme+.year;dispdate(+varme+); \ ); //tbl+varme+.focus();
document.writeln(onkeypress=\javascript:if (window.event.keycode==13||window.event.keycode ==27){ if (window.event.keycode==13) +varme+.year=this.value; this.blur(); }else if (window.event.keycode<48||window.event.keycode>57) window.event.keycode =0;\);
document.writeln(readonly maxlength=4>);
//=====================
document.writeln(年<span style="cursor:hand" onclick=\+varme+.year=+varme+.year+1;year+varme+.innertext=+varme+.year;dispdate(+varme+);\>▲</span><span style="cursor:hand" onclick=\+varme+.year=+varme+.year-1;year+varme+.innertext=+varme+.year;dispdate(+varme+);\>▼</span>);
document.writeln ( );
document.writeln(<span id=month+varme+>+this.month+</span>月<span style="cursor:hand" onclick=\+varme+.month=+varme+.month+1;if(+varme+.month>12) +varme+.month=1;month+varme+.innertext=+varme+.month;dispdate(+varme+);\>▲</span><span style="cursor:hand" onclick=\+varme+.month=+varme+.month-1;if(+varme+.month<1) +varme+.month=12;month+varme+.innertext=+varme+.month;dispdate(+varme+);\>▼</span>);
document.writeln("</td></tr>");
document.writeln(<tr style="color: yellow; " bgcolor=darkslateblue><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+0> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+1> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+2> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+3> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+4> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+5> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+6> </td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+7> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+8> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+9> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+10> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+11> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+12> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+13> </td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+14> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+15> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+16> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+17> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+18> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+19> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+20> </td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+21> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+22> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+23> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+24> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+25> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+26> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+27> </td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+28> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+29> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+30> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+31> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+32> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+33> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+34> </td></tr>);
document.writeln(<tr><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+35> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+36> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+37> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+38> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+39> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+40> </td><td style="cursor:hand" onclick=clkgrid(this,+varme+) id=td+varme+41> </td></tr>);
document.writeln("</table></div>");
return this;
}
else
{
alert("初始化日历控件错误!!")
return null;
}
}
function opencls(vme)
{
var s=vme.name;
var o=document.all("div"+s);
var o1=document.all("tbl"+s);
if (o.style.display=="none")
{
dispdate(vme);
o.style.display="block";
o1.focus();
}
else
dokey(vme,27);
}
function getcurdate()
{
return this.year+"-"+this.month+"-"+this.day;
}
function numberofdays(y,m)
{
var numdays=new array(31,28,31,30,31,30,31,31,30,31,30,31);
n=numdays[m];
if (m==1 && y%4==0) ++n
return n;
}
function dokey(vme,keycode)
{
var o,o1,i,j,k,d1,d,s;
o=document.all("div"+vme.name);
switch(keycode)
{
case 27:
o.style.display="none";
o1=document.all("txt"+vme.name);
s=o1.value;
i=s.indexof("年");
j=s.indexof("月");
k=s.indexof("日");
vme.year=math.abs(s.substring(0,i));
vme.month=math.abs(s.substring(i+1,j));
vme.day=math.abs(s.substring(j+1,k));
o1.focus;
break;
case 13:
o.style.display="none";
d=new date(vme.year,vme.month-1,vme.day);
i=d.getday();
s=getsweek(i);
o1=document.all("txt"+vme.name);
o1.value=vme.year+"年"+vme.month+"月"+vme.day+"日–"+s;
break;
case 38:
i=vme.day;
j=numberofdays(vme.year,vme.month-1);
i=i-7;
if(i>0&&i<=j)
{
d1=new date(vme.year,vme.month-1,1);
k=d1.getday();
j=vme.day+k-1;
o1=document.all("td"+vme.name+j);
o1.innerhtml=vme.day;
vme.day=i;
j=vme.day+k-1;
o1=document.all("td"+vme.name+j);
o1.innerhtml="<font color=red>"+vme.day+"</font>";
}
break;
case 40:
i=vme.day;
j=numberofdays(vme.year,vme.month-1);
i=i+7;
if(i>0&&i<=j)
{
d1=new date(vme.year,vme.month-1,1);
k=d1.getday();
j=vme.day+k-1;
o1=document.all("td"+vme.name+j);
o1.innerhtml=vme.day;
vme.day=i;
j=vme.day+k-1;
o1=document.all("td"+vme.name+j);
o1.innerhtml="<font color=red>"+vme.day+"</font>";
}
break;
case 37:
i=vme.day;
j=numberofdays(vme.year,vme.month-1);
i=i-1;
if(i>0&&i<=j)
{
d1=new date(vme.year,vme.month-1,1);
k=d1.getday();
j=math.abs(vme.day)+math.abs(k-1);
o1=document.all("td"+vme.name+j);
o1.innerhtml=vme.day;
vme.day=i;
j=math.abs(vme.day)+math.abs(k-1);
o1=document.all("td"+vme.name+j);
o1.innerhtml="<font color=red>"+vme.day+"</font>";
}
break;
case 39:
i=vme.day;
j=numberofdays(vme.year,vme.month-1);
i=i+1;
if(i>0&&i<=j)
{
d1=new date(vme.year,vme.month-1,1);
k=d1.getday();
j=math.abs(vme.day)+math.abs(k-1);
o1=document.all("td"+vme.name+j);
o1.innerhtml=vme.day;
vme.day=i;
j=math.abs(vme.day)+math.abs(k-1);
o1=document.all("td"+vme.name+j);
o1.innerhtml="<font color=red>"+vme.day+"</font>";
}
break;
}
}
function dispdate(objrl)
{
var o;
var s=objrl.name;
var y=objrl.year;
var m=objrl.month;
var d=objrl.day;
var dd=new date(y,m-1,1)
var startday=dd.getday();
var numdays=numberofdays(y,m-1);
for (var i=0;i<42;i++)
{
o=document.all("td"+s+i);
if (i>=startday&&i<startday+numdays)
if (d==i-startday+1)
o.innerhtml="<font color=red>"+d+"</font>";
else
o.innerhtml=i-startday+1;
else
o.innerhtml=""
}
}
function clkgrid(src,vme)
{
var o;
if(src.innertext!="")
{
vme.day=src.innertext;
var d=new date(vme.year,vme.month-1,vme.day);
var i=d.getday();
s=getsweek(i);
o=document.all("txt"+vme.name);
o.value=vme.year+"年"+vme.month+"月"+vme.day+"日–"+s;
o=document.all("div"+vme.name);
o.style.display="none";
}
}
function getsweek(i)
{
var s;
switch(i)
{
case 0:
s="星期日";
break;
case 1:
s="星期一";
break;
case 2:
s="星期二";
break;
case 3:
s="星期三";
break;
case 4:
s="星期四";
break;
case 5:
s="星期五";
break;
case 6:
s="星期六";
break;
}
return s;
}