
document.writeln('<iframe id=wpCalendarLayer frameborder=0 style="position: absolute; width: 153; height: 208; z-index: 9998; display: none"></iframe>');
function wpCalendar(){
	//==================================================== 参数设定部分 =======================================================
	this.bMoveable	= true;			//设置日历是否可以拖动
	this.datestyle	= "yyyy-M-d";		//added in Ver 2.1
	this.VersionInfo= "水晶日历 Version:2.5 beta 3&#13;2.0系列作者:LiuYing_Andy"	//版本信息
	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.theme		= theme["Classic"];			//主题设置，决定日历的外观

	try{this.IE6	= (parseFloat(window.navigator.appVersion.match(/MSIE (\d+\.\d+)/)[1])>=5.5)}
	catch(e){this.IE6 = false}
	this.TestSpeed	= false;					//测试机器速度，以便自动决定是否使用Filter。如果设置为true，则下面的PlayFitler参数设置无效。
	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.tmpTdClass = "";
	this.Redraw		= function (){				//定义Redraw方法，用于重绘整个日历
		//==================================================== WEB 页面显示部分 =====================================================
		var strFrame;		//存放日历层的HTML代码
		strFrame='<style>';
		with(this.theme){
			strFrame+='BODY{font-family:'+fontFamily+';}';
			strFrame+='SELECT{color:'+headFontColor+';BACKGROUND-COLOR: '+headBgColor+';font-size:12px;font-family:'+fontFamily+';height:18px;}';
			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+='TD{FONT-SIZE: 9pt;}';
			strFrame+='TD.calendarhead{COLOR: '+headFontColor+'; BACKGROUND-COLOR: '+headBgColor+';}';
			strFrame+='TD.mouseover{COLOR: '+mouseOverFontColor+'; BACKGROUND-COLOR: '+mouseOverColor+';}';
			strFrame+='TD.dragbar{font-size:12px;color:'+dragBarFontColor+';width:21px;}';
			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+='var datelayerx,datelayery;	/*存放日历控件的鼠标位置*/';
		strFrame+='var bDrag;	/*标记是否开始拖动*/';
		strFrame+='var DateLayer=parent.wpCalendar.Style;';
		strFrame+='function document.onmousemove()	/*在鼠标移动事件中，如果开始拖动日历，则移动日历*/';
		strFrame+='{if(bDrag && window.event.button==1)';
		strFrame+='	{';
		strFrame+='		DateLayer.posLeft += window.event.clientX-datelayerx;/*由于每次移动以后鼠标位置都恢复为初始的位置，因此写法与div中不同*/';
		strFrame+='		DateLayer.posTop += window.event.clientY-datelayery;}}';
		strFrame+='function DragStart()		/*开始日历拖动*/';
		strFrame+='{';
		strFrame+='	datelayerx=window.event.clientX;';
		strFrame+='	datelayery=window.event.clientY;';
		strFrame+='	bDrag=true;}';
		strFrame+='function DragEnd(){		/*结束日历拖动*/';
		strFrame+='	bDrag=false;}';
		strFrame+='</scr' + 'ipt>';
		with(this){
			strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 3; left: 19;display: none"></span>';
			strFrame+='<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 3;left: 81;display: none"></span>';
			strFrame+='<table border=1 cellspacing=0 cellpadding=0 width=151 height=160 bordercolor='+theme.borderColor+' bgcolor='+theme.bgColorMain+'>';
			strFrame+='  <tr><td width=151 height=20 bgcolor='+theme.headBgColor+'><table border=0 cellspacing=1 cellpadding=0 width=149 height=20>';
			strFrame+='      <tr align=center><td width=16><input title="向前翻 1 月" type=button ';
			strFrame+='             value="<" onclick="parent.wpCalendar.goPrevMonth()" onfocus="this.blur()" style="font-size: 12px; width: 16px; height: 18px">';
			strFrame+='        </td><td width=62 align=center class=calendarhead style="font-size:12px;cursor:default" ';
			strFrame+='onmouseover="className=\'mouseover\'" onmouseout="className=\'calendarhead\'" ';
			strFrame+='onclick="parent.wpCalendar.tmpSelectYearInnerHTML(this.innerText.substring(0,4))" title="点击这里选择年份"><span id=CalendarYearHead></span></td>';
			strFrame+='<td width=55 align=center class=calendarhead style="font-size:12px;cursor:default" onmouseover="className=\'mouseover\'" ';
			strFrame+=' onmouseout="className=\'calendarhead\'" onclick="parent.wpCalendar.tmpSelectMonthInnerHTML(this.innerText.length==3?this.innerText.substring(0,1):this.innerText.substring(0,2))"';
			strFrame+='        title="点击这里选择月份"><span id=CalendarMonthHead></span></td>';
			strFrame+='		<td width=16><input type=button value=">" onclick="parent.wpCalendar.goNextMonth()" ';
			strFrame+='             onfocus="this.blur()" title="向后翻 1 月" style="font-size: 12px; width:16px; height: 18px"></td></tr>';
			strFrame+='    </table></td></tr>';
			strFrame+='  <tr><td width=149 height=20 align=center>';
			strFrame+='<table align=center border=1 cellspacing=0 cellpadding=0 bgcolor='+theme.bgColorMain+' ' + (bMoveable? 'onmousedown="DragStart()" onmouseup="DragEnd()"':'');
			strFrame+=' BORDERCOLORLIGHT='+theme.dragBarColor+' BORDERCOLORDARK='+theme.dragBarColorDark+' width=147 height=20 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=151 height=120 align=center>';
			strFrame+='    <table align=center border=1 cellspacing=2 cellpadding=0 BORDERCOLOR='+theme.borderColor+' bgcolor='+theme.bgColorLight+' width=149 height=120>';
			var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center>'; for (i=0;i<7;i++){
			strFrame+='<td width=21 height=20 id=wpDateCell'+n+' style="font-size:12px"></td>';n++;}
			strFrame+='</tr>';}
			strFrame+='      <tr align=center>';
			for (i=35;i<39;i++)strFrame+='<td width=21 height=20 id=wpDateCell'+i+' style="font-size:12px"></td>';
			strFrame+='        <td colspan=3 align=right class=calendarhead><span onclick=parent.wpCalendar.Close() style="font-size:12px;cursor: hand"';
			strFrame+='         title="' + VersionInfo + '&#13;' + theme.VersionInfo + '"><u>关闭</u></span>&nbsp;</td></tr>';
			strFrame+='    </table></td></tr><tr><td>';
			strFrame+='        <table border=0 cellspacing=1 cellpadding=0 width=100% bgcolor='+theme.headBgColor+'>';
			strFrame+='          <tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td><input type=button value="<<" title="向前翻 1 年" onclick="parent.wpCalendar.goPrevYear()" ';
			strFrame+='             onfocus="this.blur()" style="font-size: 12px; height: 20px"><td width="1"></td><td><input title="向前翻 1 月" type=button ';
			strFrame+='             value="< " onclick="parent.wpCalendar.goPrevMonth()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td></tr></table></td><td ';
			strFrame+='             align=center><input type=button value=Today onclick="parent.wpCalendar.selectToday()" ';
			strFrame+='             onfocus="this.blur()" title="当前日期" style="font-size: 12px; height: 20px; cursor:hand"></td><td ';
			strFrame+='             align=right><table border=0 cellspacing=0 cellpadding=0><tr><td><input type=button value=" >" onclick="parent.wpCalendar.goNextMonth()" ';
			strFrame+='             onfocus="this.blur()" title="向后翻 1 月" style="font-size: 12px; height: 20px"><td width="1"></td><td><input ';
			strFrame+='             type=button value=">>" title="向后翻 1 年" onclick="parent.wpCalendar.goNextYear()"';
			strFrame+='             onfocus="this.blur()" style="font-size: 12px; height: 20px"></td></tr></table></td>';
			strFrame+='</tr></table></td></tr></table></div>';
		}

		this.oCalendar.writeln(strFrame);
		this.oCalendar.close();		//解决ie进度条不结束的问题
		
		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] = eval("this.oCalendar.getElementById('wpDateCell"+i+"')");
			this.DateCell[i].style.cursor	= "hand";
			this.DateCell[i].style.filter	= "progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0.5)";
			this.DateCell[i].style.fontWeight = "bold";
			this.DateCell[i].onmouseover	= wpMouseOver;
			this.DateCell[i].onmouseout	= wpMouseOut;
		}

		//==================================================== WEB 页面显示部分 ======================================================
	}

	this.tmpSelectYearInnerHTML = function (strYear){	//年份的下拉框
		if (strYear.match(/\D/)!=null)return;
		var m = (strYear) ? strYear : new Date().getFullYear();
		if (m < 1000 || m > 9999)return;
		var n = m - 50;
		if (n < 1000) n = 1000;
		if (n + 100 > 9999) n = 9900;
		var s = "<select name=tmpSelectYear "
		s += "onblur=\"document.getElementById('tmpSelectYearLayer').style.display='none'\" "
		s += "onchange=\"document.getElementById('tmpSelectYearLayer').style.display='none';"
		s += "parent.wpCalendar.Year = parseInt(this.value); parent.wpCalendar.WriteCalendar()\">\r\n";
		var selectInnerHTML = s;
		for (var i = n; i < n + 100; i++)
		{
		if (i == m)
			{selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";}
		else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";}
		}
		selectInnerHTML += "</select>";
		this.oCalendar.getElementById("tmpSelectYearLayer").style.display="";
		this.oCalendar.getElementById("tmpSelectYearLayer").innerHTML = selectInnerHTML;
		this.oCalendar.getElementById("tmpSelectYear").focus();
	}

	this.tmpSelectMonthInnerHTML=function (strMonth) //月份的下拉框
	{
	  if (strMonth.match(/\D/)!=null)return;
	  var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
	  var s = "<select name=tmpSelectMonth "
		 s += "onblur=\"document.getElementById('tmpSelectMonthLayer').style.display='none'\" "
		 s += "onchange=\"document.getElementById('tmpSelectMonthLayer').style.display='none';"
		 s += "parent.wpCalendar.Month = parseInt(this.value); parent.wpCalendar.WriteCalendar()\">\r\n";
	  var selectInnerHTML = s;
	  for (var i = 1; i < 13; i++)
	  {
		if (i == m)
		   {selectInnerHTML += "<option value='"+i+"' selected>"+i+"月"+"</option>\r\n";}
		else {selectInnerHTML += "<option value='"+i+"'>"+i+"月"+"</option>\r\n";}
	  }
	  selectInnerHTML += "</select>";
	  this.oCalendar.getElementById("tmpSelectMonthLayer").style.display="";
	  this.oCalendar.getElementById("tmpSelectMonthLayer").innerHTML = selectInnerHTML;
	  this.oCalendar.getElementById("tmpSelectMonth").focus();
	}

	this.Close = function(){			//关闭日历控件
		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.Year,this.Month);}
	}
	this.goNextYear=function (){	//往后翻 Year
		if(this.Year > 999 && this.Year <9999){this.Year++;
		this.WriteCalendar(this.Year,this.Month);}
	}
	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();
	}
	this.goPrevMonth=function (){		//往前翻月份
		if(this.Month>1){this.Month--}else{this.Year--;this.Month=12;}
		this.WriteCalendar(this.Year,this.Month);
	}
	this.goNextMonth=function (){		//往后翻月份
		if(this.Month==12){this.Year++;this.Month=1}else{this.Month++}
		this.WriteCalendar(this.Year,this.Month);
	}

	this.WriteCalendar=function (){	//主要的写程序**********
		var yy = this.Year;
		var mm = this.Month;
		//写入头部的年月
		this.oCalendar.getElementById("CalendarYearHead").innerText	= yy + " 年";
		this.oCalendar.getElementById("CalendarMonthHead").innerText	= 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();  //某月第一天的星期几
		for (i=0;i<firstday;i++){	//上个月的部分
			this.Days[i]=getDaysOfMonth(mm==1?yy-1:yy,mm==1?12:mm-1)-firstday+i+1	//上个月的最后几天
			var da = this.DateCell[i];
			da.innerText=this.Days[i];
			da.title=(mm==1?12:mm-1) +"月" + this.Days[i] + "日";
			da.onclick=Function("wpCalendar.DateCellClick(this.innerText,-1)");
			if(this.outerDate && ((mm==1?yy-1:yy)==this.outerDate.getFullYear() && (mm==1?12:mm-1)== this.outerDate.getMonth() + 1 && this.Days[i]==this.outerDate.getDate())){
				da.className="selectedgrayday"
				da.borderColorLight=this.theme.borderColorDark;
				da.borderColorDark=this.theme.borderColor;
			}
			else if((mm==1?yy-1:yy) == new Date().getFullYear() && (mm==1?12:mm-1) == new Date().getMonth()+1 && this.Days[i] == new Date().getDate())
				da.className="graytoday"
			else da.className="grayday";
		}
		for (i = firstday; day1 < getDaysOfMonth(yy,mm)+1; i++){	//本月的部分
			this.Days[i]=day1;day1++;
			var da = this.DateCell[i];
			da.innerText=this.Days[i];
			da.title=mm +"月" + this.Days[i] + "日";
			da.onclick=Function("wpCalendar.DateCellClick(this.innerText,0)");		//给td赋予onclick事件的处理
			if(this.outerDate && (yy==this.outerDate.getFullYear() && mm== this.outerDate.getMonth() + 1 && this.Days[i]==this.outerDate.getDate())){
				da.className="selectedday"
				da.borderColorLight=this.theme.borderColorDark;
				da.borderColorDark=this.theme.borderColor;
			}
			else if(yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && this.Days[i] == new Date().getDate())
				da.className="today"
			else da.className="normalday";
		}
		for (i=firstday+getDaysOfMonth(yy,mm);i<39;i++){	//下个月的部分
			this.Days[i]=day2;day2++;
			var da = this.DateCell[i];
			da.innerText=this.Days[i];
			da.title=(mm==12?1:parseInt(mm)+1) +"月" + this.Days[i] + "日";
			da.onclick=Function("wpCalendar.DateCellClick(this.innerText,1)");
			if(this.outerDate && ((mm==12?yy+1:yy)==this.outerDate.getFullYear() && (mm==12?1:mm+1)== this.outerDate.getMonth() + 1 && this.Days[i]==this.outerDate.getDate())){
				da.className="selectedgrayday"
				da.borderColorLight=this.theme.borderColorDark;
				da.borderColorDark=this.theme.borderColor;
			}
			else if((mm==12?yy+1:yy) == new Date().getFullYear() && (mm==12?1:mm+1) == new Date().getMonth()+1 && this.Days[i] == new Date().getDate())
				da.className="graytoday"
			else da.className="grayday";
		}
	}

	this.DateCellClick=function (n,ex){  //点击显示框选取日期，主输入函数*************
		var yy = this.Year;
		var mm = this.Month+ex;	//ex表示偏移量，用于选择上个月份和下个月份的日期
		//判断月份，并进行对应的处理
		if(mm<1){
			yy--;
			mm=12+mm;
		}
		else if(mm>12){
			yy++;
			mm=mm-12;
		}
		if (mm < 10 && this.MonthinMM)mm = "0" + mm;
		if (this.tgtObject){
			if (!n)return;
			if (n < 10 && this.Dateindd)n = "0" + n;
			this.tgtObject.value= this.datestyle.replace((this.Dateindd?"dd":"d"), n).replace("yyyy", yy).replace((this.MonthinMM?"MM":"M"), mm);	//added in Ver 2.1
			this.Close(); this.tgtObject.blur();
		}
		else {this.Close(); alert("您所要输出的控件对象并不存在！");}
	}

	function wpMouseOver() {
		if(wpCalendar.PlayFilter)this.filters[0].Apply();
		// After you set Apply, changes to the oDiv object 
		//  are not displayed until Play is called.
		wpCalendar.tmpTdClass	= this.className;
		this.className			= "mouseover";
		if(wpCalendar.PlayFilter)this.filters[0].Play();
	}
	function wpMouseOut(){
		if(wpCalendar.PlayFilter)this.filters[0].Apply();
		this.className	= wpCalendar.tmpTdClass;
		if(wpCalendar.PlayFilter)this.filters[0].Play();
	}
}


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="";	//选中日期的字体颜色
}

