JS寫的Calendar日曆控件

<!--
//----------------------------------------------------------------------------
//  主調用函數是 wpCalendar(this,[object])wpCalendar(this),[object]是控件輸出的控件名,舉兩個例子:
//  一、<input name=txt><input type=button value="Show Calendar" οnclick="showCalendar(this,document.all.txt)">
//  二、<input οnfοcus="showCalendar(this)">
//  本日曆的年份限制是(1000 - 9999)
//  按ESC鍵關閉該控件
//  在年和月的顯示地方點擊時會分別出年與月的下拉框
//  控件外任意點擊一點即可關閉該控件


document.writeln('<iframe id=wpCalendarLayer name=wpCalendarLayer frameborder=0 οnmοuseοut="wpCalendar.correctPosition()" style="position: absolute; width: 153; height: 208; z-index: 9998; display: none"></iframe>');

var wpConsts = new function(){
 this._isIE = (navigator.userAgent.indexOf("MSIE")>0);
 this.MouseButton = this._isIE?{
  LEFTBUTTON : 1,
  RIGHTBUTTON : 0,
  MIDDLEBUTTON: 4
 }:
 {
  LEFTBUTTON : 0,
  RIGHTBUTTON : 2,
  MIDDLEBUTTON: 1
 };
};

var wpEvents = new function(){
 var self = this;
    this.arrEvents = [];
 this.addListener = function(obj, eventName, oCallback){
     var ret;
  if(wpConsts._isIE){
   ret = obj.attachEvent("on" + eventName, oCallback);
  }
  else{
   ret = obj.addEventListener(eventName, oCallback, false);
  }
  if(ret)this.arrEvents.push({"obj":obj, "eventName": eventName, "oCallback":oCallback});
  return ret;
 };
 
 this.clearListener = function(obj, eventName){
     for(var i=0;i<this.arrEvents.length;i++){
         if(this.arrEvents[i].obj == obj && this.arrEvents[i].eventName == eventName){
             this.removeListener(obj, eventName, this.arrEvents[i].oCallback);
         }
     }
 };
 
 this.removeListener = function(obj, eventName, oCallback){
     if(wpConsts._isIE){
   obj.detachEvent("on" + eventName, oCallback);
  }
  else{
   obj.removeEventListener(eventName, oCallback, true);
  }
 };

 this.initWinEvents = function(oWin){
  if(!oWin)return;
  __firefox(oWin);
 };

 /*使得firefox兼容IE的event*/
 function __firefox(oWin){
  if(!oWin)oWin = window;
  HTMLElement.prototype.__defineGetter__("runtimeStyle", self.__element_style);
  oWin.constructor.prototype.__defineGetter__("event", function(){return self.__window_event(oWin);});
  Event.prototype.__defineGetter__("srcElement", self.__event_srcElement);
 }
 this.__element_style = function(){
  return this.style;
 }
 this.__window_event = function(oWin){
  return __window_event_constructor();
 }
 this.__event_srcElement = function(){
  return this.target;
 }
 function __window_event_constructor(oWin){
  if(!oWin)oWin = window;
  if(document.all){
   return oWin.event;
  }
  var _caller = __window_event_constructor.caller;
  while(_caller!=null){
   var _argument = _caller.arguments[0];
   if(_argument){
    var _temp = _argument.constructor;
    if(_temp.toString().indexOf("Event")!=-1){
     return _argument;
    }
   }
   _caller = _caller.caller;
  }
  return null;
 }
 if(window.addEventListener){
  __firefox();
 }
 /*end firefox*/
};


