function CalendarSelector(glb_name,st_Date,ed_Date,skip_day)
{if(document.getElementById('CalendarSelectorLayer_'+glb_name)==null)
{var HTML='<div ID="CalendarSelectorLayer_glb_name" style="width: 160px;padding: 5px 5px 5px 5px;border: 1px #FFCC66 solid;"><CENTER><span style="cursor: pointer;font-size: 12px;" onclick=glb_name.seek_month(-1); onfocus=this.blur();><<</span> <span style="cursor: pointer;font-size: 12px;" onclick=glb_name.Today(); onfocus=this.blur();>T</span> <span style="cursor: pointer;font-size: 12px;" onclick=glb_name.seek_month(1); onfocus=this.blur();>>></span> <INPUT TYPE=text ID=CalendarSelectorYear_glb_name size=4 maxlength=4 style="width: 40px;" onchange=glb_name.changeYear(this.value);>&nbsp;<INPUT TYPE=text ID=CalendarSelectorMonth_glb_name size=2 maxlength=2 style="width: 20px;" onchange=glb_name.changeMonth(this.value);>&nbsp;&nbsp;<span style="font-size: 12px;">[<span style="cursor: pointer;" onfocus=this.blur(); onclick=glb_name.CSL.style.display="none";>X</span>]</span> <TABLE ID=CalendarSelectorTable_glb_name border=1 cellpadding=2 cellspacing=0><tr><td style="color: #F8D017;">日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td style="color: #C5B83D;;">六</td></tr></TABLE></CENTER></div>';document.body.innerHTML+=HTML.replace(new RegExp('glb_name','g'),glb_name);}
if(typeof(st_Date)=='undefined'||st_Date=='')st_Date='0000-00-00';if(typeof(ed_Date)=='undefined'||ed_Date=='')ed_Date='9999-99-99';if(typeof(skip_day)=='undefined'||skip_day=='')skip_day=[];this.st_Date=st_Date;this.ed_Date=ed_Date;this.skip_day=skip_day;this.CSL=document.getElementById('CalendarSelectorLayer_'+glb_name);this.CST=document.getElementById('CalendarSelectorTable_'+glb_name);this.ud=new Date();this.ud_1=new Date();this.month_max=[31,28,31,30,31,30,31,31,30,31,30,31];this.getYear=function()
{var y=this.ud.getYear();if(y<1900)y+=1900;return y;}
this.getMonth=function()
{return this.ud.getMonth();}
this.setYear=function(y)
{this.ud.setYear(y);}
this.setMonth=function(m)
{this.ud.setMonth(m);}
this.setDate=function(d)
{this.ud.setDate(d);}
this.bissextile=function()
{y=this.getYear();this.month_max[1]=28;if(y%100==0&&y%400!=0)return;if(y%3200==0)return;this.month_max[1]=(y%4==0)?29:28;}
this.seek_month=function(i)
{this.setMonth(this.getMonth()+i);this.drow();}
this.changeYear=function(y)
{this.setYear(y);this.drow();}
this.changeMonth=function(m)
{this.setMonth(m-1);this.drow();}
this.callback=null;this.selectDate=function(d)
{this.ud.setDate(d);document.getElementById('CalendarSelectorLayer_'+glb_name).style.display='none';if(this.callback!=null)
{this.callback();}}
this.Today=function()
{this.ud=new Date();this.drow();}
this.drow=function()
{while(this.CST.rows.length>1)this.CST.deleteRow(this.CST.rows.length-1);ud_1=new Date(this.getYear(),this.getMonth(),1);document.getElementById('CalendarSelectorYear_'+glb_name).value=this.getYear();document.getElementById('CalendarSelectorMonth_'+glb_name).value=this.getMonth()+1;var tr,td,w,d=0;var skip=ud_1.getDay();tr=this.CST.insertRow(-1);tr.align='right';while(skip--)
{td=tr.insertCell(-1);td.innerHTML=' ';++d;}
this.bissextile();var month_max=this.month_max[this.getMonth()];var date_str;for(var i=1;i<=month_max;++i)
{w=d%7;if(w==0)
{tr=this.CST.insertRow(-1);tr.align='right';}
td=tr.insertCell(-1);date_str=this.getYear()+'-'+this.digital(this.getMonth()+1,2)+'-'+this.digital(i,2);if(date_str>=this.st_Date&&date_str<=this.ed_Date&&!this.check_skip_day(w))
{td.innerHTML='<span style="cursor: pointer;" onclick="'+glb_name+'.selectDate('+i+');">'+i+'</span>';}
else td.innerHTML=i;if(w==0)
{td.style.color='#F8D017';}
else if(w==6)
{td.style.color='#C5B83D';}
++d;}
while(w!=6)
{td=tr.insertCell(-1);td.innerHTML=' ';w=d++%7;}}
this.digital=function(num,len)
{num=num.toString();while(num.length<len)
{num='0'+num;}
return num;}
this.toString=function()
{var str=this.getYear();str+='-'+this.digital(this.getMonth()+1,2);str+='-'+this.digital(this.ud.getDate(),2);return str;}
this.check_skip_day=function(d)
{i=this.skip_day.length;while(i--)
{if(this.skip_day[i]==d)break;}
return i!=-1?true:false;}}