function setday(tt,obj) //主调函数
{
	if (arguments.length >  2){alert("对不起！传入本控件的参数太多！");return;}
	if (arguments.length == 0){alert("对不起！您没有传回本控件任何参数！");return;}
	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;
	if(document.body.clientWidth-(tleft-document.body.scrollLeft)<144 && tleft-document.body.scrollLeft>144)	//added in Ver 2.2
		dads.left = tleft + twid - 144 + ((ttyp=="image")? 0:4)
	else dads.left = tleft;
	wpCalendar.tgtObject = (arguments.length == 1) ? th : obj;
	wpCalendar.srcButton = (arguments.length == 1) ? 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	=r[t[1]];
		wpCalendar.Month=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;
	}
}


function document.onclick(){		//任意点击时关闭该控件
	with(window.event)
		if (srcElement != wpCalendar.tgtObject && srcElement != wpCalendar.srcButton)
		wpCalendar.Close();
}

function document.onkeyup(){		//按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 作者：LiuYing_Andy";	//主题的版本信息
	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 作者：LiuYing_Andy";	//主题的版本信息
	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 作者：LiuYing_Andy";	//主题的版本信息
	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 作者：LiuYing_Andy";	//主题的版本信息
	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["Custom"]=new CalendarTheme();
	theme["Custom"].VersionInfo			= "主题：Custom 作者：LiuYing_Andy";	//主题的版本信息
	theme["Custom"].fontFamily			= "宋体";		//字体
	theme["Custom"].borderColor			= "#666666";	//边框颜色
	theme["Custom"].borderColorDark		= "#FFFFFF";	//边框暗部颜色
	theme["Custom"].bgColorMain			= "#666666";	//日历主背景色
	theme["Custom"].bgColorLight		= "#F0F0F0";	//日历的浅背景色
	theme["Custom"].headBgColor			= "#F0F0F0";	//日历头部背景色
	theme["Custom"].headFontColor		= "#000000";	//日历头部字体颜色
	theme["Custom"].mouseOverColor		= "#666666";	//鼠标移动的背景色
	theme["Custom"].mouseOverFontColor	= "#000000";	//鼠标移动的字体颜色
	theme["Custom"].buttonBorderColor	= "#000000";	//按钮边框颜色
	theme["Custom"].buttonColor			= "#F0F0F0";	//按钮的主色调
	theme["Custom"].buttonFontColor		= "#000000";	//按钮文字颜色
	theme["Custom"].dragBarFontColor	= "#FFFFFF";	//拖动条的文字颜色
	theme["Custom"].dragBarColor		= "#666666";	//拖动条的边框颜色
	theme["Custom"].dragBarColorDark	= "#666666";	//拖动条的边框暗部颜色
	theme["Custom"].normalDayColor		= "#F0F0F0";	//日期的背景颜色
	theme["Custom"].normalDayFontColor	= "#000000";	//日期的字体颜色
	theme["Custom"].grayDayColor		= "#F0F0F0";	//非本月日期的背景颜色
	theme["Custom"].grayDayFontColor	= "#808080";	//非本月日期的字体颜色
	theme["Custom"].todayColor			= "#666666";	//当前日期的背景颜色
	theme["Custom"].todayFontColor		= "#000000";	//当前日期的字体颜色
	theme["Custom"].selectedDayColor	= "#666666";	//选中日期的背景颜色
	theme["Custom"].selectedDayFontColor= "#FFFFFF";	//选中日期的字体颜色

	theme["DiabloII"]=new CalendarTheme();
	theme["DiabloII"].VersionInfo			= "主题：DiabloII 作者：LiuYing_Andy";	//主题的版本信息
	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();

// -->


			function setnumber(obj)
			{
				former = new Integer(obj.value);
				document.all.txtBookFee.value = former;
			}
			function AllTrim(x)
			{
				while((x.length>0) && (x.charAt(0)==' '))
			{
				x = x.substring(1,x.length);
			}
 
			while((x.length>0) && (x.charAt(x.length-1)==' '))
			{
				x = x.substring(0,x.length-1);
			}

				return x;
			}  

		function AllTrim(x)
{
	while((x.length>0) && (x.charAt(0)==' '))
	{
		x = x.substring(1,x.length);
	}
 
	while((x.length>0) && (x.charAt(x.length-1)==' '))
	{
		x = x.substring(0,x.length-1);
	}

	return x;
}  


function checkLength(val,msg)
{

	var string = AllTrim(val.value);
	//var Msg = msg;
	
	if(string.length == 0)
	{
		alert(msg);
		val.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function DateCheck(start,end,msg)
{
	if(new Date(start.value) >= new Date(end.value))
	{
		alert(msg);
		end.focus();
		return false;
	}
	return true;
}


function onDateInputLeave(obj, msg)
{
	var txt=AllTrim(obj.value);
	if(txt != "")
	{
		
		if(!isValidDate(txt))
		{
			alert(msg);
			obj.focus();
			//obj.style.backgroundColor="Coral";
			obj.select();
			return false;
		}
		else
		{
	    	return true;
		
		}
	}

}


function checkRadioButton(obj1,obj2,msg)
{
	if(obj1.checked == false && obj2.checked == false)
	{
		window.alert(msg);
		obj1.focus();
		return false;
	}
	return true;
}

		function checkNumber(obj,msg)
		{
			if(isNaN(obj.value) )
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			else
			{
				return true;
			}
		}
		
		function checkRequestDdlAndFocus(obj, msg)
		{
	
		if(obj.selectedIndex == 0)
		{
			window.alert(msg);
			//obj.style.backgroundColor="Coral";
			obj.focus();
			return false;
		}

		return true;
	}
	function setClassName(obj)
	{
		if(obj.selectedIndex != 0)
		{
			//if(document.all.txtClassName.value == "")
			//{
				document.all.txtClassName.value = obj.options[obj.selectedIndex].text;
			//}
		}
	}
	
	function isValidDate(val)
{
	var inText = AllTrim(val);	
	var rex = new RegExp("^(?=\\d)(?:(?!(?:1582(?:\\.|-|\\/)10(?:\\.|-|\\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\\.|-|\\/)0?9(?:\\.|-|\\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\\d\\d)(?:[02468][048]|[13579][26]))\\D0?2\\D29)|(?:\\d{4}\\D(?!(?:0?[2469]|11)\\D31)(?!0?2(?:\\.|-|\\/)(?:29|30))))(\\d{4})([-\\/.])(0?\\d|1[012])\\2((?!00)[012]?\\d|3[01])(?:$|(?=\\x20\\d)\\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\\d){0,2}(?:\\x20[aApP][mM]))|(?:[01]\\d|2[0-3])(?::[0-5]\\d){1,2})?$");

	return rex.test(inText);
}
	
	function setClassName2(obj)
	{
		//document.all.txtAddress.value
		var selectValue = obj.value;
		for(i=0 ;i<number;i++)
		{
			if (selectsSite[i][0] == selectValue) 
			{ 
				document.all.txtAddress.value = selectsSite[i][1];
			} 
		}

	}
	
function IsScroll(obj1,obj2,obj3)
{
	if(obj1.options(obj1.selectedIndex).text == '随到随学')
	{
		//error1();
		obj2.style.color = 'white';
		obj3.style.color = 'white';
		//obj4.style.color = 'white';
		obj2.value = '1900-01-01';
		obj3.value = '1900-01-01';
		//obj4.value = '1900-01-01';
		obj2.disabled = true;
		obj3.disabled = true;
		//obj4.disabled = true;
	}
	else if(document.all.txtbakClass_Time_Type.value == '随到随学' )
	{
		obj2.style.color = 'black';
		obj3.style.color = 'black';
		//obj4.style.color = 'black';
		obj2.value = '';
		obj3.value = '';
		//obj4.value = '';
		obj2.disabled = false;
		obj3.disabled = false;
		//obj4.disabled = false;
	}
	else
	{
		obj2.style.color = 'black';
		obj3.style.color = 'black';
		//obj4.style.color = 'black';
		obj2.disabled = false;
		obj3.disabled = false;
		//obj4.disabled = false;
	}
	document.all.txtbakClass_Time_Type.value = obj1.options(obj1.selectedIndex).text;
}
