function test(){
	alert("aaa");
}
function atCalendarControl(){ 

var calendar=this; 
this.calendarPad=null;
this.calendarPad1=null; 
this.prevMonth=null; 
this.nextMonth=null; 
this.goToday=null; 
this.head=null; 
this.body=null; 
this.head1=null; 
this.body1=null;
this.today=[]; 
this.currentDate=[]; 
this.sltDate; 
this.target; 
this.source; 

/************** 加入日历底板及阴影 *********************/ 
this.addCalendarPad=function(){ 
document.write("<div id='divCalendarpad' style='position:absolute;top:0;left:20;display:none;'>"); 
document.write("<div style='position:absolute;top:2;left:22;'></div>"); 
document.write("</div>"); 
calendar.calendarPad=document.all.divCalendarpad; 
}
/************** 加入日历面板 *********************/ 
this.addCalendarBoard=function(){ 
var BOARD=this; 
var divBoard=document.createElement("div"); 
calendar.calendarPad.insertAdjacentElement("beforeEnd",divBoard); 
var tbBoard=document.createElement("table"); 
divBoard.insertAdjacentElement("beforeEnd",tbBoard); 
tbBoard.style.cssText="border-style:solid;border-color:#ff0000;border-width:thin;"; 
tbBoard.cellPadding=0; 
tbBoard.cellSpacing=0;
tbBoard.height=153;
tbBoard.width=175;

/************** 设置各功能按钮的功能 *********************/ 
/*********** Calendar About Button ***************/ 
trRow = tbBoard.insertRow(0);
trRow.bgColor="#ffc650";
calendar.prevMonth = calendar.insertTbCell(trRow,0,"←","center"); 
calendar.prevMonth.title="← 上一月 "; 
calendar.prevMonth.onmousedown=function(){ 
calendar.currentDate[1]--; 
if(calendar.currentDate[1]==0){ 
calendar.currentDate[1]=12; 
calendar.currentDate[0]--; 
} 
calendar.show(calendar.target,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source); 
}
/*********** Calendar Head ***************/ 
tbCell=trRow.insertCell(1); 
tbCell.colSpan=6; 
tbCell.bgColor="#ffc650"; 
tbCell.align="center"; 
tbCell.style.cssText = "font-weight:bold;color: #000000"; 
calendar.head=tbCell; 

trRow= tbBoard.insertRow(1); 
var cnDateName = new Array("日","一","二","三","四","五","六"); 
for (var i = 0; i < 7; i++) { 
tbCell=trRow.insertCell(i); 
tbCell.innerText=cnDateName[i];
tbCell.align="center"; 
tbCell.width=18; 

tbCell.style.cssText="background-color:#da0000;color:#ffffff;font-weight:bold;font-size:11pt;"; 
} 

/*********** Calendar Body ***************/ 
trRow= tbBoard.insertRow(2); 
tbCell=trRow.insertCell(0); 
tbCell.colSpan=7; 
tbCell.height=100; 
tbCell.vAlign="top"; 
tbCell.bgColor="#ffffff"; 

var tbBody=document.createElement("table"); 
tbCell.insertAdjacentElement("beforeEnd",tbBody); 
tbBody.height=115; 
tbBody.cellPadding=0; 
tbBody.cellSpacing=0; 
calendar.body=tbBody;

} 

/************** 加入日历底板及阴影1 *********************/
this.addCalendarPad1=function(){ 
document.write("<div id='divCalendarpad1' style='position:absolute;display:none;'>"); 
document.write("<div style=''></div>"); 
document.write("</div>"); 
calendar.calendarPad1=document.all.divCalendarpad1; 
}
/************** 加入日历面板1 *********************/ 
this.addCalendarBoard1=function(){ 
var BOARD1=this; 
var divBoard1=document.createElement("div"); 
calendar.calendarPad1.insertAdjacentElement("beforeEnd",divBoard1); 
divBoard1.style.cssText=""; 

var tbBoard1=document.createElement("table"); 
divBoard1.insertAdjacentElement("beforeEnd",tbBoard1); 
tbBoard1.style.cssText="border-style:solid;border-color:#ff0000;border-width:thin;"; 
tbBoard1.cellPadding=0; 
tbBoard1.cellSpacing=0; 
tbBoard1.height=153; 
tbBoard1.width=175;
/************** 设置各功能按钮的功能 *********************/ 
/*********** Calendar About Button ***************/ 

/*********** Calendar Head ***************/
trRow1 = tbBoard1.insertRow(0);
trRow1.bgColor="#ffc650";  
tbCell1=trRow1.insertCell(0); 
tbCell1.colSpan=6; 
tbCell1.bgColor="#ffc650"; 
tbCell1.align="center"; 
tbCell1.style.cssText = "font-weight:bold;color: #000000"; 
calendar.head1=tbCell1; 
/*********** Calendar NextMonth Button ***************/ 


calendar.nextMonth = calendar.insertTbCell(trRow1,1,"→","center"); 
calendar.nextMonth.title="下一月 →"; 
calendar.nextMonth.onmousedown=function(){ 
calendar.currentDate[1]++; 
if(calendar.currentDate[1]==13){ 
calendar.currentDate[1]=1; 
calendar.currentDate[0]++; 
} 
calendar.show(calendar.target,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source); 
}


trRow1 = tbBoard1.insertRow(1); 
var cnDateName = new Array("日","一","二","三","四","五","六"); 
for (var i = 0; i < 7; i++) { 
tbCell1=trRow1.insertCell(i) 
tbCell1.innerText=cnDateName[i];
tbCell1.align="center"; 
tbCell1.width=18; 
tbCell1.style.cssText="background-color:#da0000;color:#ffffff;font-weight:bold;font-size:11pt;"; 
} 

/*********** Calendar Body ***************/ 
trRow1 = tbBoard1.insertRow(2); 
tbCell1=trRow1.insertCell(0); 
tbCell1.colSpan=7; 
tbCell1.height=100; 
tbCell1.vAlign="top"; 
tbCell1.bgColor="#ffffff"; 

var tbBody1=document.createElement("table"); 
tbCell1.insertAdjacentElement("beforeEnd",tbBody1); 
tbBody1.height=115; 
tbBody1.cellPadding=0; 
tbBody1.cellSpacing=0; 
calendar.body1=tbBody1; 

/*********** Time Body ***************/ 

} 

/************** 加入功能按钮公共样式 *********************/ 
this.insertTbCell=function(trRow,cellIndex,TXT,trAlign,tbColSpan){ 
var tbCell=trRow.insertCell(cellIndex);  
var btnCell=document.createElement("button"); 
tbCell.insertAdjacentElement("beforeEnd",btnCell);
btnCell.value=TXT; 
btnCell.style.cssText="border:0;font-weight:bold;color: #000000;background-color:#ffc650;"; 
btnCell.onmouseover=function(){ 
btnCell.style.cssText="border:0;font-weight:bold;color: #000000;background-color:#ffc650;cursor:hand;"; 

} 
btnCell.onmouseout=function(){ 
btnCell.style.cssText="border:0;font-weight:bold;color: #000000;background-color:#ffc650;"; 
} 
 
btnCell.onclick=function(){ 
btnCell.blur(); 
} 
return btnCell; 
} 

this.setDefaultDate=function(){ 
var dftDate=new Date(); 
calendar.today[0]=dftDate.getYear(); 
calendar.today[1]=dftDate.getMonth()+1; 
calendar.today[2]=dftDate.getDate();  
} 

/****************** Show Calendar *********************/ 
this.show=function(targetObject,defaultDate,sourceObject){ 
if(targetObject==undefined) { 
alert("未设置目标对象. \n方法: ATCALENDAR.show(obj 目标对象,boolean 是否返回时间,string 默认日期,obj 点击对象);\n\n目标对象:接受日期返回值的对象.\n默认日期:格式为\"yyyy-mm-dd\",缺省为当前日期.\n点击对象:点击这个对象弹出calendar,默认为目标对象.\n"); 
return false; 
} 
else calendar.target=targetObject; 

if(sourceObject==undefined) calendar.source=calendar.target; 
else calendar.source=sourceObject; 


var firstDay; 
var Cells=new Array(); 
if((defaultDate==undefined) || (defaultDate=="")){ 
var theDate=new Array(); 
calendar.head.innerText = calendar.today[0]+"年"+calendar.formatTime(calendar.today[1])+"月";

if(calendar.today[1]+1==13){
calendar.head1.innerText = calendar.today[0]+1+"年01月";
}else{
calendar.head1.innerText = calendar.today[0]+"年"+calendar.formatTime(calendar.today[1]+1)+"月";}

theDate[0]=calendar.today[0];
 theDate[1]=calendar.today[1]; 
 theDate[2]=calendar.today[2]; 
 
} 
else{ 
var Datereg=/^\d{4}-\d{1,2}-\d{2}$/ 
if(!defaultDate.match(Datereg)) { 
alert("默认日期(时间)的格式不正确！\t\n\n默认可接受格式为:\n1、yyyy-mm-dd \n2、yyyy-mm-dd hh:mm\n3、(空)"); 
calendar.setDefaultDate(); 
return; 
} 

if(defaultDate.match(Datereg)) 
var strDateTime=defaultDate.split("-");
var theDate=new Array(); 
theDate[0]=strDateTime[0]; 
theDate[1]=strDateTime[1]; 
theDate[2]=strDateTime[2]; 

calendar.head.innerText = theDate[0]+"年"+calendar.formatTime(theDate[1])+"月";
if(parseInt(theDate[1],10)+1==13){
calendar.head1.innerText = parseInt(theDate[0],10)+1+"年01月"; 
}else{
calendar.head1.innerText = theDate[0]+"年"+calendar.formatTime(parseInt(theDate[1],10)+1)+"月";  
} }
calendar.currentDate[0]=theDate[0]; 
calendar.currentDate[1]=theDate[1]; 
calendar.currentDate[2]=theDate[2]; 

theFirstDay=calendar.getFirstDay(theDate[0],theDate[1]); 
theMonthLen=theFirstDay+calendar.getMonthLen(theDate[0],theDate[1]); 
theFirstDay1=calendar.getFirstDay(theDate[0],parseInt(theDate[1],10)+1); 
theMonthLen1=theFirstDay1+calendar.getMonthLen(theDate[0],parseInt(theDate[1],10)+1); 

calendar.calendarPad.style.display="";
calendar.calendarPad1.style.display=""; 
var theRows = Math.ceil((theMonthLen)/7); 
var theRows1 = Math.ceil((theMonthLen1)/7); 
//清除旧的日历; 
while (calendar.body.rows.length > 0) { 
calendar.body.deleteRow(0) 
}
while (calendar.body1.rows.length > 0) { 
calendar.body1.deleteRow(0) 
} 
//建立新的日历; 
var n=0;day=0; 
for(i=0;i<theRows;i++){ 
theRow=calendar.body.insertRow(i); 
for(j=0;j<7;j++){ 
n++; 
if(n>theFirstDay && n<=theMonthLen){ 
day=n-theFirstDay; 
calendar.insertBodyCell(theRow,j,day,theDate[1],0); 
} 

else{ 
var theCell=theRow.insertCell(j);
theCell.style.cssText="";   
} 
} 
}
//建立新的日历1; 
var n=0;day=0;
 
for(i=0;i<theRows1;i++){ 
theRow1=calendar.body1.insertRow(i); 
for(j=0;j<7;j++){ 
n++; 
if(n>theFirstDay1 && n<=theMonthLen1){ 
day=n-theFirstDay1; 
calendar.insertBodyCell(theRow1,j,day,parseInt(theDate[1],10)+1,1);
 
} 

else{ 
var theCell=theRow1.insertCell(j); 
theCell.style.cssText=""; 
} 
} 
} 

//****************调整日历位置**************// 
var offsetPos=calendar.getAbsolutePos(calendar.source);//计算对象的位置; 
if((document.body.offsetHeight-(offsetPos.y+calendar.source.offsetHeight-document.body.scrollTop))<calendar.calendarPad.style.pixelHeight){ 
var calTop=offsetPos.y-calendar.calendarPad.style.pixelHeight; 
} 
else{ 
var calTop=offsetPos.y+calendar.source.offsetHeight; 
} 
if((document.body.offsetWidth-(offsetPos.x+calendar.source.offsetWidth-document.body.scrollLeft))>calendar.calendarPad.style.pixelWidth){ 
var calLeft=offsetPos.x; 
} 
else{ 
var calLeft=calendar.source.offsetLeft+calendar.source.offsetWidth; 
} 
if(calLeft+350>document.body.offsetWidth){ 
calendar.calendarPad.style.pixelLeft=calLeft-(calLeft+350-document.body.offsetWidth);}else{
calendar.calendarPad.style.pixelLeft=calLeft; }
calendar.calendarPad.style.pixelTop=calTop+20; 
calendar.calendarPad1.style.pixelLeft=calendar.calendarPad.style.pixelLeft+175; 
calendar.calendarPad1.style.pixelTop=calTop+20;
} 
/****************** 计算对象的位置 *************************/ 
this.getAbsolutePos = function(el) { 
var r = { x: el.offsetLeft, y: el.offsetTop }; 
if (el.offsetParent) { 
var tmp = calendar.getAbsolutePos(el.offsetParent); 
r.x += tmp.x; 
r.y += tmp.y; 
} 
return r; 
}; 

//************* 插入日期单元格 **************/ 
this.insertBodyCell=function(theRow,j,day,month,hit,targetObject){ 
var theCell=theRow.insertCell(j); 
var theBgColor="#FFFFFF"; //其他日子的颜色
if(hit==0){
var days=((parseInt(calendar.currentDate[0],10)-2000)*365+day+parseInt(calendar.currentDate[1],10)*30)*3600*24;}else{
var days=((parseInt(calendar.currentDate[0],10)-2000)*365+day+(parseInt(calendar.currentDate[1],10)+1)*30)*3600*24;
}
var nowDays=((parseInt(calendar.today[0],10)-2000)*365+parseInt(calendar.today[2],10)+parseInt(calendar.today[1],10)*30)*3600*24;

if(calendar.target.value!=""){
var textTime=calendar.target.value.split("-") ;
if(day==textTime[2]&&month==textTime[1]&&calendar.currentDate[0]==textTime[0]) var theBgColor="#ffc650";
}//文体框日子的颜色 
 
theCell.bgColor=theBgColor; 
theCell.innerText=day; 
theCell.align="center"; 
theCell.width=25; 
if(day==calendar.today[2]&&month==calendar.today[1]&&calendar.currentDate[0]==calendar.today[0]){
theCell.style.cssText="font-size:10pt;color:#000000;font-weight:bold;background-color:#FFFFFF;text-decoration:underline;";
}else{
//if(nowDays>days) {
//theCell.style.cssText="font-size:10pt;color:#888888"; 
//}else{
	
if(j==0||j==6) {theCell.style.cssText="font-size:10pt;color:#ff0000;";}else{ 
theCell.style.cssText="font-size:10pt;color:#000000;"; }}
//}
theCell.onmouseover=function(){ 
//if(days<nowDays){
//theCell.style.cssText="font-size:10pt;color:#888888";
//}else{
theCell.bgColor="#ffc650";
if(j==0||j==6) {theCell.style.cssText="font-size:10pt;color:#ff0000;cursor:hand;";}else{ 
theCell.style.cssText="font-size:10pt;color:#000000;cursor:hand;";} 
//}
if(day==calendar.today[2]&&month==calendar.today[1]&&calendar.currentDate[0]==calendar.today[0]){
theCell.style.cssText="font-size:10pt;color:#000000;font-weight:bold;background-color:#ffc650;text-decoration:underline;cursor:hand;";
}
} 
theCell.onmouseout=function(){
//if(days<nowDays){
//theCell.style.cssText="font-size:10pt;color:#888888";
//}else{ 
 
theCell.bgColor=theBgColor; 
if(j==0||j==6) {theCell.style.cssText="font-size:10pt;color:#ff0000;";}else{
theCell.style.cssText="font-size:10pt;color:#000000;"; }
//}
if(day==calendar.today[2]&&month==calendar.today[1]&&calendar.currentDate[0]==calendar.today[0]){
theCell.style.cssText="font-size:10pt;color:#000000;font-weight:bold;background-color:#FFFFFF;text-decoration:underline;";
}
} 
theCell.onmousedown=function(){ 
//if(days<nowDays) return;
theCell.bgColor="#FFFFCC"; 
theCell.style.cssText="font-size:10pt;color:#000000;"; 
} 
theCell.onclick=function(){ 
//if(days<nowDays) return;
if(hit==0){
calendar.sltDate=calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(day); }
else{
if(parseInt(calendar.currentDate[1],10)+1==13){
calendar.sltDate=parseInt(calendar.currentDate[0],10)+1+"-01"+"-"+calendar.formatTime(day);
}else{
calendar.sltDate=calendar.currentDate[0]+"-"+calendar.formatTime(parseInt(calendar.currentDate[1],10)+1)+"-"+calendar.formatTime(day);}
}
calendar.target.value=calendar.sltDate;
calendar.hide(); 
} 
} 
/************** 取得月份的第一天为星期几 *********************/ 
this.getFirstDay=function(theYear, theMonth){ 
var firstDate = new Date(theYear,theMonth-1,1); 
return firstDate.getDay(); 
} 
/************** 取得月份共有几天 *********************/ 

this.getMonthLen=function(theYear, theMonth) { 
theMonth--; 
var oneDay = 1000 * 60 * 60 * 24; 
var thisMonth = new Date(theYear, theMonth, 1); 
var nextMonth = new Date(theYear, theMonth + 1, 1); 
var len = Math.ceil((nextMonth.getTime() - thisMonth.getTime())/oneDay); 
return len; 
} 
/************** 隐藏日历 *********************/ 
this.hide=function(){ 
//calendar.clearEventKey(); 
calendar.calendarPad.style.display="none"; 
calendar.calendarPad1.style.display="none"; 
} 
/************** 从这里开始 *********************/ 
this.setup=function(defaultDate){ 

calendar.addCalendarPad();
calendar.addCalendarBoard();
calendar.addCalendarPad1();
calendar.addCalendarBoard1();  
calendar.setDefaultDate(); 
} 
/************** 格式化时间 *********************/ 
this.formatTime = function(str) { 
str = ("00"+str); 
return str.substr(str.length-2); 
} 


calendar.setup(); 
} 


