﻿/*k
 * cnCalendar 1.0 - 中国日历
 *
 * Copyright (c) 2007 Zhiwei Ou (ouzhiwei@gmail.com)
 * licensed under the GPL licenses.
 *
 * 参考：
 *  维基百科 - http://zh.wikipedia.org/wiki/中华人民共和国
 *  公历转换农历的算法 - http://hi.baidu.com/adverse/blog/item/d1532a2ead4716514ec22667.html
 *
 * $Date: 2007-08-03 $
 * $Rev: $
 */

//*******************************************************
// 中国农历年数据（LUNAR_START - 2100）
//*******************************************************
var LUNAR_START = 1900;
var arrLunarInfo = new Array(
	0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
	0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
	0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
	0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
	0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
	0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
	0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
	0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
	0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
	0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
	0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
	0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
	0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
	0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
	0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0
);

/* 1900至2100农历参考数据，目前不能用
	0x4bd8,0x4ae0,0xa570,0x54d5,0xd260,0xd950,0x5554,0x56af,0x9ad0,0x55d2,
	0x4ae0,0xa5b6,0xa4d0,0xd250,0xd295,0xb54f,0xd6a0,0xada2,0x95b0,0x4977,
	0x497f,0xa4b0,0xb4b5,0x6a50,0x6d40,0xab54,0x2b6f,0x9570,0x52f2,0x4970,
	0x6566,0xd4a0,0xea50,0x6a95,0x5adf,0x2b60,0x86e3,0x92ef,0xc8d7,0xc95f,
	0xd4a0,0xd8a6,0xb55f,0x56a0,0xa5b4,0x25df,0x92d0,0xd2b2,0xa950,0xb557,
	0x6ca0,0xb550,0x5355,0x4daf,0xa5b0,0x4573,0x52bf,0xa9a8,0xe950,0x6aa0,
	0xaea6,0xab50,0x4b60,0xaae4,0xa570,0x5260,0xf263,0xd950,0x5b57,0x56a0,
	0x96d0,0x4dd5,0x4ad0,0xa4d0,0xd4d4,0xd250,0xd558,0xb540,0xb6a0,0x95a6,
	0x95bf,0x49b0,0xa974,0xa4b0,0xb27a,0x6a50,0x6d40,0xaf46,0xab60,0x9570,
	0x4af5,0x4970,0x64b0,0x74a3,0xea50,0x6b58,0x5ac0,0xab60,0x96d5,0x92e0,
	0xc960,0xd954,0xd4a0,0xda50,0x7552,0x56a0,0xabb7,0x25d0,0x92d0,0xcab5,
	0xa950,0xb4a0,0xbaa4,0xad50,0x55d9,0x4ba0,0xa5b0,0x5176,0x52bf,0xa930,
	0x7954,0x6aa0,0xad50,0x5b52,0x4b60,0xa6e6,0xa4e0,0xd260,0xea65,0xd530,
	0x5aa0,0x76a3,0x96d0,0x4afb,0x4ad0,0xa4d0,0xd0b6,0xd25f,0xd520,0xdd45,
	0xb5a0,0x56d0,0x55b2,0x49b0,0xa577,0xa4b0,0xaa50,0xb255,0x6d2f,0xada0,
	0x4b63,0x937f,0x49f8,0x4970,0x64b0,0x68a6,0xea5f,0x6b20,0xa6c4,0xaaef,
	0x92e0,0xd2e3,0xc960,0xd557,0xd4a0,0xda50,0x5d55,0x56a0,0xa6d0,0x55d4,
	0x52d0,0xa9b8,0xa950,0xb4a0,0xb6a6,0xad50,0x55a0,0xaba4,0xa5b0,0x52b0,
	0xb273,0x6930,0x7337,0x6aa0,0xad50,0x4b55,0x4b6f,0xa570,0x54e4,0xd260,
	0xe968,0xd520,0xdaa0,0x6aa6,0x56df,0x4ae0,0xa9d4,0xa4d0,0xd150,0xf252,
	0xd520
*/

//*******************************************************
// 天干地支及生肖
//*******************************************************
var arrTianGan = new Array('甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸');
var arrDiZhi = new Array('子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥');
var arrAnimals = new Array('鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪');

