document.writeln("<SCRIPT language=JavaScript> ");
document.writeln("var lunarInfo=new Array(");
document.writeln("0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,");
document.writeln("0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,");
document.writeln("0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,");
document.writeln("0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,");
document.writeln("0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,");
document.writeln("0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,");
document.writeln("0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,");
document.writeln("0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,");
document.writeln("0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,");
document.writeln("0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,");
document.writeln("0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,");
document.writeln("0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,");
document.writeln("0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,");
document.writeln("0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,");
document.writeln("0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0,");
document.writeln("0x14b63);");
document.writeln("var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);");
document.writeln("var Gan=new Array(\"甲\",\"乙\",\"丙\",\"丁\",\"戊\",\"己\",\"庚\",\"辛\",\"壬\",\"癸\");");
document.writeln("var Zhi=new Array(\"子\",\"丑\",\"寅\",\"卯\",\"辰\",\"巳\",\"午\",\"未\",\"申\",\"酉\",\"戌\",\"亥\");");
document.writeln("var nStr1 = new Array(\'日\',\'一\',\'二\',\'三\',\'四\',\'五\',\'六\',\'七\',\'八\',\'九\',\'十\');");
document.writeln("var nStr2 = new Array(\'初\',\'十\',\'廿\',\'卅\',\'　\');");
document.writeln("var nStr3 = new Array(\'日\',\'一\',\'二\',\'三\',\'四\',\'五\',\'六\',\'七\',\'八\',\'九\',\'十\',\'十一\',\'十二\');");
document.writeln("function lYearDays(y) {");
document.writeln("   var i, sum = 348;");
document.writeln("   for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0;");
document.writeln("   return(sum+leapDays(y));");
document.writeln("}");
document.writeln("function leapDays(y) {");
document.writeln("   if(leapMonth(y))  return((lunarInfo[y-1900] & 0x10000)? 30: 29);");
document.writeln("   else return(0);");
document.writeln("}");
document.writeln("function leapMonth(y) {");
document.writeln("   return(lunarInfo[y-1900] & 0xf);");
document.writeln("}");
document.writeln("function monthDays(y,m) {");
document.writeln("   return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 );");
document.writeln("}");
document.writeln("function Lunar(objDate) {");
document.writeln("   var i, leap=0, temp=0;");
document.writeln("   var offset   = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))\/86400000;");
document.writeln("   this.dayCyl = offset + 40;");
document.writeln("   this.monCyl = 14;");
document.writeln("   for(i=1900; i<2050 && offset>0; i++) {");
document.writeln("      temp = lYearDays(i);");
document.writeln("      offset -= temp;");
document.writeln("      this.monCyl += 12;");
document.writeln("   }");
document.writeln("   if(offset<0) {");
document.writeln("      offset += temp;");
document.writeln("      i--;");
document.writeln("      this.monCyl -= 12;");
document.writeln("   }");
document.writeln("   this.year = i;");
document.writeln("   this.yearCyl = i-1864;");
document.writeln(" ");
document.writeln("   leap = leapMonth(i); \/\/闰哪个月");
document.writeln("   this.isLeap = false;");
document.writeln(" ");
document.writeln("   for(i=1; i<13 && offset>0; i++) {");
document.writeln("      \/\/闰月");
document.writeln("      if(leap>0 && i==(leap+1) && this.isLeap==false)");
document.writeln("         { --i; this.isLeap = true; temp = leapDays(this.year); }");
document.writeln("      else");
document.writeln("         { temp = monthDays(this.year, i); } ");
document.writeln("      if(this.isLeap==true && i==(leap+1)) this.isLeap = false; ");
document.writeln("      offset -= temp;");
document.writeln("      if(this.isLeap == false) this.monCyl ++;");
document.writeln("   } ");
document.writeln("   if(offset==0 && leap>0 && i==leap+1)");
document.writeln("      if(this.isLeap)");
document.writeln("         { this.isLeap = false; }");
document.writeln("      else");
document.writeln("         { this.isLeap = true; --i; --this.monCyl;}");
document.writeln("    if(offset<0){ offset += temp; --i; --this.monCyl; }");
document.writeln("    this.month = i;");
document.writeln("   this.day = offset + 1;");
document.writeln("}");
document.writeln("function solarDays(y,m) {");
document.writeln("   if(m==1)");
document.writeln("      return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28);");
document.writeln("   else");
document.writeln("      return(solarMonth[m]);");
document.writeln("}");
document.writeln("function cyclical(num) {");
document.writeln("   return(Gan[num%10]+Zhi[num%12]);");
document.writeln("}");
document.writeln("function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {");
document.writeln("      this.isToday    = false;");
document.writeln("      \/\/公历");
document.writeln("      this.sYear      = sYear;");
document.writeln("      this.sMonth     = sMonth;");
document.writeln("      this.sDay       = sDay;");
document.writeln("      this.week       = week;");
document.writeln("      \/\/农历");
document.writeln("      this.lYear      = lYear;");
document.writeln("      this.lMonth     = lMonth;");
document.writeln("      this.lDay       = lDay;");
document.writeln("      this.isLeap     = isLeap;");
document.writeln("      \/\/干支");
document.writeln("      this.cYear      = cYear;");
document.writeln("      this.cMonth     = cMonth;");
document.writeln("      this.cDay       = cDay; ");
document.writeln("}");
document.writeln("function calendar(y,m) {");
document.writeln("   var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2;");
document.writeln("   var lDPOS = new Array(3);");
document.writeln("   var n = 0;");
document.writeln("   var firstLM = 0;");
document.writeln("   sDObj = new Date(y,m,1,0,0,0,0);    \/\/当月一日日期 ");
document.writeln("   this.length    = solarDays(y,m);    \/\/公历当月天数");
document.writeln("   this.firstWeek = sDObj.getDay();    \/\/公历当月1日星期几 ");
document.writeln("   for(var i=0;i<this.length;i++) {");
document.writeln("   if(lD>lX) {");
document.writeln("         sDObj = new Date(y,m,i+1);    \/\/当月一日日期");
document.writeln("         lDObj = new Lunar(sDObj);     \/\/农历");
document.writeln("         lY    = lDObj.year;           \/\/农历年");
document.writeln("         lM    = lDObj.month;          \/\/农历月");
document.writeln("         lD    = lDObj.day;            \/\/农历日");
document.writeln("         lL    = lDObj.isLeap;         \/\/农历是否闰月");
document.writeln("         lX    = lL? leapDays(lY): monthDays(lY,lM); \/\/农历当月最後一天");
document.writeln(" ");
document.writeln("         if(n==0) firstLM = lM;");
document.writeln("         lDPOS[n++] = i-lD+1;");
document.writeln("      }");
document.writeln(" ");
document.writeln("      this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],");
document.writeln("                               lY, lM, lD++, lL,");
document.writeln("                               cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) );");
document.writeln("   } ");
document.writeln("}");
document.writeln("function cDay(d){");
document.writeln("   var s;");
document.writeln(" ");
document.writeln("   switch (d) {");
document.writeln("      case 10:");
document.writeln("         s = \'初十\'; break;");
document.writeln("      case 20:");
document.writeln("         s = \'二十\'; break;");
document.writeln("         break;");
document.writeln("      case 30:");
document.writeln("         s = \'三十\'; break;");
document.writeln("         break;");
document.writeln("      default :");
document.writeln("         s = nStr2[Math.floor(d\/10)];");
document.writeln("         s += nStr1[d%10];");
document.writeln("   }");
document.writeln("   return(s);");
document.writeln("}");
document.writeln("function cMon(d){");
document.writeln("   var s;");
document.writeln("   switch (d) {");
document.writeln("      case 1:");
document.writeln("         s = \'正\'; break;");
document.writeln("      case 12:");
document.writeln("         s = \'腊\'; break;");
document.writeln("      default :");
document.writeln("         s = nStr3[d];");
document.writeln("		 break;");
document.writeln("   }");
document.writeln("   return(s);");
document.writeln("} ");
document.writeln("var ctime=new Date();");
document.writeln("var nYear = ctime.getYear();");
document.writeln("var nMonth = ctime.getMonth();");
document.writeln("var d = ctime.getDate() - 1;");
document.writeln("var ddd =new calendar(nYear,nMonth);");
document.writeln(" ");
document.writeln("var bsWeek=ddd[d].week;");
document.writeln("var bsDate=ddd[d].sYear+\"年\"+ddd[d].sMonth+\"月\";");
document.writeln("var bsDate2=ddd[d].sDay+\"日\";");
document.writeln("var bsYear=ddd[d].cYear + \"年\" + cMon(ddd[d].lMonth) + \"月\" + cDay(ddd[d].lDay);");
document.writeln(" ");
document.writeln("function CAL(){");
document.writeln("document.write(\"<table \");");
document.writeln("document.write(\"<tr><td align=\'left\'><font color=#000000>\"+bsDate+bsDate2+\"<\/font>&nbsp;&nbsp;<font color=#000000><span style=\'FONT-SIZE: 10pt\'>\");");
document.writeln("document.write(\"星期\" + bsWeek+\"<\/span>\"+\"&nbsp;&nbsp;<font color=#000000>\");");
document.writeln("document.write(bsYear + \"<\/td><\/tr><\/table>\");");
document.writeln("}");
document.writeln("CAL();");
document.writeln("<\/script>")