function wpCalendar(){
 //==================================================== 參數設定部分 =======================================================
 this.bmoveable = true;   //設置日曆是否可以拖動
 this.datestyle = "yyyy-M-d";  //added in Ver 2.1
 this.cellwidth = 21;   //設置單個單元格的寬度
 this.cellheight = 20;   //設置單元格的高度
 this.versioninfo= "wpCanlendar Version:2.59&#13;作者:WalkingPoison"; //版本信息
 this.tgtObject = null;
 this.srcButton = null;  //點擊的按鈕
 this.outerDate = "";  //存放對象的日期
 this.oCalendar = window.frames.wpCalendarLayer.document;   //存放日曆對象
 this.Style  = document.getElementById("wpCalendarLayer").style; //存放日曆層的style
 this.MonthinMM = this.datestyle.indexOf("MM")>=0?true:false;  //added in Ver 2.1
 this.Dateindd = this.datestyle.indexOf("dd")>=0?true:false;
 this.themename = "Classic";      //主題設置,決定日曆的外觀
 this.theme  = null;      //根據主題設置得到對應的主題,在redraw函數中根據themename自動設置
 this.ScrollYearOnClick = false;   //設置年的下拉選擇框內的年份是通過點擊還是mouseover來滾動

 try{this.IE6 = (parseFloat(window.navigator.appVersion.match(/MSIE (/d+/./d+)/)[1])>=5.5)}
 catch(e){this.IE6 = false}
 this.testspeed = false;     //測試機器速度,以便自動決定是否使用Filter。如果設置爲true,則下面的playfilter參數設置無效。
 this.testtimeout= 120;      //測試標準,單位是毫秒,小於這個數值的就認爲機器速度足夠快
 this.playfilter = this.IE6;     //設置是否使用Filter

 this.year  = new Date().getFullYear(); //定義年的變量的初始值
 this.month  = new Date().getMonth()+1; //定義月的變量的初始值
 this.date  = new Date().getDate();  //定義日的變量的初始值
 this.Days  = new Array(39);   //定義寫日期的數組
 this.DateCell = new Array(39);   //存放日期單元格
 
 this.followcodes= "";      //存放執行完點擊日曆以後需要執行的操作代碼

 this.tmpTdClass = "";
 this.redraw  = function (){    //定義redraw方法,用於重繪整個日曆
  //==================================================== WEB 頁面顯示部分 =====================================================
  if(this.cellwidth<21)this.cellwidth=21;
  if(this.cellheight<20)this.cellheight=20;
  this.theme = typeof theme[this.themename] == "object"? theme[this.themename] : theme["Classic"];
  var strFrame;  //存放日曆層的HTML代碼
  strFrame='<style>';
  with(this.theme){
   strFrame+='BODY{font-family:'+fontFamily+';}';
   strFrame+='INPUT{color:'+buttonFontColor+';border-right:'+buttonBorderColor+' 1px solid;border-top:'+buttonBorderColor+' 1px solid;border-left:'+buttonBorderColor+' 1px solid;';
   strFrame+='border-bottom:'+buttonBorderColor+' 1px solid;background-color:'+buttonColor+';font-family:'+fontFamily+';}';
   strFrame+='table.main{border:1px solid '+borderColor+';width:' + (this.getCalendarWidth()-2) + 'px;height:' + this.getMainHeight() + 'px;background-color:'+bgColorMain+';}';
   strFrame+='table.dragbar{border-top:1px solid '+dragBarColor+';border-left:1px solid '+dragBarColor+';border-right:1px solid '+dragBarColorDark+';border-bottom:1px solid '+dragBarColorDark+';}';
   strFrame+='table.head{background-color:'+headBgColor+';}';
   strFrame+='td.head{background-color:'+headBgColor+';}';
   strFrame+='span.year{z-index: 9999;position:absolute;top:3px;left:20px;border: 1px solid '+borderColor+'}';
   strFrame+='table.year{width:' + (this.getYearWidth()-4) + 'px;height:140px;background-color:'+bgColorMain+';cursor:default;}';
   strFrame+='span.month{z-index: 9999;position: absolute;top: 3px;left: ' + (this.getYearWidth() + 19) + 'px;border:'+borderColor+' 1px solid}';
   strFrame+='table.month{width:' + (this.getMonthWidth()-4) + 'px;height:168px;background-color:'+bgColorMain+';cursor:default;}';
   strFrame+='TD{font-size: 12px;}';
   strFrame+='a{color:' + normalDayFontColor + ';}';
   strFrame+='table.datecell{border-top:1px solid '+dragBarColor+';border-left:1px solid '+dragBarColor+';border-right:1px solid '+dragBarColorDark+';border-bottom:1px solid '+dragBarColorDark+';}';
   strFrame+='TD.calendarhead{color: '+headFontColor+'; background-color: '+headBgColor+';border:1px solid '+headBgColor+';}';
   strFrame+='TD.mouseoverYM{text-align:center;color: '+mouseOverFontColor+'; background-color: '+mouseOverColor+';}';
   strFrame+='td.normalYM{text-align:center;color:'+normalDayFontColor+';background-color:'+normalDayColor+';}';
   strFrame+='td.selectedYM{text-align:center;color:'+selectedDayFontColor+';background-color:'+selectedDayColor+';}';
   strFrame+='TD.dragbar{font-size:12px;color:'+dragBarFontColor+';width:21px;border-bottom:1px solid '+dragBarColor+';border-right:1px solid '+dragBarColor+';border-left:1px solid '+dragBarColorDark+';border-top:1px solid '+dragBarColorDark+';}';
   strFrame+='TD.mouseover{color: '+mouseOverFontColor+'; background-color: '+mouseOverColor+';border:1px solid '+borderColor+';}';
   strFrame+='TD.normalday,TD.grayday,TD.today,TD.graytoday{border-left:1px solid '+borderColorDark+';border-top:1px solid '+borderColorDark+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';}';
   strFrame+='TD.selectedday,TD.selectedgrayday{border-left:1px solid '+borderColor+';border-top:1px solid '+borderColor+';border-right:1px solid '+borderColorDark+';border-bottom:1px solid '+borderColorDark+';}';
   strFrame+='TD.normalday{color:'+normalDayFontColor+';background-color:'+normalDayColor+';}';
   strFrame+='TD.grayday{color:'+grayDayFontColor+';background-color:'+grayDayColor+';}';
   strFrame+='TD.today{color:'+todayFontColor+';background-color:'+todayColor+';}';
   strFrame+='TD.selectedday{color:'+selectedDayFontColor+';background-color:'+selectedDayColor+';}';
   strFrame+='TD.selectedgrayday{color:'+grayDayFontColor+';background-color:'+selectedDayColor+';}';
   // 'border-left-color:'+borderColor+';border-top-color:'+borderColor+';border-right-color:'+borderColorDark+';border-bottom-color:'+borderColorDark+';}';
   strFrame+='TD.graytoday{color:'+grayDayFontColor+';background-color:'+todayColor+';}';
   // 'border-left-color:'+borderColor+';border-top-color:'+borderColor+';border-right-color:'+borderColorDark+';border-bottom-color:'+borderColorDark+';}';
  }
  strFrame+='</style>';
  strFrame+='<scr' + 'ipt>';
  strFrame+='if(window.addEventListener){parent.wpEvents.initWinEvents(window);} /*解決兼容ff事件的問題*/';
  strFrame+='var datelayerx,datelayery; /*存放日曆控件的鼠標位置*/';
  strFrame+='var bDrag=false; /*標記是否開始拖動*/';
  strFrame+='var DateLayer=parent.wpCalendar.Style;';
  strFrame+='document.οnmοusemοve=function() /*在鼠標移動事件中,如果開始拖動日曆,則移動日曆*/';
  strFrame+='{if(bDrag){';
  strFrame+='  DateLayer.left = (parseInt(DateLayer.left)+window.event.clientX-datelayerx)+"px";/*由於每次移動以後鼠標位置都恢復爲初始的位置,因此寫法與div中不同*/';
  strFrame+='  DateLayer.top = (parseInt(DateLayer.top)+window.event.clientY-datelayery)+"px";}};';
  strFrame+='function DragStart(){  /*開始日曆拖動*/';
  strFrame+=' if(window.event.button==parent.wpConsts.MouseButton.LEFTBUTTON){';
  strFrame+='  datelayerx=window.event.clientX;';
  strFrame+='  datelayery=window.event.clientY;';
  strFrame+='  bDrag=true;}}';
  strFrame+='function DragEnd(){  /*結束日曆拖動*/';
  strFrame+=' bDrag=false;}';
  strFrame+='document.οnmοusedοwn=function(){ /*點擊的時候關閉年份和月份的選擇列表*/';
  strFrame+=' var obj=document.getElementById("tmpSelectYearLayer");if(!bFromYear&&event.srcElement!=document.getElementById("CalendarYearHead")&&obj.style.display!="none"){obj.style.display="none";bYearListOpening=true}';
  strFrame+=' obj=document.getElementById("tmpSelectMonthLayer");if(event.srcElement!=document.getElementById("CalendarMonthHead")&&obj.style.display!="none")obj.style.display="none";};';
  strFrame+='var strTempClass="";';
  strFrame+='document.οncοntextmenu=function(){if(!event.ctrlKey)return false;}; /*禁止出現右鍵菜單*/';
  strFrame+='function mOver(obj){strTempClass=obj.className;obj.className="mouseoverYM";bYearListOpening=false;/*爲了顯示年份列表的時候向上滾動功能的正常使用*/}/*年/月選擇列表的mouseover處理*/';
  strFrame+='function mOut(obj){obj.className=strTempClass;}/*年/月選擇列表的mouseout處理*/';
  strFrame+='function setMonth(iMonth){parent.wpCalendar.setMonth(iMonth)}/*下拉選擇月份的處理*/';
  strFrame+='function setYear(iYear){parent.wpCalendar.setYear(iYear)}/*下拉選擇年份的處理*/';
  strFrame+='var bScrolling=false;var bYearListOpening=true;/*這個變量用於控制在剛剛顯示年份列表的時候,鼠標處於向上滾動條位置的情況下不要滾動*/';
  strFrame+='var iScroll=null;';
  strFrame+='var bFromYear=false; /*標誌爲從年份下拉列表處進行了點擊,以便不要關閉年份列表*/';
  strFrame+='function scrollYear(bUp){';
  strFrame+=' var oTable=document.getElementById("tmpSelectYearLayer").childNodes[0];';
  strFrame+=' if(bUp){';
  strFrame+='  var iMin=parseInt(oTable.rows[1].cells[0].innerHTML.replace(///D/g,/'/'));';
  strFrame+='  if(iMin>1000){oTable.deleteRow(oTable.rows.length-2);var oTd=oTable.insertRow(1).insertCell(0);';
  strFrame+='   oTd.innerHTML=(iMin-1).toString()+" 年";oTd.οnmοuseοver=Function("mOver(this)");oTd.οnmοuseοut=Function("mOut(this)");';
  strFrame+='   oTd.οnmοusedοwn=Function("setYear("+(iMin-1).toString()+")");oTd.className=(iMin-1==parent.wpCalendar.year?"selectedYM":"normalYM");';
  strFrame+='   if(bScrolling)window.setTimeout("scrollYear(true)", 100);}}';
  strFrame+=' else{';
  strFrame+='  var iMax=parseInt(oTable.rows[oTable.rows.length-2].cells[0].innerHTML.replace(///D/g,/'/'));';
  strFrame+='  if(iMax<=9999){var oTd=oTable.insertRow(oTable.rows.length-1).insertCell(0);oTable.deleteRow(1);';
  strFrame+='   oTd.innerHTML=(iMax+1).toString()+" 年";oTd.οnmοuseοver=Function("mOver(this)");oTd.οnmοuseοut=Function("mOut(this)");';
  strFrame+='   oTd.οnmοusedοwn=Function("setYear("+(iMax+1).toString()+")");oTd.className=(iMax+1==parent.wpCalendar.year?"selectedYM":"normalYM");';
  strFrame+='   if(bScrolling)window.setTimeout("scrollYear(false)", 100);}}';
  strFrame+='}';
  strFrame+='function startScroll(oTd,bUp){bFromYear=true;if(!bYearListOpening){bScrolling=true;scrollYear(bUp);}}';
  strFrame+='function stopScroll(){bYearListOpening=false;bFromYear=false;bScrolling=false;if(iScroll)clearTimeout(iScroll);}';
  strFrame+='</scr' + 'ipt>';
  with(this){
   strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false">';
   strFrame+='<span id=tmpSelectYearLayer class="year" style="display: none;"></span>';
   strFrame+='<span id=tmpSelectMonthLayer class="month" style="display: none;"></span>';
   strFrame+='<table border=1 cellspacing=0 cellpadding=0 bordercolor="' + theme.borderColor + '" class="main">';
   strFrame+='  <tr><td width=' + (getCalendarWidth()-2) + ' height=' + (cellheight) + ' class="head"><table border=0 cellspacing=1 cellpadding=0 width=' + (getCalendarWidth()-4) + ' height=' + cellheight + '>';
   strFrame+='      <tr align=center><td width=16><input title="向前翻 1 月" type=button ';
   strFrame+='             value="<" οnclick="parent.wpCalendar.goPrevMonth()" οndblclick="parent.wpCalendar.goPrevMonth()" οnfοcus="this.blur()" style="font-size: 12px; width: 16px; height: ' + (cellheight-2) + 'px">';
   strFrame+='        </td><td width=' + getYearWidth() + ' align=center class=calendarhead style="font-size:12px;cursor:default" ';
   strFrame+='οnmοuseοver="className=/'mouseover/'" οnmοuseοut="className=/'calendarhead/'" ';
   strFrame+='οnclick="parent.wpCalendar.selectYear(this.innerHTML.substring(0,4))" title="點擊這裏選擇年份" id=CalendarYearHead></td>';
   strFrame+='<td width=' + getMonthWidth() + ' align=center class=calendarhead style="font-size:12px;cursor:default" οnmοuseοver="className=/'mouseover/'" ';
   strFrame+=' οnmοuseοut="className=/'calendarhead/'" οnclick="parent.wpCalendar.selectMonth(this.innerHTML.replace(///D/g,/'/'))"';
   strFrame+='        title="點擊這裏選擇月份" id=CalendarMonthHead></td>';
   strFrame+='  <td width=16><input type=button value=">" οnclick="parent.wpCalendar.goNextMonth()" οndblclick="parent.wpCalendar.goNextMonth()" ';
   strFrame+='             οnfοcus="this.blur()" title="向後翻 1 月" style="font-size: 12px; width:16px; height: ' + (cellheight-2) + 'px"></td></tr>';
   strFrame+='    </table></td></tr>';
   strFrame+='  <tr><td width=' + (getCalendarWidth()-4) + ' height=' + (cellheight) + ' align=center>';
   strFrame+='<table align=center border=1 cellspacing=0 cellpadding=0 bgcolor='+theme.bgColorMain+' ' + (bmoveable? 'οnmοusedοwn="DragStart()" οnmοuseup="DragEnd()"':'');
   strFrame+=' class="dragbar" width=' + (getCalendarWidth()-6) + ' height=' + (cellheight) + ' style="cursor:' + (bmoveable ? 'move':'default') + '">';
   strFrame+='<tr align=center valign=bottom><td class=dragbar>日</td>';
   strFrame+='<td class=dragbar>一</td><td class=dragbar>二</td>';
   strFrame+='<td class=dragbar>三</td><td class=dragbar>四</td>';
   strFrame+='<td class=dragbar>五</td><td class=dragbar>六</td></tr>';
   strFrame+='</table></td></tr>';
   strFrame+='  <tr><td width=' + (getCalendarWidth()-2) + ' height=' + getBodyHeight() + ' align=center>';
   strFrame+='    <table align=center border=1 cellspacing=2 cellpadding=0 class="datecell" bordercolor='+theme.borderColor+' bgcolor='+theme.bgColorLight+' width=' + (getCalendarWidth()-4) + ' height=' + getBodyHeight() + '>';
   var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center>'; for (i=0;i<7;i++){
   strFrame+='<td width=' + (cellwidth) + ' height=' + (cellheight) + ' id=wpDateCell'+n+'></td>';n++;}
   strFrame+='</tr>';}
   strFrame+='      <tr align=center>';
   for (i=35;i<39;i++)strFrame+='<td width=' + (cellwidth) + ' height=' + (cellheight) + ' id=wpDateCell'+i+'></td>';
   strFrame+='        <td colspan=3 align=right class=calendarhead οnclick=parent.wpCalendar.close() style="font-size:12px;cursor: pointer;padding-right:5px;" title="' + versioninfo + '&#13;' + theme.versioninfo + '">';
   strFrame+='        <a href="javascript:void(0);">關閉</a></td></tr>';
   strFrame+='    </table></td></tr><tr><td>';
   strFrame+='        <table border=0 cellspacing=1 cellpadding=0 width=100% class="head">';
   strFrame+='          <tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td><input type=button value="<<" title="向前翻 1 年" οnclick="parent.wpCalendar.goPrevYear()" ';
   strFrame+='             οndblclick="parent.wpCalendar.goPrevYear()" οnfοcus="this.blur()" style="width:20px;font-size: 12px; height: ' + (cellheight) + 'px"><td width="1"></td><td><input title="向前翻 1 月" type=button ';
   strFrame+='             value="<" οnclick="parent.wpCalendar.goPrevMonth()" οndblclick="parent.wpCalendar.goPrevMonth()" οnfοcus="this.blur()" style="width:16px;font-size: 12px; height: ' + (cellheight) + 'px"></td></tr></table></td><td ';
   strFrame+='             align=center><input type=button value=Today οnclick="parent.wpCalendar.selectToday()" ';
   strFrame+='             οnfοcus="this.blur()" title="當前日期" style="font-size: 12px; height: ' + (cellheight) + 'px; cursor:pointer"></td><td ';
   strFrame+='             align=right><table border=0 cellspacing=0 cellpadding=0><tr><td><input type=button value=">" οnclick="parent.wpCalendar.goNextMonth()" ';
   strFrame+='             οndblclick="parent.wpCalendar.goNextMonth()" οnfοcus="this.blur()" title="向後翻 1 月" style="width:16px;font-size: 12px; height: ' + (cellheight) + 'px"><td width="1"></td><td><input ';
   strFrame+='             type=button value=">>" title="向後翻 1 年" οnclick="parent.wpCalendar.goNextYear()" οndblclick="parent.wpCalendar.goNextYear()"';
   strFrame+='             οnfοcus="this.blur()" style="width:20px;font-size: 12px; height: ' + (cellheight) + 'px"></td></tr></table></td>';
   strFrame+='</tr></table></td></tr></table></div>';
  }

  this.oCalendar.writeln(strFrame);
  this.oCalendar.close();  //解決ie進度條不結束的問題
  this.Style.width = this.getCalendarWidth();  //設置外部iframe的寬度
  this.Style.height = this.getCalendarHeight();  //設置外部iframe的高度
  
  this.MonthinMM= this.datestyle.indexOf("MM")>=0?true:false;
  this.Dateindd = this.datestyle.indexOf("dd")>=0?true:false;
  //測試速度
  if(this.testspeed){
   var t=new Date();var s="";
   for (var i=1;i<10000;i++){s=(s.length>=500?" ":s+" ");}
   if(new Date()-t<=this.testtimeout)this.playfilter = this.IE6
   else this.playfilter = false;
   delete t;delete s;
  }

  for (i=0;i<39;i++)
  {
   this.DateCell[i] = this.oCalendar.getElementById('wpDateCell'+i);
   var da = this.DateCell[i];
   da.style.cursor = "pointer";
   da.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0.5)";
   da.style.fontWeight = "bold";
   da.onmouseover = wpMouseOver;
   da.onmouseout = wpMouseOut;
   da.onclick  = Function("wpCalendar.dateCellClick("+i+")");  //給td賦予onclick事件的處理
  }

  //==================================================== WEB 頁面顯示部分 ======================================================
 }
 this.Redraw = this.redraw;

 //設置了自定義的日曆單元格寬度,以下函數用於根據單元格寬度獲得日曆寬度
 this.getCalendarWidth = function(){
  return parseInt(this.cellwidth*7+6);
 };
 this.getYearWidth = function(){    //獲取顯示年份部分的寬度
  return parseInt(((this.cellwidth*7+2)-32)*0.53);
 };
 this.getMonthWidth = function(){   //獲取顯示月份部分的寬度
  return parseInt(((this.cellwidth*7+2)-32)*0.47);
 };
 this.getCalendarHeight = function(){
  return (this.cellheight+2)*9 + 10;
 };
 this.getMainHeight = function(){
  return this.cellheight*8;
 };
 this.getBodyHeight = function(){
  return this.cellheight*6;
 };
 this.selectMonth = function (strMonth){  //顯示月份選擇列表
  if (strMonth.match(//D/)!=null)return;
  var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
  var s = '';
  s += '<table border=0 cellspacing=0 cellpadding=0 class="month">';
  for(var i=1;i<=12;i++){
   s += '<tr><td class=' + (i==parseInt(strMonth)?'selectedYM':'normalYM') + ' οnmοuseοver="mOver(this)" οnmοuseοut="mOut(this)" οnmοusedοwn="setMonth('+i+')">' + i + ' 月' + '</td></tr>';
  }
  s += '</table>';
  this.oCalendar.getElementById("tmpSelectMonthLayer").innerHTML = s;
  this.oCalendar.getElementById("tmpSelectMonthLayer").style.display="";
 };
 this.selectYear = function (strYear){  //顯示年份選擇列表,並且年份列表可以滾動
  if (strYear.match(//D/)!=null)return;
  var m = (strYear) ? strYear : new Date().getFullYear();
  if (m < 1000 || m > 9999)return;
  var n = m - 5;
  if (n < 1000) n = 1000;
  if (n + 100 > 9999) n = 9900;
  var s = '';
  with(this.theme){
   s += '<table border=0 cellspacing=0 cellpadding=0 class="year">';
   if(this.ScrollYearOnClick){
    s += '<tr><td height=5 bgcolor='+bgColorLight+' οnmοuseοver="this.bgColor=/''+bgColorMain+'/'" οnmοuseοut="stopScroll();this.bgColor=/''+bgColorLight+'/'"' +
     'οnclick="return false" οnmοusedοwn="startScroll(this,true)" οnmοuseup="stopScroll()" title="向上滾動年份"></td></tr>';
   }
   else{
    s += '<tr><td height=5 bgcolor='+bgColorLight+' οnmοuseοver="startScroll(this,true);this.bgColor=/''+bgColorMain+'/'" οnmοuseοut="stopScroll();this.bgColor=/''+bgColorLight+'/'"' +
     'οnclick="return false" title="向上滾動年份"></td></tr>';
   }
   for(var i=n;i<n+12;i++){
    s += '<tr><td class=' + (i==parseInt(strYear)?'selectedYM':'normalYM') + ' οnmοuseοver="mOver(this)" οnmοuseοut="mOut(this)" οnmοusedοwn="setYear('+i+')">' + i + ' 年' + '</td></tr>';
   }
   if(this.ScrollYearOnClick){
    s += '<tr><td height=5 bgcolor=' + this.theme.bgColorLight + ' οnmοuseοver="this.bgColor=/''+bgColorMain+'/'" οnmοuseοut="stopScroll();this.bgColor=/''+bgColorLight+'/'"' +
     'οnclick="return false" οnmοusedοwn="startScroll(this,false)" οnmοuseup="stopScroll()" title="向下滾動年份"></td></tr>';
   }
   else{
    s += '<tr><td height=5 bgcolor=' + this.theme.bgColorLight + ' οnmοuseοver="startScroll(this,false);this.bgColor=/''+bgColorMain+'/'" οnmοuseοut="stopScroll();this.bgColor=/''+bgColorLight+'/'"' +
     'οnclick="return false" title="向下滾動年份"></td></tr>';
   }
   s += '</table>';
  }
  this.oCalendar.getElementById("tmpSelectYearLayer").innerHTML = s;
  this.oCalendar.getElementById("tmpSelectYearLayer").style.display="";
 };

 this.close = function(){   //關閉日曆控件
  this.oCalendar.getElementById("tmpSelectYearLayer").style.display="none";
  this.oCalendar.getElementById("tmpSelectMonthLayer").style.display="none";
  this.Style.display="none";
 };

 function getDaysOfMonth(year,month){ //得到某年某月的天數
  return((new Date(year,month,0)).getDate());
 }

 this.goPrevYear=function (){ //往前翻 year
  if(this.year > 1000 && this.year <10000){this.year--;
  this.writeCalendar();}
 };
 this.goNextYear=function (){ //往後翻 year
  if(this.year > 999 && this.year <9999){this.year++;
  this.writeCalendar();}
 };
 this.selectToday=function (){ //Today Button
  var today;
  this.year = new Date().getFullYear();
  this.month = new Date().getMonth()+1;
  today=new Date().getDate();
  if(this.month<10 && this.MonthinMM)this.month="0" + this.month; //added in Ver 2.1
  if(today<10 && this.Dateindd)today="0" + today;
  //WriteCalendar(wpCalendar.year,wpCalendar.month);
  if(this.tgtObject){
   this.tgtObject.value=this.datestyle.replace((this.Dateindd?"dd":"d"), today).replace("yyyy", this.year).replace((this.MonthinMM?"MM":"M"), this.month);
  }
  this.close();
  if(this.followcodes!="")eval(this.followcodes);
 };
 this.goPrevMonth=function (){  //往前翻月份
  if(this.month>1){this.month--}else{this.year--;this.month=12;}
  this.writeCalendar();
 };
 this.goNextMonth=function (){  //往後翻月份
  if(this.month==12){this.year++;this.month=1}else{this.month++}
  this.writeCalendar();
 };
 this.setDateStyle=function (datestyle){ //設置日期格式的函數
  this.datestyle=datestyle;
  this.redraw();
 };
 this.setTheme=function (themename){ //設置主題爲對應的名字
  this.themename=themename;
  this.redraw();
 };

 this.setMonth=function (i){   //設置日曆的月份爲month的值,其範圍爲1~12。
  if(isNaN(i)||i<=0||i>12)return;
  this.month=parseInt(i);
  this.writeCalendar();
 };
 this.setYear=function (i){   //設置日曆的年份爲year的值,其範圍爲1000~9999。
  if(isNaN(i)||i<=999||i>9999)return;
  this.year=parseInt(i);
  this.writeCalendar();
 };
 this.setYearMonth=function (year, month){ //設置日曆的年月分別爲year和month,年月的範圍同上。
  if(isNaN(year)||year<=999||year>9999)return;
  if(isNaN(month)||month<=0||month>12)return;
  this.year=parseInt(year);
  this.month=parseInt(month);
  this.writeCalendar();
 };

 this.writeCalendar=function (){ //主要的寫程序**********
  var yy = this.year;
  var mm = this.month;
  //寫入頭部的年月
  this.oCalendar.getElementById("CalendarYearHead").innerHTML = yy + " 年";
  this.oCalendar.getElementById("CalendarMonthHead").innerHTML = mm + " 月";
  
  for (var i = 0; i < 39; i++){ //初始化邊框
  // this.DateCell[i].borderColorLight=this.theme.borderColor;
  // this.DateCell[i].borderColorDark=this.theme.borderColorDark;
  }
  var day1 = 1,day2=1,firstday = new Date(yy,mm-1,1).getDay();  //某月第一天的星期幾
  var year, month;
  for (i=0;i<firstday;i++){ //上個月的部分
   year = mm==1?yy-1:yy;
   month= mm==1?12:mm-1;
   this.Days[i]=new wpDay(year, month, getDaysOfMonth(year,month)-firstday+i+1); //上個月的最後幾天
  }
  for (i = firstday; day1 < getDaysOfMonth(yy,mm)+1; i++){ //本月的部分
   this.Days[i]=new wpDay(yy, mm, day1);day1++;
  }
  for (i=firstday+getDaysOfMonth(yy,mm);i<39;i++){ //下個月的部分
   year = mm==12?yy+1:yy;
   month= mm==12?1:mm+1;
   this.Days[i]=new wpDay(year, month, day2);day2++;
  }
  for (i=0; i<39; i++)
  {
   var da = this.DateCell[i];
   if(this.outerDate && this.Days[i].equals(this.outerDate)){
    if(i<8 && this.Days[i].day>20 || i>=28 && this.Days[i].day<12)da.className="selectedgrayday"
    else da.className="selectedday";
    //da.borderColorLight=this.theme.borderColorDark;
    //da.borderColorDark=this.theme.borderColor;
   }
   else if(this.Days[i].equals(new Date())){
    if(i<8 && this.Days[i].day>20 || i>=28 && this.Days[i].day<12)da.className="graytoday"
    else da.className="today";
   }
   else{
    if(i<8 && this.Days[i].day>20 || i>=28 && this.Days[i].day<12)da.className="grayday"
    else da.className="normalday";
   }
   da.innerHTML=this.Days[i].day;
   da.title=this.Days[i].date;
  }
 };

 this.dateCellClick=function (n){  //點擊顯示框選取日期,主輸入函數*************
  if (this.tgtObject){
   this.tgtObject.value= this.Days[n].date; //modified in Ver 2.51
   this.close(); this.tgtObject.blur();
  }
  else {this.close(); alert("您所要輸出的控件對象並不存在!");}
  if(this.followcodes!="")eval(this.followcodes);
 };

 //當鼠標移動出iframe的時候糾正日曆位置的函數,使得日曆更加不容易停下來
 //*但是當鼠標移動太快,並且在外面產生了mousemove的事件以後日曆仍然會停下來
 this.correctPosition = function(){
  var CalendarWindow = window.frames.wpCalendarLayer;
  if(CalendarWindow.bDrag){
   var x = event.clientX - CalendarWindow.datelayerx;
   var y = event.clientY - CalendarWindow.datelayery;
   this.Style.left = (x<0?0:x) + "px";
   this.Style.top = (y<0?0:y) + "px";
  }
 };

 var self = this; //用於下面的內部函數可以訪問到wpCalendar對象本身
 function wpMouseOver() {
  if(self.playfilter)this.filters[0].Apply();
  // After you set Apply, changes to the oDiv object
  //  are not displayed until Play is called.
  self.tmpTdClass = this.className;
  this.className   = "mouseover";
  if(self.playfilter)this.filters[0].Play();
 }
 function wpMouseOut(){
  if(self.playfilter)this.filters[0].Apply();
  this.className = self.tmpTdClass;
  if(self.playfilter)this.filters[0].Play();
 }

 //抽象的日期對象,初始化接受年月日的參數,月的範圍是1到12
 function wpDay(year, month, day){
  this.year = year;
  this.month = month;
  this.day = day;
  var mm=month;var n=day;
  if (month < 10 && self.MonthinMM)mm = "0" + mm;
  if (day < 10 && self.Dateindd)n = "0" + n;
  //提示文字變爲與輸出格式完全一致,好不好有待實踐證明
  this.date = self.datestyle.replace((self.Dateindd?"dd":"d"), n).replace("yyyy", year).replace((self.MonthinMM?"MM":"M"), mm);

  //判斷是否與另一個日期相等的函數,接受的參數是日期對象
  this.equals = function(eDate){
   try{return this.year==eDate.getFullYear() && this.month==eDate.getMonth()+1 && this.day==eDate.getDate();}
   catch(e){return false}
  }
 }
}

function CalendarTheme(){
 this.versioninfo  = ""; //主題的版本信息
 this.fontFamily   = ""; //字體
 this.borderColor  = ""; //邊框顏色
 this.borderColorDark = ""; //邊框暗部顏色
 this.bgColorMain  = ""; //日曆主背景色
 this.bgColorLight  = ""; //日曆的淺背景色
 this.headBgColor  = ""; //日曆頭部背景色
 this.headFontColor  = ""; //日曆頭部字體顏色
 this.mouseOverColor  = ""; //鼠標移動的背景色
 this.mouseOverFontColor = ""; //鼠標移動的字體顏色
 this.buttonBorderColor = ""; //按鈕邊框顏色
 this.buttonColor  = ""; //按鈕的主色調
 this.buttonFontColor = ""; //按鈕文字顏色
 this.dragBarFontColor = ""; //拖動條的文字顏色
 this.dragBarColor  = ""; //拖動條的邊框顏色
 this.dragBarColorDark = ""; //拖動條的邊框暗部顏色
 this.normalDayColor  = ""; //日期的背景顏色
 this.normalDayFontColor = ""; //日期的字體顏色
 this.grayDayColor  = ""; //非本月日期的背景顏色
 this.grayDayFontColor = ""; //非本月日期的字體顏色
 this.todayColor   = ""; //當前日期的背景顏色
 this.todayFontColor  = ""; //當前日期的字體顏色
 this.selectedDayColor = ""; //選中日期的背景顏色
 this.selectedDayFontColor=""; //選中日期的字體顏色
}
setday=showCalendar; //保留老的調用方式
function showCalendar() //主調函數
{
 var obj;
 if (arguments.length == 0){alert("對不起!您沒有傳回本控件任何參數!");return;}
 var tt=arguments[0];
 wpCalendar.followcodes=""; //每次調用的時候都初始化followCodes的內容
 if(arguments.length==2){
  if(typeof(arguments[1])=="object")obj=arguments[1]
  else if(typeof(arguments[1])=="string")wpCalendar.followcodes=arguments[1];
 }else if(arguments.length==3){
  obj=arguments[1];
  wpCalendar.followcodes=arguments[1];
 }
 
 var dads  = wpCalendar.Style;
 var th = tt;
 var ttop  = tt.offsetTop;  //TT控件的定位點高
 var thei  = tt.clientHeight; //TT控件本身的高
 var twid  = tt.clientWidth;  //TT控件本身的寬 //added in Ver 2.2
 var tleft = tt.offsetLeft;  //TT控件的定位點寬
 var ttyp  = tt.type;   //TT控件的類型
 while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
 //同時滿足1.總高度足以放得下日曆控件;2.下方剩餘高度不足日曆控件高度;3.上方高度大於日曆控件高度 這3個條件的時候日曆將會顯示在上方
 if(document.body.clientHeight>211 + thei && document.body.clientHeight-(ttop-document.body.scrollTop)<211+thei && ttop-document.body.scrollTop>211) //added in Ver 2.1
  dads.top = ttop-211
 else dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
 var cwidth = wpCalendar.getCalendarWidth();
 if(document.body.clientWidth-(tleft-document.body.scrollLeft)<cwidth && tleft-document.body.scrollLeft>cwidth) //added in Ver 2.2
  dads.left = tleft + twid - cwidth + ((ttyp=="image")? 0:4)
 else dads.left = tleft;
 wpCalendar.tgtObject = !obj ? th : obj;
 wpCalendar.srcButton = !obj ? null : th; //設定外部點擊的按鈕
 //根據當前輸入框的日期顯示日曆的年月
 var reg = new RegExp("^" + wpCalendar.datestyle.replace((wpCalendar.Dateindd?"dd":"d"),"(//d{1,2})").replace("yyyy","(//d{4})").replace((wpCalendar.MonthinMM?"MM":"M"), "(//d{1,2})")+"$"); //added in Ver 2.1
 var r = wpCalendar.tgtObject.value.match(reg);
 if(r!=null){
  var t=getIndex();
  r[t[2]]=r[t[2]]-1;
  if(wpCalendar.datestyle.indexOf("d")<0)r[t[3]]=1;   //使用一個"d"就可以包括兩種情況  //added in Ver 2.1
  var d= new Date(r[t[1]], r[t[2]],r[t[3]]);
  if(d.getFullYear()==r[t[1]] && d.getMonth()==r[t[2]] && d.getDate()==r[t[3]]){
   wpCalendar.outerDate=d;  //保存外部傳入的日期
  }
  else wpCalendar.outerDate="";
  wpCalendar.year =parseInt(r[t[1]]);
  wpCalendar.month=parseInt(r[t[2]])+1;
 }
 else{
  wpCalendar.outerDate="";
  wpCalendar.year =new Date().getFullYear();
  wpCalendar.month=new Date().getMonth() + 1;
 }
 wpCalendar.writeCalendar();
 dads.display = '';

 event.returnValue=false;

 function getIndex(){ //根據日期格式設置返回年月日分別所在的位置 //added in Ver 2.1
  var i,j;
  var m=eval("new Array(wpCalendar.datestyle.indexOf(/"yyyy/"), wpCalendar.datestyle.indexOf(/"M/")" + (wpCalendar.datestyle.indexOf("d")>=0?", wpCalendar.datestyle.indexOf(/"d/")":"") + ")"); //使用一個"M"和一個"d"就可以包括兩種情況
  var t=new Array();
  for(i=1;i<=m.length;i++){
   t[i]=1;
   for(j=1;j<=m.length;j++)if(i!=j && m[i-1]>m[j-1])t[i]++;
  }
  if(m.length<3)t[3]=3;
  return t;
 }
}


wpEvents.addListener(document,"click",function(){  //任意點擊時關閉該控件
 with(window.event)
  if (srcElement != wpCalendar.tgtObject && srcElement != wpCalendar.srcButton)
  wpCalendar.close();
});

wpEvents.addListener(document,"keyup",function(){  //按Esc鍵關閉,切換焦點關閉
 if (window.event.keyCode==27){
  if(wpCalendar.tgtObject)wpCalendar.tgtObject.blur();
  wpCalendar.close();
 }
 else if(document.activeElement)
  if(document.activeElement != wpCalendar.tgtObject && document.activeElement != wpCalendar.srcButton)
   wpCalendar.close();
});

var theme=new Object();

 theme["Classic"]=new CalendarTheme();
 theme["Classic"].versioninfo  = "主題:Classic 作者:WalkingPoison"; //主題的版本信息
 theme["Classic"].fontFamily   = "宋體";  //字體
 theme["Classic"].borderColor  = "#FF9900"; //邊框顏色
 theme["Classic"].borderColorDark = "#FFFFFF"; //邊框暗部顏色
 theme["Classic"].bgColorMain  = "#FF9900"; //日曆主背景色
 theme["Classic"].bgColorLight  = "#FFF8EC"; //日曆的淺背景色
 theme["Classic"].headBgColor  = "#FFFFFF"; //日曆頭部背景色
 theme["Classic"].headFontColor  = "#000000"; //日曆頭部字體顏色
 theme["Classic"].mouseOverColor  = "#FFD700"; //鼠標移動的背景色
 theme["Classic"].mouseOverFontColor = "#000000"; //鼠標移動的字體顏色
 theme["Classic"].buttonBorderColor = "#FF9900"; //按鈕邊框顏色
 theme["Classic"].buttonColor  = "#FFF8EC"; //按鈕的主色調
 theme["Classic"].buttonFontColor = "#000000"; //按鈕文字顏色
 theme["Classic"].dragBarFontColor = "#FFFFFF"; //拖動條的文字顏色
 theme["Classic"].dragBarColor  = "#FF9900"; //拖動條的邊框顏色
 theme["Classic"].dragBarColorDark = "#FFFFFF"; //拖動條的邊框暗部顏色
 theme["Classic"].normalDayColor  = "#E0E0E0"; //日期的背景顏色
 theme["Classic"].normalDayFontColor = "#000000"; //日期的字體顏色
 theme["Classic"].grayDayColor  = "#E0E0E0"; //非本月日期的背景顏色
 theme["Classic"].grayDayFontColor = "#808080"; //非本月日期的字體顏色
 theme["Classic"].todayColor   = "#FFD700"; //當前日期的背景顏色
 theme["Classic"].todayFontColor  = "#000000"; //當前日期的字體顏色
 theme["Classic"].selectedDayColor = "#00FFFF"; //選中日期的背景顏色
 theme["Classic"].selectedDayFontColor="#000000"; //選中日期的字體顏色

 theme["NewAge"]=new CalendarTheme();
 theme["NewAge"].versioninfo   = "主題:NewAge 作者:WalkingPoison"; //主題的版本信息
 theme["NewAge"].fontFamily   = "宋體";  //字體
 theme["NewAge"].borderColor   = "#336699"; //邊框顏色
 theme["NewAge"].borderColorDark  = "#FFFFFF"; //邊框暗部顏色
 theme["NewAge"].bgColorMain   = "#336699"; //日曆主背景色
 theme["NewAge"].bgColorLight  = "#F0F8FF"; //日曆的淺背景色
 theme["NewAge"].headBgColor   = "#FFFFFF"; //日曆頭部背景色
 theme["NewAge"].headFontColor  = "#000000"; //日曆頭部字體顏色
 theme["NewAge"].mouseOverColor  = "#add8e6"; //鼠標移動的背景色
 theme["NewAge"].mouseOverFontColor = "#000000"; //鼠標移動的字體顏色
 theme["NewAge"].buttonBorderColor = "#336699"; //按鈕邊框顏色
 theme["NewAge"].buttonColor   = "#F0F8FF"; //按鈕的主色調
 theme["NewAge"].buttonFontColor  = "#000000"; //按鈕文字顏色
 theme["NewAge"].dragBarFontColor = "#FFFFFF"; //拖動條的文字顏色
 theme["NewAge"].dragBarColor  = "#336699"; //拖動條的邊框顏色
 theme["NewAge"].dragBarColorDark = "#336699"; //拖動條的邊框暗部顏色
 theme["NewAge"].normalDayColor  = "#fff0f5"; //日期的背景顏色
 theme["NewAge"].normalDayFontColor = "#000000"; //日期的字體顏色
 theme["NewAge"].grayDayColor  = "#fff0f5"; //非本月日期的背景顏色
 theme["NewAge"].grayDayFontColor = "#808080"; //非本月日期的字體顏色
 theme["NewAge"].todayColor   = "#add8e6"; //當前日期的背景顏色
 theme["NewAge"].todayFontColor  = "#000000"; //當前日期的字體顏色
 theme["NewAge"].selectedDayColor = "#336699"; //選中日期的背景顏色
 theme["NewAge"].selectedDayFontColor= "#FFFFFF"; //選中日期的字體顏色

 theme["Nostalgia"]=new CalendarTheme();
 theme["Nostalgia"].versioninfo   = "主題:Nostalgia 作者:WalkingPoison"; //主題的版本信息
 theme["Nostalgia"].fontFamily   = "宋體";  //字體
 theme["Nostalgia"].borderColor   = "#CC3300"; //邊框顏色
 theme["Nostalgia"].borderColorDark  = "#CC3300"; //邊框暗部顏色
 theme["Nostalgia"].bgColorMain   = "#CC3300"; //日曆主背景色
 theme["Nostalgia"].bgColorLight   = "#FFF8EC"; //日曆的淺背景色
 theme["Nostalgia"].headBgColor   = "#FFFFFF"; //日曆頭部背景色
 theme["Nostalgia"].headFontColor  = "#000000"; //日曆頭部字體顏色
 theme["Nostalgia"].mouseOverColor  = "#FFD700"; //鼠標移動的背景色
 theme["Nostalgia"].mouseOverFontColor = "#000000"; //鼠標移動的字體顏色
 theme["Nostalgia"].buttonBorderColor = "#CC3300"; //按鈕邊框顏色
 theme["Nostalgia"].buttonColor   = "#FFF8EC"; //按鈕的主色調
 theme["Nostalgia"].buttonFontColor  = "#000000"; //按鈕文字顏色
 theme["Nostalgia"].dragBarFontColor  = "#FFFFFF"; //拖動條的文字顏色
 theme["Nostalgia"].dragBarColor   = "#CC3300"; //拖動條的邊框顏色
 theme["Nostalgia"].dragBarColorDark  = "#FFFFFF"; //拖動條的邊框暗部顏色
 theme["Nostalgia"].normalDayColor  = "#ffefd5"; //日期的背景顏色
 theme["Nostalgia"].normalDayFontColor = "#000000"; //日期的字體顏色
 theme["Nostalgia"].grayDayColor   = "#ffefd5"; //非本月日期的背景顏色
 theme["Nostalgia"].grayDayFontColor  = "#808080"; //非本月日期的字體顏色
 theme["Nostalgia"].todayColor   = "#FFD700"; //當前日期的背景顏色
 theme["Nostalgia"].todayFontColor  = "#000000"; //當前日期的字體顏色
 theme["Nostalgia"].selectedDayColor  = "#CCFFFF"; //選中日期的背景顏色
 theme["Nostalgia"].selectedDayFontColor = "#000000"; //選中日期的字體顏色

 theme["Icicle"]=new CalendarTheme();
 theme["Icicle"].versioninfo   = "主題:Icicle 作者:WalkingPoison"; //主題的版本信息
 theme["Icicle"].fontFamily   = "宋體";  //字體
 theme["Icicle"].borderColor   = "#00bfff"; //邊框顏色
 theme["Icicle"].borderColorDark  = "#ffffff"; //邊框暗部顏色
 theme["Icicle"].bgColorMain   = "#00bfff"; //日曆主背景色
 theme["Icicle"].bgColorLight  = "#f0faff"; //日曆的淺背景色
 theme["Icicle"].headBgColor   = "#FFFFFF"; //日曆頭部背景色
 theme["Icicle"].headFontColor  = "#000000"; //日曆頭部字體顏色
 theme["Icicle"].mouseOverColor  = "#e0e9ff"; //鼠標移動的背景色
 theme["Icicle"].mouseOverFontColor = "#000000"; //鼠標移動的字體顏色
 theme["Icicle"].buttonBorderColor = "#87cefa"; //按鈕邊框顏色
 theme["Icicle"].buttonColor   = "#FFF8EC"; //按鈕的主色調
 theme["Icicle"].buttonFontColor  = "#000000"; //按鈕文字顏色
 theme["Icicle"].dragBarFontColor = "#336699"; //拖動條的文字顏色
 theme["Icicle"].dragBarColor  = "#00bfff"; //拖動條的邊框顏色
 theme["Icicle"].dragBarColorDark = "#FFFFFF"; //拖動條的邊框暗部顏色
 theme["Icicle"].normalDayColor  = "#e0e9ff"; //日期的背景顏色
 theme["Icicle"].normalDayFontColor = "#336699"; //日期的字體顏色
 theme["Icicle"].grayDayColor  = "#e0e9ff"; //非本月日期的背景顏色
 theme["Icicle"].grayDayFontColor = "#808080"; //非本月日期的字體顏色
 theme["Icicle"].todayColor   = "#FFD700"; //當前日期的背景顏色
 theme["Icicle"].todayFontColor  = "#336699"; //當前日期的字體顏色
 theme["Icicle"].selectedDayColor = "#CCFFFF"; //選中日期的背景顏色
 theme["Icicle"].selectedDayFontColor= "#336699"; //選中日期的字體顏色

 theme["Greenbrier"]=new CalendarTheme();
 theme["Greenbrier"].versioninfo   = "主題:Greenbrier 作者:liuliu"; //主題的版本信息
 theme["Greenbrier"].fontFamily   = "宋體";  //字體
 theme["Greenbrier"].borderColor   = "#32CD32"; //邊框顏色
 theme["Greenbrier"].borderColorDark  = "#32CD32"; //邊框暗部顏色
 theme["Greenbrier"].bgColorMain   = "#32CD32"; //日曆主背景色
 theme["Greenbrier"].bgColorLight  = "#FFF8EC"; //日曆的淺背景色
 theme["Greenbrier"].headBgColor   = "#FFFFFF"; //日曆頭部背景色
 theme["Greenbrier"].headFontColor  = "#000000"; //日曆頭部字體顏色
 theme["Greenbrier"].mouseOverColor  = "#FFD700"; //鼠標移動的背景色
 theme["Greenbrier"].mouseOverFontColor = "#000000"; //鼠標移動的字體顏色
 theme["Greenbrier"].buttonBorderColor = "#2E8B57"; //按鈕邊框顏色
 theme["Greenbrier"].buttonColor   = "#FFF8EC"; //按鈕的主色調
 theme["Greenbrier"].buttonFontColor  = "#000000"; //按鈕文字顏色
 theme["Greenbrier"].dragBarFontColor = "#FFFFFF"; //拖動條的文字顏色
 theme["Greenbrier"].dragBarColor  = "#2E8B57"; //拖動條的邊框顏色
 theme["Greenbrier"].dragBarColorDark = "#FFFFFF"; //拖動條的邊框暗部顏色
 theme["Greenbrier"].normalDayColor  = "#FFF8DC"; //日期的背景顏色
 theme["Greenbrier"].normalDayFontColor = "#000000"; //日期的字體顏色
 theme["Greenbrier"].grayDayColor  = "#FFF8DC"; //非本月日期的背景顏色
 theme["Greenbrier"].grayDayFontColor = "#808080"; //非本月日期的字體顏色
 theme["Greenbrier"].todayColor   = "#FFD700"; //當前日期的背景顏色
 theme["Greenbrier"].todayFontColor  = "#000000"; //當前日期的字體顏色
 theme["Greenbrier"].selectedDayColor = "#00FFFF"; //選中日期的背景顏色
 theme["Greenbrier"].selectedDayFontColor= "#000000"; //選中日期的字體顏色

 theme["DiabloII"]=new CalendarTheme();
 theme["DiabloII"].versioninfo   = "主題:DiabloII 作者:WalkingPoison"; //主題的版本信息
 theme["DiabloII"].fontFamily   = "宋體";  //字體
 theme["DiabloII"].borderColor   = "#928a70"; //邊框顏色
 theme["DiabloII"].borderColorDark  = "#928a70"; //邊框暗部顏色
 theme["DiabloII"].bgColorMain   = "#333333"; //日曆主背景色
 theme["DiabloII"].bgColorLight   = "#333333"; //日曆的淺背景色
 theme["DiabloII"].headBgColor   = "#333333"; //日曆頭部背景色
 theme["DiabloII"].headFontColor   = "#928a70"; //日曆頭部字體顏色
 theme["DiabloII"].mouseOverColor  = "#666666"; //鼠標移動的背景色
 theme["DiabloII"].mouseOverFontColor = "#afafaf"; //鼠標移動的字體顏色
 theme["DiabloII"].buttonBorderColor  = "#333333"; //按鈕邊框顏色
 theme["DiabloII"].buttonColor   = "#333333"; //按鈕的主色調
 theme["DiabloII"].buttonFontColor  = "#928a70"; //按鈕文字顏色
 theme["DiabloII"].dragBarFontColor  = "#928a70"; //拖動條的文字顏色
 theme["DiabloII"].dragBarColor   = "#333333"; //拖動條的邊框顏色
 theme["DiabloII"].dragBarColorDark  = "#333333"; //拖動條的邊框暗部顏色
 theme["DiabloII"].normalDayColor  = "#333333"; //日期的背景顏色
 theme["DiabloII"].normalDayFontColor = "#928a70"; //日期的字體顏色
 theme["DiabloII"].grayDayColor   = "#333333"; //非本月日期的背景顏色
 theme["DiabloII"].grayDayFontColor  = "#afafaf"; //非本月日期的字體顏色
 theme["DiabloII"].todayColor   = "#333333"; //當前日期的背景顏色
 theme["DiabloII"].todayFontColor  = "#2e8b57"; //當前日期的字體顏色
 theme["DiabloII"].selectedDayColor  = "#666666"; //選中日期的背景顏色
 theme["DiabloII"].selectedDayFontColor = "#ffcc33"; //選中日期的字體顏色

var wpCalendar=new wpCalendar();
wpCalendar.redraw();

// -->

 

 

 

 

 

引用:

 

<asp:TextBox ID="txtOperTimeStart" runat="server" Width="120px"></asp:TextBox>
                        <img alt="" src="../images/calendar.jpg" οnclick="showCalendar(this,document.all.txtOperTimeStart)" />

發佈了32 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章