//*******************************************************
// 二十四节气数据
//*******************************************************
var arrTermInfo = [
	{adjust: 0, name: '小寒'},
	{adjust: 21208, name: '大寒'},
	{adjust: 42467, name: '立春'},
	{adjust: 63836, name: '雨水'},
	{adjust: 85337, name: '惊蛰'},
	{adjust: 107014, name: '春分'},
	{adjust: 128867, name: '清明'},
	{adjust: 150921, name: '谷雨'},
	{adjust: 173149, name: '立夏'},
	{adjust: 195551, name: '小满'},
	{adjust: 218072, name: '芒种'},
	{adjust: 240693, name: '夏至'},
	{adjust: 263343, name: '小暑'},
	{adjust: 285989, name: '大暑'},
	{adjust: 308563, name: '立秋'},
	{adjust: 331033, name: '处暑'},
	{adjust: 353350, name: '白露'},
	{adjust: 375494, name: '秋分'},
	{adjust: 397447, name: '寒露'},
	{adjust: 419210, name: '霜降'},
	{adjust: 440795, name: '立冬'},
	{adjust: 462224, name: '小雪'},
	{adjust: 483532, name: '大雪'},
	{adjust: 504758, name: '冬至'}
];

//*******************************************************
// 农历节日
//*******************************************************
var arrLunarFestival = {
	'1.1': '春节 正月初一',
	'1.2': '春节 正月初二',
	'1.3': '春节 正月初三',
	'1.4': '春节 正月初四',
	'1.5': '春节 正月初五',
	'1.15': '元宵节',
	'5.5': '端午节',
	'7.7': '七夕',
	'7.15': '中元节',
	'8.15': '中秋节',
	'9.9': '重阳节',
	'12.8': '腊八节',
	'12.24': '小年',
	'12.30': '除夕'
};

//*******************************************************
// 各月の別名
//*******************************************************
var arrMonthAlias = {
	1: '正月 陬月 孟陬 孟春',
	2: '如月 杏月 仲春',
	3: '桃月 季春',
	4: '余月 清和月 槐月 孟夏',
	5: '皋月 榴月 蒲月 端月 仲夏',
	6: '且月 荷月 伏月 季夏',
	7: '相月 桶月 巧月 霜月 孟秋',
	8: '壮月 桂月 仲秋',
	9: '玄月 菊月 季秋',
	10: '阳月 小阳春 孟冬',
	11: '辜月 葭月，仲冬',
	12: '涂月 腊月 嘉平月 季冬'
};

//*******************************************************
// 黄道十二宫（星座）
//*******************************************************
var arrZodiac = [
	'白羊座',
	'金牛座',
	'双子座',
	'巨蟹座',
	'狮子座',
	'处女座',
	'天秤座',
	'天蝎座',
	'射手座',
	'摩羯座',
	'宝瓶座',
	'双鱼座'
];

//*******************************************************
// 取得农历年生肖名
//*******************************************************
function getAnimalName(numYear) {
	return arrAnimals[(numYear-4)%12];
}

//*******************************************************
// 取得农历年月日之天干名
//*******************************************************
function getTianGan(numOffset) {
	return arrTianGan[numOffset % 10];
}

//*******************************************************
// 取得农历年月日之地支名
//*******************************************************
function getDiZhi(numOffset) {
	return arrDiZhi[numOffset % 12];
}

//*******************************************************
// 取得中文年名
//*******************************************************
function getCnYearName(numYear) {
	var arrCNum = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');
	var strYear = numYear + '';
	var strName = '';
	for(var i = 0; i < strYear.length; i++) {
		var n = parseInt(strYear.charAt(i));
		strName += arrCNum[n];
	}
	return strName + '年';
}

