	//阳历节日
	var SOLAR_FESTIVAL = [
		[1,1, 	"元旦"],
		[2,14, 	"情人节"],
		[3,8, 	"妇女节"],
		[3,12, 	"植树节"],
		[3,15, 	"消费者权益日"],
		[4,1, 	"愚人节"],
		[5,1, 	"劳动节"],
		[5,4, 	"青年节"],
		[5,12, 	"护士节"],
		[6,1, 	"儿童节"],
		[7,1, 	"建党节"],
		[8,1, 	"建军节"],
		[8,8, 	"父亲节"],
		[9,10, 	"教师节"],
		[10,1, 	"国庆节"],
		[10,6, 	"老人节"],
		[10,24, "联合国日"],
		[11,12, "孙中山诞辰"],
		[12,25, "圣诞节"],
		[12,26, "毛泽东诞辰"]
	];
	
	//农历节日
	var LUNAR_FESTIVAL = [
		[1,1, 	"春节"],
		[1,15, 	"元宵节"],
		[5,5, 	"端午节"],
		[7,7, 	"七夕情人节"],
		[7,15, 	"中元节"],
		[8,15, 	"中秋节"],
		[9,9, 	"重阳节"],
		[12,8, 	"腊八节"],
		[12,23, "小年"],
		[12,30,	"除夕"]
	];
	
	var lunarInfo=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)
	//====================================== 传回农历 y年的总天数
	function lYearDays(y) {
	   var i, sum = 348
	   for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0
	   return(sum+leapDays(y))
	}
	
	//====================================== 传回农历 y年闰月的天数
	function leapDays(y) {
	   if(leapMonth(y))  return((lunarInfo[y-1900] & 0x10000)? 30: 29)
	   else return(0)
	}
	
	//====================================== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
	function leapMonth(y) {
	   return(lunarInfo[y-1900] & 0xf)
	}
	
	//====================================== 传回农历 y年m月的总天数
	function monthDays(y,m) {
	   return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 )
	}
	//====================================== 算出农历, 传入日期物件, 传回农历日期物件
	//                                       该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCyl
	function Lunar(objDate) {
	
	   var i, leap=0, temp=0
	   var baseDate = new Date(1900,0,31)
	   var offset   = (objDate - baseDate)/86400000
	
	   this.dayCyl = offset + 40
	   this.monCyl = 14
	
	   for(i=1900; i<2050 && offset>0; i++) {
	      temp = lYearDays(i)
	      offset -= temp
	      this.monCyl += 12
	   }
	
	   if(offset<0) {
	      offset += temp;
	      i--;
	      this.monCyl -= 12
	   }
	
	   this.year = i
	   this.yearCyl = i-1864
	
	   leap = leapMonth(i) //闰哪个月
	   this.isLeap = false
	
	   for(i=1; i<13 && offset>0; i++) {
	      //闰月
	      if(leap>0 && i==(leap+1) && this.isLeap==false)
	         { --i; this.isLeap = true; temp = leapDays(this.year); }
	      else
	         { temp = monthDays(this.year, i); }
	
	      //解除闰月
	      if(this.isLeap==true && i==(leap+1)) this.isLeap = false
	
	      offset -= temp
	      if(this.isLeap == false) this.monCyl ++
	   }
	
	   if(offset==0 && leap>0 && i==leap+1)
	      if(this.isLeap)
	         { this.isLeap = false; }
	      else
	         { this.isLeap = true; --i; --this.monCyl;}
	
	   if(offset<0){ offset += temp; --i; --this.monCyl; }
	
	   this.month = i
	   this.day = offset + 1
	   
	   this.day = parseInt(this.day);
	}
	
	
	
	
	/**
	 * 增强Date对象----------------------------------------------------------------------------------
	 */
	//---------解析日期字符串
	Date.parseDate = function(value){
		if(value == null)
			return null;
		
		var regExp = /([\d]{4})[^\d]([\d]{1,2})[^\d]([\d]{1,2}[\s]{0,1})/;
		
		var result = null;
		
		var tmp = value.match(regExp);

		if(tmp != null){
			result = new Date(tmp[1], tmp[2]-1, tmp[3]);
		}
		return result;
	}
	
	/**
	 * 月份中文
	 */
	var MONTH_CN = new Array("正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月");
	
	/**
	 * 星期中文
	 */
	var WEEK_DAY_CN = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	
	/**
	 * 获得农历月显示样式
	 */
	Date.prototype.getLunarMonth = function(){
		return MONTH_CN[(new Lunar(this)).month - 1];
	}
	
	/**
	 * 获得农历星期几的显示样式
	 */
	Date.prototype.getLunarDay = function(){
		return WEEK_DAY_CN[this.getDay()];
	}
	
	/**
	 * 获得农历日
	 */
	Date.prototype.getLunarDate = function(){
		var date = (new Lunar(this)).day + "";
		
		var result = "";
		
		var lastNumber = "";
		
		if(date.length == 2){
			if(date.substring(0,1) == "1"){
				result += "十";
			}
			else if(date.substring(0,1) == "2"){
				result += "廿十";
			}
			else if(date.substring(0,1) == "3"){
				result += "三十";
			}
			
			lastNumber = date.substring(1,2);
		}
		else{
			lastNumber = date;
		}
		
		switch(lastNumber){
			case "1":
				result += "一";break;
			case "2":
				result += "二";break;
			case "3":
				result += "三";break;
			case "4":
				result += "四";break;
			case "5":
				result += "五";break;
			case "6":
				result += "六";break;
			case "7":
				result += "七";break;
			case "8":
				result += "八";break;
			case "9":
				result += "九";break;
		}
		
		if(result.length == 1)
			result = "初" + result;
		
		return result;
	}
	
	Date.prototype.getFestival = function(){
		var festival = "";
		//阳历节日
		for(var n=0;n<SOLAR_FESTIVAL.length;n++){
			if(SOLAR_FESTIVAL[n][0] == this.getMonth() + 1 && 
				SOLAR_FESTIVAL[n][1] == this.getDate()){
				festival += SOLAR_FESTIVAL[n][2];
				break;
			}
		}
		
		var lunarDate = new Lunar(this);
		//阴历节日
		for(var n=0;n<LUNAR_FESTIVAL.length;n++){
			if(LUNAR_FESTIVAL[n][0] == lunarDate.month && 
				LUNAR_FESTIVAL[n][1] == lunarDate.day){
				if(festival != "") festival += "/";
				
				festival += LUNAR_FESTIVAL[n][2];
				break;
			}
		}
		
		return festival;
	}
	
	//获取日期串
	Date.prototype.toString = function(){
		return this.getFullYear() + "-" + this.getMonth() + "-" + this.getDate();
	}
	
	Date.prototype.toDisplayString = function(){
		var month = (this.getMonth()+1) + "";
		var date = this.getDate() + "";
		
		if(month.length == 1)
			month = "0" + month;
			
		if(date.length == 1)
			date = "0" + date;
		
		return this.getFullYear() + "-" + month + "-" + date;
	}
	
	//日期比较
	Date.prototype.dateEquals = function(anotherDate){
		if(anotherDate == null || anotherDate.getYear() == null || 
			anotherDate.getMonth() == null || anotherDate.getDate() == null)
			return false;
			
		if(this.getYear() == anotherDate.getYear() && 
			this.getMonth() == anotherDate.getMonth() &&
			this.getDate() == anotherDate.getDate())
			return true;
		else
			return false;
	}
	
	//日期加减 "y"年,"m"月,"d"日
	Date.prototype.YEAR = "y";
	Date.prototype.MONTH = "m";
	Date.prototype.DATE = "d";
	Date.prototype.add = function(interval,number){
		if(isNaN(number))
			return;
		number = parseInt(number);
		switch(interval){
			case this.YEAR: this.setFullYear(this.getFullYear()+number); break;
			case this.MONTH: this.setMonth(this.getMonth()+number); break;
			case this.DATE: this.setDate(this.getDate()+number); break;
		}
		return this;
	}
	
	//日期对象克隆
	Date.prototype.clone = function(){
		var result = new Date(this.getFullYear(), this.getMonth(), this.getDate());
		
		return result;
	}






	//--------------------------------Calendar 对象
	
	function generateHeaderHtml(now, chosenDate, id){
		var result = '<div style="width:170px;height:24px;margin:4px;margin-bottom:0px;background-color:#CAC9DC">';
		result += '	<div style="float:left;height:24px;width:60%">';
		result += '		<select id="calendarYear' + id + '" onchange="calendarManager.getCalendarById(' + id + ').changeYear(this.options[this.selectedIndex].value)" style="margin-left:8px;margin-top:2px;margin-right:2px;border: 1px dashed;font-size:10px;">';
		
		var tmp;
		
		var chosenYear = chosenDate.getFullYear();
		for(var n=50;n>0;n--){
			tmp = now.getFullYear() - n;
			result += '<option ' + ((chosenYear == tmp)?'selected':'') + ' value="' + tmp + '">&nbsp;' + tmp + '&nbsp;</option>';
		}
		
		for(var n=0;n<20;n++){
			tmp = now.getFullYear() + n;
			result += '<option ' + ((chosenYear == tmp)?'selected':'') + ' value="' + tmp + '">&nbsp;' + tmp + '&nbsp;</option>';
		}
		
		result += '		</select>';
		
		result += '	</div>';
		result += '	<div style="float:left;height:24px;">';
		result += '		<select id="calendarMonth' + id + '" onchange="calendarManager.getCalendarById(' + id + ').changeMonth(this.options[this.selectedIndex].value)" style="margin-left:2px;margin-top:2px;margin-right:2px;border: 1px dashed;font-size:10px;">';
		
		var chosenMonth = chosenDate.getMonth();
		for(var n=0;n<=11;n++){
			result += '<option ' + ((chosenMonth == n)?'selected':'') + ' value="' + n + '">&nbsp;' + (n+1) + '&nbsp;</option>';
		}
		
		result += '		</select>';
		result += '	</div>';
		result += '</div>';
		
		return result;
	}
	
	function generateLunarInfoHtml(chosenDate){
		var result = '<div align="center" style="width:170px;height:18px;margin-left:4px;margin-right:4px;background-color:#CAC9DC">';
		
		result += '		农历 ' + chosenDate.getLunarMonth() + chosenDate.getLunarDate();
		
		result += ' <span style="color:blue;font:bold">' + chosenDate.getFestival() + '</span>';
		
		result += '</div>';
		
		return result;
	}
	
	function generateWeekDayTitleHtml(){
		var result = '<div style="width:170px;height:18px;margin-left:4px;margin-right:4px">';
		
		var normalDayStyle = 'float:left;width:24px;height:18px;';
		
		var dayStyle = null;
		for(var n=0;n<WEEK_DAY_CN.length;n++){
			if(n == 0)
				dayStyle = normalDayStyle + 'color:red;margin-left:1px';
			else if(n == 6)
				dayStyle = normalDayStyle + 'color:blue';
			else
				dayStyle = normalDayStyle;
				
			result += '<div align="center" style="' + dayStyle + '">';
			
			result += '	<p style="margin-top:3px">' + WEEK_DAY_CN[n] + '</p>';
			
			result += '</div>';
		}
		result += '</div>'
		
		return result;
	}
	
	//------------------------------------------
	//Calendar cell 对象
	function CalendarCell(date, isDisplayMonth){
		//日期对象
		this.date = date;
		
		//是否是当前显示月份里的日期
		this.isDisplayMonth = isDisplayMonth;
	}
	
	/**
	 * 获取当前页要显示的值
	 */
	function getCurrentCalendarCellList(chosenDate){
		var dates = new Array();
		
		var clonedChosenDate = chosenDate.clone();
		
		clonedChosenDate.setDate(1);
		
		//第一天不是星期天,需要取上个月日期
		if(clonedChosenDate.getDay() != 0){
			var lastMonthDate = clonedChosenDate.clone();
			
			lastMonthDate.add(lastMonthDate.DATE, -clonedChosenDate.getDay());
			
			for(var i=0;i<clonedChosenDate.getDay();i++){
				dates[dates.length] = new CalendarCell(lastMonthDate.clone(), false);
				lastMonthDate.add(lastMonthDate.DATE, 1);
			}
		}
		
		var displayMonth = clonedChosenDate.getMonth();
		
		while(clonedChosenDate.getMonth() == displayMonth){
			dates[dates.length] = new CalendarCell(clonedChosenDate.clone(), true);
			
			clonedChosenDate.add(clonedChosenDate.DATE, 1);
		}
		
		//如果还不够6个星期 6*7 = 42
		while(dates.length < 42){
			dates[dates.length] = new CalendarCell(clonedChosenDate.clone(), false);
			
			clonedChosenDate.add(clonedChosenDate.DATE, 1);
		}
		
		return dates;
	}
	
	function generateCalendarCellHtml(calCellList, now, chosenDate, id){
		var calHtml = '<div id="cellContainer" style="border:1px dashed;width:168px;height:108px;margin-left:4px;margin-right:4px">';
		
		var cell = null;
		for(var n=0;n<6;n++){
			calHtml += '<div id="week' + id + "_" + n + '" style="width:168px;height:18px">';
			
			
			for(var i=0;i<7;i++){
				cell = calCellList[n*7+i];
				
				var cellFrontColor = "#000000";
				cellFrontColor = (cell.isDisplayMonth) ? cellFrontColor : "gray";
				
				var cellBgColor = "";
				
				cellBgColor = (cell.date.dateEquals(chosenDate)) ? "green" : cellBgColor;
				
				cellBgColor = (cell.date.dateEquals(now)) ? "yellow" : cellBgColor;
				
				
				
				if(cellBgColor != "")
					cellBgColor = "background-color:" + cellBgColor + ";";
				else{
					if(i == 0 || i == 6)
						cellBgColor = "background-color:#D1D1D1;";
				}
				
				calHtml += '	<div onclick="calendarManager.getCalendarById(' + id + ').changeDate(' + (n*7+i) + ')" ' + ((cellBgColor != "")?'':'onmouseover="this.style.backgroundColor=\'#9e9e9e\'" onmouseout="this.style.backgroundColor=\'\'"') + ' align="center" style="' + cellBgColor + 'color:' + cellFrontColor + ';cursor:pointer;float:left;width:24px;height:16px;margin-top:1px">';
				calHtml += '		<p style="margin-top:1px">' + cell.date.getDate() + '</p>';
				calHtml += '	</div>';
			}
			calHtml += '</div>';
		}
		calHtml += '</div>';
		
		return calHtml;
	}
	
	function generateButtonHtml(calendarObj, id){
		var result = '<div align="right" style="width:170px;height:18px;margin-left:4px;margin-right:4px">';
		result += '<p style="margin-top:3px">';
		if(calendarObj.supportYearMonth){
			result += '	<a href="javascript:calendarManager.getCalendarById(' + id + ').getSelectedYear()" style="TEXT-DECORATION: none;color:blue;  margin-right:4px">Year</a>';
			result += '	<a href="javascript:calendarManager.getCalendarById(' + id + ').getSelectedYearMonth()" style="TEXT-DECORATION: none;color:blue;  margin-right:4px">Year-Month</a>';
		}
		result += '	<a href="javascript:calendarManager.getCalendarById(' + id + ').today()" style="TEXT-DECORATION: none;color:blue;  margin-right:4px">Today</a>';
		if(calendarObj.constructor == DynamicCalendar)
			result += '	<a href="javascript:calendarManager.getCalendarById(' + id + ').clear()" style="TEXT-DECORATION: none;color:blue; margin-right:4px">Clear</a>';
		
		if(calendarObj.constructor == DynamicCalendar)
			result += '	<a href="javascript:calendarManager.getCalendarById(' + id + ').hideCalendar()" style="TEXT-DECORATION: none;color:blue; margin-right:4px">Close</a>';
		
		
		result += '</p>';
		result += '</div>';
		return result;
	}
	
	function getCalendarInternalHtml(){
		var calendarHtml = '';
		//日历头
		calendarHtml += generateHeaderHtml(this.now, this.curMonth, this.id);

		//农历信息
		calendarHtml += generateLunarInfoHtml(this.chosenDate);
		
		//星期信息头
		calendarHtml += generateWeekDayTitleHtml();
		//日历单元格
		calendarHtml += generateCalendarCellHtml(getCurrentCalendarCellList(this.curMonth), this.now, this.chosenDate, this.id);
		
		//操作按钮
		calendarHtml += generateButtonHtml(this, this.id);
		
		return calendarHtml;
	}
	
	//----------------------------------------
	/**
	 * Calendar 管理器
	 */
	function CalendarManager(){
		this.calendars = new Array();
		
		this.newCalendar = function(){
			var newCalendar = new Calendar();
			this.registerCalendar(newCalendar);
			
			return newCalendar;
		}
		
		//-----------------------
		
		this.pageLoaded = false;
		
		//判定页面加载完毕
		window.onload=function(){
			calendarManager.pageLoaded = true;
		}
		//-----------------------
		this.registerCalendar = function(newCal){
			newCal.id = this.calendars.length;
			
			this.calendars[this.calendars.length] = newCal;
		}
		
		/**
		 * 通过id获得calendar
		 */
		this.getCalendarById = function(id){
			for(var n=0;n<this.calendars.length;n++){
				if(this.calendars[n].id == id)
					return this.calendars[n];
			}
			
			return null;
		}
		
		this.bandCalendar = function(obj, supportYearMonth){
			
			obj.onclick = function(){
				dynamicCalendar.supportYearMonth = supportYearMonth;
				dynamicCalendar.showCalendar(obj);
			}
			
			obj.onfocus = null;
		}
	}
	var calendarManager = new CalendarManager();
	/**
	 * Calendar 主对象
	 */
	function Calendar(){
		//唯一标示此日历控件的id号
		this.id = -1;
		
		this.created = false;
		
		this.display = true;
		
		//是否动态显示和隐藏
		//this.dynamicMode = dynamicMode != null ? dynamicMode : false;
		
		this.now = new Date();
		
		this.curMonth = new Date();
		this.chosenDate = new Date();
		
		this.events = new Array();
		
		/**
		 * event handling, supported events: onDateChange
		 */ 
		this.attachEvent = function(eventType, eventFunc){
			this.events[this.events.length] = [eventType, eventFunc];
		}
		
		/* 触发事件 */
		this.fireEvent = function(eventType){
			if(eventType == null)
				return;
				
			for(var n=0;n<this.events.length;n++){
				if(this.events[n][0] == eventType){
					if(typeof(this.events[n][1]) == "string")
						eval(this.events[n][1]);
					else
						this.events[n][1](this);
				}
			}
		}
		
		this.getCalendarInternalHtml = getCalendarInternalHtml;
		
		//--------html generation
		this.create = function(){
			var calendarContainerHtml = '<div id="dateControlContainer' + this.id + '" style="' + (this.display?'':'display:none;') + 'background-color:#efefef;left:' + this.x + 'px;top:' + this.y + 'px;width:180px;border:1px solid;border-color:#808080;font-size:12px;z-index: 9999;">';
		
			calendarContainerHtml += this.getCalendarInternalHtml();
			
			calendarContainerHtml += '</div>';
			
			document.write(calendarContainerHtml);
			
			this.created = true;
		}
		
		this.refresh = function(){
			var calendarContainer = document.getElementById('dateControlContainer' + this.id);
		
			calendarContainer.innerHTML = this.getCalendarInternalHtml();
		}
		
		//--------Data operation
		this.getCurrentCalendarCellList = getCurrentCalendarCellList;
		
		//--------Date change
		this.changeDate = function(cellNumber){
			this.changeDateInternal(cellNumber);
			
			this.refresh();
		}
		
		this.changeDateInternal = function(cellNumber){
			var calCellList = this.getCurrentCalendarCellList(this.curMonth);
			
			this.chosenDate = calCellList[cellNumber].date;
			
			this.curMonth = this.chosenDate.clone();
			
			this.fireEvent("onDateChange");
		}
		
		this.changeYear = function(year){
			this.curMonth.setFullYear(year);
			
			//this.chosenDate.setFullYear(year);
			
			this.refresh();
		}
		
		this.changeMonth = function(month){
			this.curMonth.setMonth(month);
			//如果设置完月份后时间跳到了下个月1号，则设置为上个月最后一天
			if(this.curMonth.getMonth() != month){
			    this.curMonth.setDate(0);
			}
			
			//this.chosenDate.setMonth(month);
			
			this.refresh();
		}
		
		this.today = function(){
			this.todayInternal();
			this.refresh();
		}
		
		this.todayInternal = function(){
			this.chosenDate = this.now;
			
			this.curMonth = this.chosenDate.clone();
			
			this.fireEvent("onDateChange");
		}
		
		
	}
	
	/**
	 * 动态calendar
	 */
	function DynamicCalendar(x, y){
		
		this.supportYearMonth = false;
		
		this.obj = null;
		
		this.x = (isNaN(x)?0:parseInt(x));
		this.y = (isNaN(y)?0:parseInt(y));
		
		this.changeDate = function(cellNumber){
			this.changeDateInternal(cellNumber);
			
			this.obj.value = this.chosenDate.toDisplayString();
			
			this.fireEvent("onDateChange");
			
			this.hideCalendar();
		}
		
		this.today = function(){
			this.todayInternal();
			
			this.obj.value = this.chosenDate.toDisplayString();
			
			this.fireEvent("onDateChange");
			
			this.hideCalendar();
		}
		
		this.getSelectedYear = function(){
			this.obj.value = this.curMonth.toDisplayString().substring(0, 4);
			
			//this.fireEvent("onDateChange");
			this.hideCalendar();
		}
		
		this.getSelectedYearMonth = function(){
			this.obj.value = this.curMonth.toDisplayString().substring(0, 7);
			
			//this.fireEvent("onDateChange");
			
			this.hideCalendar();
		}
		
		this.clear = function(){
			this.obj.value = "";
			
			this.hideCalendar();
		}
		
		//--------show & hide
		this.showCalendar = function(obj){
			//同一个对象不重复显示
			
			
			//切换时，检查内容是否合法
			if(this.obj != obj && !this.checkMasterObjValue())
				return;
			
			var calendarContainer = this.getCalendarHtmlObj();
			
			calendarContainer.style.position = "absolute";
			
			this.now = new Date();
			this.chosenDate = this.now;
			
			//显示的时候，如果是初始状态，读取主控件中的内容进行解析
			var parseResult = Date.parseDate(obj.value);
			
			if(parseResult != null){
				this.chosenDate = parseResult;
				this.curMonth = this.chosenDate.clone();
				//校正格式
				obj.value = this.chosenDate.toDisplayString();
			}
			
			this.refresh();
			
			this.obj = obj;
			
			/* 由于ie的onclick事件和firefox相反,只好用一个延时来使执行顺序相同 */
			setTimeout('showCalendarDelay(' + this.id + ')', 10);
		}
		
		this.hideCalendar = function(){
			if(this.checkMasterObjValue()){
				var calendarContainer = this.getCalendarHtmlObj();
				
				//放在一个比较远的地方
				calendarContainer.style.left = 3000;
				calendarContainer.style.top = 3000;
				
				calendarContainer.style.display = "none";
				
				this.display = false;
				
				dynamicCalendarDisplay = false;
				
				//return true;
			}
			else{
				//this.warnAndKeepCalendar();
				
				//return false;
			}
		}
		
		this.warnAndKeepCalendar = function(){
			alert("日期格式应该是[yyyy-mm-dd],您输入的日期格式错误,请重新输入或选择");
				
			this.obj.select();
			this.obj.focus();
		}
		
		this.checkMasterObjValue = function(){
			if(this.obj == null || this.obj.value == "")
				return true;
			
			/*var parseResult = Date.parseDate(this.obj.value);
			if(parseResult == null){
				return false;
			}
			else{
				this.obj.value = parseResult.toDisplayString();
			}*/
			
			return true;
		}
		
		this.getCalendarHtmlObj = function(){
			return document.getElementById('dateControlContainer' + this.id);
		}
	}
	
	function showCalendarDelay(id){
		var calendar = calendarManager.getCalendarById(id);
		
		calendar.getCalendarHtmlObj().style.display = "";
		
		var relativePosition = getRelativePosition(calendar.obj, calendar.getCalendarHtmlObj());
		
		calendar.x = relativePosition.x;
		calendar.y = relativePosition.y;
		
		calendar.getCalendarHtmlObj().style.left = relativePosition.x;
		calendar.getCalendarHtmlObj().style.top = relativePosition.y;
		
		calendar.display = true;
		
		dynamicCalendarDisplay = true;
	}
	
	
	/* 动态calendar继承自普通calendar */
	DynamicCalendar.prototype = new Calendar();
	DynamicCalendar.prototype.constructor = DynamicCalendar;
	
	/* 动态calendar显示标志, 由于ie和firefox的事件触发顺序相反 */
	var dynamicCalendarDisplay = false;
		
	/**
	 * 监听点击在动态日期控件外的click事件
	 */
	function listenClickOutOfObject(e){
		var evt = window.event?window.event:e;
		if(dynamicCalendarDisplay){
			var calendarHtmlObj = dynamicCalendar.getCalendarHtmlObj();
			
			if(isEventOutOfObject(evt, calendarHtmlObj)){
				dynamicCalendar.hideCalendar();
			}
		}
	}

	addEvent(document,"click",listenClickOutOfObject);
	
	/**
	 * dynamic calendar,应用于动态显示,id为0
	 */
	var dynamicCalendar = new DynamicCalendar(3000,3000);
	
	dynamicCalendar.display = false;
	
	calendarManager.registerCalendar(dynamicCalendar);
	
	dynamicCalendar.create();