//*******************************************************
// 取得中文月名
//*******************************************************
function getCnMonthName(numMonth) {
	var arrCNum = new Array('', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二');
	return arrCNum[numMonth] + '月';
}

//*******************************************************
// 取得中文日名（农历）
//*******************************************************
function getCnDayName(numDay) {
	var arrCNum = new Array('', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
	var arrLead = new Array('初', '十', '廿', '卅');
	
	return (numDay == 10) ? '初十' :
			((numDay == 20) ? '二十' :
				((numDay == 30) ? '三十' :
					arrLead[Math.floor(numDay/10)] + arrCNum[numDay%10]
				)
			);
}

//*******************************************************
// 取得农历年的总天数
//*******************************************************
var arrLunarYDays = new Array();
function getLunarYearDays(numYear) {
	if(!arrLunarInfo[numYear - LUNAR_START]) {
		return null;
	}
			
	if(arrLunarYDays[numYear]) {
		//如果全局数组里已有，直接返回
		return arrLunarYDays[numYear];
	}

   	var numDays = 348;
    for(var i = 0x8000; i > 0x8; i >>= 1) {
    	numDays += (arrLunarInfo[numYear - LUNAR_START] & i) ? 1: 0;
    }
    
	//为避免重复计算，结果放在全局数组里
    arrLunarYDays[numYear] = numDays + getLunarLeapDays(numYear);
    return arrLunarYDays[numYear];
}

//*******************************************************
// 取得农历年某月的总天数
//*******************************************************
function getLunarMonthDays(numYear, numMonth) {
	return (arrLunarInfo[numYear-LUNAR_START] & (0x10000>>numMonth)) ? 30: 29;
}

//*******************************************************
// 取得农历年闰月天数
//*******************************************************
function getLunarLeapDays(numYear) {
    if(getLunarLeapMonth(numYear)) {
		return (arrLunarInfo[numYear-LUNAR_START] & 0x10000) ? 30: 29;
    } else {
    	return 0;
    }
}

//*******************************************************
// 取得农历年的闰月(1-12), 若无闰月返回0
//*******************************************************
function getLunarLeapMonth(numYear) {
	return	(arrLunarInfo[numYear-LUNAR_START] & 0xf);
}

//*******************************************************
// 农历日期对象，参数是普通的Date对象
// 属性：
//  .year .month .day .isLeap 
//　.ygzOffset .mgzOffset .dgzOffset
//　.yearName .monthName .dayName
//  .Festival
//*******************************************************
function LunarDate(objDate) {
	this.year = 0;
	this.mohth = 0;
	this.day = 0;
    this.isLeap = false;
    this.ygzOffset = 0;
    this.mgzOffset = 0;
    this.dgzOffset = 0;

	this.yearName = '';
	this.monthName = '';
	this.dayName = '';
	this.Festival = '';

	var baseDate = new Date(LUNAR_START, 0, 31);
	var offsetDays = (objDate - baseDate)/86400000;
	
	this.dgzOffset = offsetDays + 40;
	this.mgzOffset = 14;

	var i, adjust = 0;

	for(i = LUNAR_START; adjust != null && offsetDays > 0; i++) {
		adjust = getLunarYearDays(i);
		offsetDays -= adjust;
		this.mgzOffset += 12;
	}
    
    if(offsetDays < 0) {
       offsetDays += adjust;
       i--;
       this.mgzOffset -= 12;
    }

    this.year = i;
    this.ygzOffset = i-1864;
	
	//取得闰月
    var leapMonth = getLunarLeapMonth(i); 
    for(i = 1; i < 13 && offsetDays > 0; i++) {
		//闰月
		if(leapMonth > 0 && i == (leapMonth+1) && !this.isLeap) {
			this.isLeap = true; --i; 
			adjust = getLunarLeapDays(this.year);
		} else {
			adjust = getLunarMonthDays(this.year, i);
		}

		//解除闰月
		if(this.isLeap && i == (leapMonth+1)) {
		   	this.isLeap = false;
		}

		offsetDays -= adjust;
		if(!this.isLeap) {
			this.mgzOffset++;
		}
    }

	if(offsetDays==0 && leapMonth>0 && i==(leapMonth+1)) {
		if(this.isLeap) {
			this.isLeap = false;
		} else {
			this.isLeap = true; --i; --this.mgzOffset;
		}
	}
	
    if(offsetDays<0){
    	offsetDays += adjust; --i; --this.mgzOffset;
    }
	
    this.month = i;
    this.day = offsetDays + 1;

	this.yearName = getCnYearName(this.year);
	this.monthName = getCnMonthName(this.month);
	this.dayName = getCnDayName(this.day);
	
	this.Festival = arrLunarFestival[this.month + '.' + this.day];
}


//*******************************************************
// 取得二十四节气名
//*******************************************************
function getSolarTerm(numYear, numMonth, numDay) {
	var objTerm = arrTermInfo[(numMonth - 1) * 2];
	if(objTerm) {
		var tmpDate = new Date((31556925974.7 * (numYear - 1900) + objTerm['adjust'] * 60000) + Date.UTC(1900, 0, 6, 2, 5));
		var numTermDay = tmpDate.getUTCDate();
		if (numTermDay == numDay) {
			return objTerm['name'];
		}
		
		objTerm = arrTermInfo[(numMonth - 1) * 2 + 1];
		tmpDate = new Date((31556925974.7 * (numYear - 1900) + objTerm['adjust'] * 60000) + Date.UTC(1900, 0, 6, 2, 5));
		numTermDay = tmpDate.getUTCDate();
		if (numTermDay == numDay) {
			return objTerm['name'];
		}
	}
	return '';
}

//*******************************************************
// 普通节假日
//*******************************************************
var arrDayAlias = {
	'1.1': '元旦',
	'3.8': '妇女节',
	'3.12': '植树节',
	'5.1': '劳动节',
	'5.4': '青年节',
	'5.12': '护士节',
	'6.1': '儿童节',
	'7.1': '建党节',
	'8.1': '建军节',
	'9.10': '教师节',
	'10.1': '国庆节',
	'11.8': '记者节'
}

//*******************************************************
// 取得指定月份的天数
//*******************************************************
function getLastDay(numYear, numMonth) {
	with (new Date(numYear, numMonth, 1, 12)) {
		setDate(0) ; 
		return getDate();
	}
}

//*******************************************************
// 节假日
//*******************************************************
function getChinaHoliday(numYear, strKey1, strKey2) {
	var strTitle = '';
	
	if(numYear >= 1949 && arrDayAlias[strKey1]) {
		strTitle = arrDayAlias[strKey1];
	}

	return strTitle;
}

//*******************************************************
// 纪念日
//*******************************************************
function getMemorialDay(numYear, strKey1, strKey2) {
	var strTitle = '';
	
	//某月某日的纪念日
	switch( strKey1 ) {
		case '3.15':
			strTitle = (numYear >= 1983) ? '消费者权益日' :  '';
			break;
		case '7.1':
			strTitle = (numYear >= 1997) ? '香港回归纪日' :  '';
			break;
		case '9.3':
			strTitle = (numYear >= 1945) ? '抗战胜利纪念日' : '';
			break;
		case '9.9':
			strTitle = (numYear >= 1976) ? '毛泽东逝世纪念日' : '';
			break;
		case '9.28':
			strTitle = (numYear >= 1976) ? '孔子诞辰纪念日' : '';
			break;
		case '10.24':
			strTitle = (numYear >= 1945) ? '联合国日' : '';
			break;
		case '11.12':
			strTitle = (numYear >= 1866) ? '孙中山诞辰纪念日' : '';
			break;
		case '12.20':
			strTitle = (numYear >= 1999) ? '澳门回归纪念日' : '';
			break;
		case '12.26':
			strTitle = (numYear >= 1893) ? '毛泽东诞辰纪念日' : '';
			break;
		default:
			break;
	}
	
	//某月某周几的纪念日
	var strAnd = (strTitle == '') ? '' : '<br />';
	switch( strKey2 ) {
		default:
			break;
	}

	return strTitle;
}

//*******************************************************
// 取得指定年度的复活节日期
//*******************************************************
function getEaster(numYear) {
    var golden = numYear % 19;
    var fullmoon = (golden*(30 - 11)+15) % 30;
    if (numYear > 1582) {
        var century = Math.floor((numYear - 1500)/100);
        var adjust = Math.floor(century/25)*8 + Math.min(8,Math.floor((century%25)/3)) + 3;
        fullmoon = (fullmoon + Math.floor(numYear/100) -Math.floor(numYear/400) - 2 - adjust) % 30;
        
        if (fullmoon == 28 && golden >= 11) {
        	fullmoon--;
        } else if (fullmoon > 28) {
        	fullmoon = 28;
        }
    }
	
	numMonth = 3;
    var adjust = numYear <= 1582 ? 2 : Math.floor(numYear/100) - Math.floor(numYear/400);
    wDay = (numYear + Math.floor(numYear/4) - adjust + Math.floor((13 * numMonth + 8)/5) + 21 + fullmoon) % 7;

    pascha = fullmoon + 7 - wDay

    var numDay = 21 + pascha;
    if (numDay > 31) {
        numMonth++; 
        numDay -= 31;
    }
    
    return numMonth + '.' + numDay;
}

//*******************************************************
// 西方节日
//*******************************************************
var arrEaster = new Array();
function getWestHoliday(numYear, strKey1, strKey2) {
	var strTitle = '';
	
	//复活节日期的取得，为了不重复计算，放在全局数组里
	if(!arrEaster[numYear]) {
		arrEaster[numYear] = getEaster(numYear);
	}
	//何月何日
	switch( strKey1 ) {
		case arrEaster[numYear]:
			strTitle = '复活节';
			break;
		case '2.14':
			strTitle = '情人节';
			break;
		case '4.1':
			strTitle = '愚人节';
			break;
		case '10.31':
			strTitle = '万圣节';
			break;
		case '12.24':
			strTitle = '平安夜';
			break;
		case '12.25':
			strTitle = '圣诞节';
			break;
		default:
			break;
	}
	
	//何月何週何日
	var strAnd = (strTitle == '') ? '' : '<br />';
	switch( strKey2 ) {
		case '5.w2.0':
			strTitle += (numYear >= 1907) ? strAnd + '母亲节' : '';
			break;
		case '6.w3.0':
			strTitle += (numYear >= 1910) ? strAnd + '父亲节' : '';
			break;
		case '11.w4.4':
			strTitle += (numYear >= 1924) ? strAnd + '感恩节' : '';
			break;
		default:
			break;
	}

	return strTitle;
}

//*******************************************************
// 取得星座名
//*******************************************************
function getZodiac(numMonth, numDay) {
	var numTmp = numMonth * 100 + numDay;
	var numIndex;

	if ((numTmp >= 321) && (numTmp <= 419)) {
		numIndex = 0;
	} else if ((numTmp >= 420) && (numTmp <= 520)) {
		numIndex = 1;
	} else if ((numTmp >= 521) && (numTmp <= 621)) {
		numIndex = 2;
	} else if ((numTmp >= 622) && (numTmp <= 722)) {
		numIndex = 3;
	} else if ((numTmp >= 723) && (numTmp <= 822)) {
		numIndex = 4;
	} else if ((numTmp >= 823) && (numTmp <= 922)) {
		numIndex = 5;
	} else if ((numTmp >= 923) && (numTmp <= 1022)) {
		numIndex = 6;
	} else if ((numTmp >= 1023) && (numTmp <= 1121)) {
		numIndex = 7;
	} else if ((numTmp >= 1122) && (numTmp <= 1221)) {
		numIndex = 8;
	} else if ((numTmp >= 1222) || (numTmp <= 119)) {
		numIndex = 9;
	} else if ((numTmp >= 120) && (numTmp <= 218)) {
		numIndex = 10;
	} else if ((numTmp >= 219) && (numTmp <= 320)) {
		numIndex = 11;
	} else {
		return '';
	}
	
	return arrZodiac[numIndex];
}

//*******************************************************
// 生成指定年月日历的HTML代码
//*******************************************************
function getCalendarHtml(numYear, numMonth) {
	var strYear = numYear + '年';
	var strMonth = ( numMonth < 10 ) ? '0' + numMonth + '月' : '' + numMonth + '月';
	
	var startDate = new Date(numYear, numMonth - 1, 1, 0, 0, 0);
	var numOffset = startDate.getDay() - 1;
	var numLastDay = getLastDay(numYear, numMonth);
	
	var startLunarDate = null;
	if(arrLunarInfo[numYear - LUNAR_START]) {
		startLunarDate = new LunarDate(startDate);
	} 

	var strAnd = '<br />';
	var strMonthTip = strYear + strMonth;
	
	if(startLunarDate != null) {
		strMonthTip += strAnd + strAnd + '【农历】';
		strMonthTip += strAnd + getCnYearName(startLunarDate.year) + getCnMonthName(startLunarDate.month);
		strMonthTip += strAnd + arrMonthAlias[startLunarDate.month];
		strMonthTip += strAnd + getTianGan(startLunarDate.ygzOffset)  + getDiZhi(startLunarDate.ygzOffset) + '(' + getAnimalName(numYear) + ')' + '年';
		strMonthTip += '&nbsp;' + getTianGan(startLunarDate.mgzOffset)  + getDiZhi(startLunarDate.mgzOffset) + '月';
	}
	
	var strHtml = '	    <table cellpadding="2" cellspacing="2" border="0">\n'
				+ '	      <tr>\n'
				+ '	        <td colspan="7" title="' + strMonthTip + '"><center>\n'
				+ '	          <b>' + strYear + strMonth + '</b>\n'
				+ '	        </center></td>\n'
				+ '	      </tr>\n'
				+ '	      <tr>\n'
				+ '	        <th align="right"><font color="#DD0022">日</font></th>\n'
				+ '	        <th align="right">一</th>\n'
				+ '	        <th align="right">二</th>\n'
				+ '	        <th align="right">三</th>\n'
				+ '	        <th align="right">四</th>\n'
				+ '	        <th align="right">五</th>\n'
				+ '	        <th align="right"><font color="#DD0022">六</font></th>\n'
				+ '	      </tr>\n';

	var numCount = 0;
	var arrWdayCnt = [0, 0, 0, 0, 0, 0, 0];
	for( var iRow = 0; iRow < 6; iRow++) {
		strHtml += '	      <tr>\n';
		for( var iCol = 0; iCol < 7; iCol++) {
			var numDay = numCount - numOffset;

			var strText = ''
			var strDayTip = '';
			var strBgColor = '';

			var strTextColor = (iCol == 0 || iCol == 6) ? '#DD0022' : '';

			if( numDay > 0 && numDay <= numLastDay ) {
				var solarDate = new Date(numYear, numMonth - 1, numDay, 0, 0, 0);
				strText = '' + numDay;
				if(startLunarDate != null) {
					var lunarDate = new LunarDate(solarDate);
					strText += '<br /><font size="-2" color="#BBBBBB">' + lunarDate.dayName + '</font>';
				}
				
				var numWeek = iRow + 1;
				var numWeekDay = solarDate.getDay();
				arrWdayCnt[numWeekDay] += 1;

				var strKey1 = numMonth + '.' + numDay;
				var strKey2 = numMonth + '.w' + arrWdayCnt[numWeekDay] + '.' + numWeekDay;

				strDayTip = numYear + '年' + numMonth + '月' + numDay + '日';

				//纪念日
				var strMemorialDay = getMemorialDay(numYear, strKey1, strKey2);
				if( strMemorialDay != '') {
					strDayTip += strAnd + strMemorialDay;
					strTextColor = '#2F4F4F';
					strBgColor = '#F0F8FF';
				}

				//西方节日
				var strWestHoliday = getWestHoliday(numYear, strKey1, strKey2);
				if( strWestHoliday != '') {
					strDayTip += strAnd + strWestHoliday;
					strTextColor = '#660099';
					strBgColor = '#F6ECF6';
				}

				//二十四节气
				var strSolarTerm = getSolarTerm(numYear, numMonth, numDay);
				if( strSolarTerm != '') {
					strDayTip += strAnd + strSolarTerm;
					strTextColor = '#336600';
					strBgColor = '#F1FAE8';
				}

				//中国节日(建国后)
				var strChinaHoliday = getChinaHoliday(numYear, strKey1, strKey2);
				if( strChinaHoliday != '') {
					strDayTip += strAnd + strChinaHoliday;
					strTextColor = '#808000';
					strBgColor = '#FAFAD2';
				}

				//星座
				var strZodiac = getZodiac(numMonth, numDay);
				strDayTip += strAnd + strAnd + '【星座】';
				strDayTip += strAnd + strZodiac;

				//农历消息
				if(startLunarDate != null) {
					strDayTip += strAnd + strAnd + '【农历】';
					strDayTip += strAnd + lunarDate.yearName + lunarDate.monthName + lunarDate.dayName;
					strDayTip += strAnd + getTianGan(lunarDate.ygzOffset)  + getDiZhi(lunarDate.ygzOffset) + '(' +  getAnimalName(numYear) + ')' + '年';
					strDayTip += '&nbsp;' + getTianGan(lunarDate.mgzOffset)  + getDiZhi(lunarDate.mgzOffset) + '月';
					strDayTip += '&nbsp;' + getTianGan(lunarDate.dgzOffset)  + getDiZhi(lunarDate.dgzOffset) + '日';
					if (lunarDate.Festival) {
						strDayTip += strAnd + lunarDate.Festival;
						strTextColor = '#DD0022';
						strBgColor = '#FFE4E1';
					}
				}
			} else {
				strText = '&nbsp;';
			}

			strTextColor = (strTextColor == '') ? '#000000' : strTextColor;
			
			strHtml +='	        <td title="'+ strDayTip + '" bgcolor="'+ strBgColor + '" align="right"><font color="' + strTextColor + '">'+ strText +'</font></td>\n';
			numCount++;
		}
		strHtml += '	      </tr>\n';
	}
	
	strHtml += '	    </table>\n';
    return strHtml;
}
