document.writeln('<div id="meizzDateLayer" dragable="dragable" style="position:absolute;width:100;left:120;top:160;display:none;" >');
document.writeln('<table width="0%" height="100%" border="1" bordercolor="#0080FF" cellspacing="0" cellpadding="0">');
document.writeln('<tr bgcolor="#0080FF" style="cursor:move">');
document.writeln('<td align="right" width="100%" height="25px" onMousedown="initializedragie(event)">');
document.writeln('<ilayer onSelectStart="return false">');
document.writeln('<layer onMouseover="dragswitch=1;drag_dropns(meizzDateLayer)" onMouseout="dragswitch=0">');
document.writeln('<layer onMouseover="dragswitch=1;drag_dropns(meizzDateLayer)" onMouseout="dragswitch=0">');
document.writeln('</layer>');
document.writeln('</layer>');
document.writeln('</ilayer>');
document.writeln('<img src="./admin/images/01.gif" border="0" style="cursor:pointer" onClick="hidebox();return false">');
document.writeln('</td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<td colspan="2">');
document.writeln('<font face="細明體" size="2" color="#80BFFF">');
document.writeln('<span id=tmpSelectYearLayer  style="z-index: 9999;position: absolute;top: 30; left: 28px;display: block"></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 30; left: 90px;display: block"></span>');
document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=161 height=160 bgcolor=#808080 onselectstart="return false">');
document.writeln('  <tr><td width=142 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=161 height=23>');
document.writeln('      <tr align="center"><td width=20 align="center" bgcolor=#808080 style="font-size:12px;cursor: pointer;color: #FFD700" ');
document.writeln('        onclick="meizzPrevM()" title="向前翻　月" ><b >&lt;&lt;</b>');
document.writeln('        </td><td width=100 align="center" style="font-size:12px;cursor:default" >');
document.writeln('        <span  id="meizzYearHead" onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
document.writeln('         id=meizzMonthHead  onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
document.writeln('        <td width=20 bgcolor=#808080 align=center style="font-size:12px;cursor: pointer;color: #FFD700" ');
document.writeln('         onclick="meizzNextM()" title="往后翻　月" ><b >&gt;&gt;</b></td></tr>');
document.writeln('    </table></td></tr>');
document.writeln('  <tr><td width=142 height=18 bgcolor=#808080>');
document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=161 height=1 style="cursor:default">');
document.writeln('<tr align=center><td style="font-size:12px;color:#FFFFFF" >日</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" >一</td><td style="font-size:12px;color:#FFFFFF" >二</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" >三</td><td style="font-size:12px;color:#FFFFFF" >四</td>');
document.writeln('<td style="font-size:12px;color:#FFFFFF" >五</td><td style="font-size:12px;color:#FFFFFF" >六</td></tr>');
document.writeln('</table></td></tr>');
document.writeln('  <tr><td width=142 height=120>');
document.writeln('    <table border=0 cellspacing=1 cellpadding=0 width=161 height=120 bgcolor=#FFFFFF>');
var n=0; for (j=0;j<5;j++){ document.writeln (' <tr align=center>'); for (i=0;i<7;i++){
document.writeln('<td width=23 height=20 id="meizzDay'+n+'" style="font-size:12px"  onclick="meizzDayClick(this)"></td>');n++;}
document.writeln('</tr>');}
document.writeln('      <tr align=center><td width=23 height=20 style="font-size:12px" id=meizzDay35  ');
document.writeln('         onclick=meizzDayClick(this)></td>');
document.writeln('        <td width=23 height=20 style="font-size:12px" id="meizzDay36"  onclick=meizzDayClick(this)></td></tr>');
document.writeln('    </table></td></tr><tr><td>');
document.writeln('        <table border=0 cellspacing=1 cellpadding=0 width="161px" height="8px" bgcolor=#FFFFFF>');
document.writeln('          <tr><td  align="left"><input  type="button" value="<<" title="向前翻　年" onclick="meizzPrevY()" ');
document.writeln('             onfocus="this.blur()" style="font-size: 12px; width: 20px; height: 20px"><input title="向前翻　月" type="button" ');
document.writeln('             value="<" onclick="meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; width: 15px; height: 20px"></td><td ');
document.writeln('              align=center><input  type="button" value="今天" onclick="meizzToday()" ');
document.writeln('             onfocus="this.blur()" title="到今天的日期" style="font-size: 12px; height: 20px">');
document.writeln('  <input type=button value=清空 onclick="ClearDay();" title="將資料清空" style="background-color:#CCFF99;font-size: 12px; height: 20px"></td><td ');
document.writeln('              align=right><input  type=button value=">" onclick="meizzNextM()" ');
document.writeln('             onfocus="this.blur()" title="往后翻　月" style="font-size: 12px; width: 15px; height: 20px"><input ');
document.writeln('              type=button value=">>" title="往后翻　年" onclick="meizzNextY()"');
document.writeln('             onfocus="this.blur()" style="font-size: 12px; width: 20px; height: 20px"></td>');
document.writeln('</tr></table></td></tr></table>');　

document.writeln('</font>');
document.writeln('</td>');
document.writeln('</tr>');
document.writeln('</table>');
document.writeln('</div>');



//==================================================== WEB ?面?示部分 ======================================================
var outObject;
var dateStyles;	//null：2007/03/28；
var Public_tt;

function setday(tt,obj) //主?函?
{
  if(Public_tt != null) hidebox();
  if (arguments.length >  2){alert("?不起！?入本控件的??太多！");return;}
  if (arguments.length == 0){alert("?不起！您?有?回本控件任何??！");return;}
  /*if(document.all)												//IE
  {
	Public_tt = document.getElementById("meizzDateLayer");
  }         
  else  															//FireFox
  {  
	var evt = document.createEvent("MouseEvents");  
	evt.initEvent("click",true,true);  
	document.getElementById("meizzDateLayer").dispatchEvent(evt);  
  }*/  
  Public_tt = document.all.meizzDateLayer;
  var dads  = Public_tt.style;var th = tt;
  var ttop  = tt.offsetTop;     //TT控件的定位?高
  var thei  = tt.clientHeight;  //TT控件本身的高
  var tleft = tt.offsetLeft;    //TT控件的定位??
  var ttyp  = tt.type;          //TT控件的?型
  while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
  dads.left = tleft;
  outObject = (arguments.length == 1 || arguments.length == 2) ? th : obj;
  dateStyles = (arguments.length == 2) ? obj : null;
  dads.display = '';
  meizzYearHead.onclick();
  meizzMonthHead.onclick();
  //event.returnValue=false;
	if (window.event) //IE
	{
		event.returnValue = false;   //event.returnValue=false 效果相同.
	}
	else //Firefox
	{
		return false;
	}

}　

var MonHead = new Array(12);               //定???中每?月的最大天?
    MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4]  = 31; MonHead[5]  = 30;
    MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;　

var meizzTheYear=new Date().getFullYear(); //定?年的?量的初始值
var meizzTheMonth=new Date().getMonth()+1; //定?月的?量的初始值
var meizzWDay=new Array(37);               //定??日期的??　

document.onclick = function()
{ //任意??????控件
	if(document.all) 
	{	//ie
	  with(window.event.srcElement)
	  {
		/*
		 if (tagName != "INPUT" && getAttribute("Author")==null)
		document.all.meizzDateLayer.style.display="none";
		*/
	  }
	}
}　

function meizzWriteHead(yy,mm)  //往 head 中?入?前的年与月
{ 
	//if(document.all)												//IE
	//{
		document.all.meizzYearHead.innerText  = yy;
		document.all.meizzMonthHead.innerText = mm;
	//}
	//else
	//{
		//document.all.meizzYearHead.textContent = yy;
		//document.all.meizzMonthHead.textContent = mm;
	//}
}　

function tmpSelectYearInnerHTML(strYear) //年份的下拉框
{
  if (strYear.toString().match(/\D/)!=null){alert("年份?入??不是?字！");return;}
  var m = (strYear) ? strYear : new Date().getFullYear();
  if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之?！");return;}
  var n = m - 100;
  if (n < 1000) n = 1000;
  if (n + 136 > 9999) n = 9974;
  var s = "<select  name='tmpSelectYear' style='font-size: 12px' "
     s += "onblur='document.all.tmpSelectYearLayer.style.display=\"block\"' "
     s += "onchange='document.all.tmpSelectYearLayer.style.display=\"block\";"
     s += "meizzTheYear = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\r\n";
  var selectInnerHTML = s;
  for (var i = n; i < n + 136; i++)
  {
    if (i == m)
       {selectInnerHTML += "<option value='" + i + "' selected>" + i + "年" + "</option>\r\n";}
    else {selectInnerHTML += "<option value='" + i + "'>" + i + "年" + "</option>\r\n";}
  }
  selectInnerHTML += "</select>";
  document.all.tmpSelectYearLayer.style.display="block";
  document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
  document.all.tmpSelectYear.focus();
}　

function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框
{
  if (strMonth.toString().match(/\D/)!=null){alert("月份?入??不是?字！");return;}
  var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
  var s = "<select  name=tmpSelectMonth style='font-size: 12px' "
     s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"block\"' "
     s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"block\";"
     s += "meizzTheMonth = this.value; meizzSetDay(meizzTheYear,meizzTheMonth)'>\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>";
  document.all.tmpSelectMonthLayer.style.display="block";
  document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
  document.all.tmpSelectMonth.focus();
}　

function closeLayer()               //???的??
  {
    Public_tt.style.display="none";
  }　

document.onkeydown = function()
{
	if(Public_tt != null)
	{
		if (document.all) //IE
		{
	    	if (window.event.keyCode==27)Public_tt.style.display="none";
		}
		else
		{
			if (evt.keyCode==27)Public_tt.style.display="none";
		}
	}
}　

function IsPinYear(year)            //判?是否?平年
  {
    if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
  }　

function GetMonthCount(year,month)  //?年二月?29天
  {
    var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
  }　

function GetDOW(day,month,year)     //求某天的星期几
  {
    var dt=new Date(year,month-1,day).getDay()/7; return dt;
  }　

function meizzPrevY()  //往前翻 Year
  {
    if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
    else{alert("年份超出范?（1000-9999）！");}
    meizzSetDay(meizzTheYear,meizzTheMonth);
	meizzYearHead.onclick();
  }
function meizzNextY()  //往后翻 Year
  {
    if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
    else{alert("年份超出范?（1000-9999）！");}
    meizzSetDay(meizzTheYear,meizzTheMonth);
	meizzYearHead.onclick();
  }
function meizzToday()  //Today Button
  {
    meizzTheYear = new Date().getFullYear();
    meizzTheMonth = new Date().getMonth()+1;
    meizzSetDay(meizzTheYear,meizzTheMonth);
	meizzYearHead.onclick();
    meizzMonthHead.onclick();
  }
function meizzPrevM()  //往前翻月份
  {
    if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
    meizzSetDay(meizzTheYear,meizzTheMonth);
	meizzMonthHead.onclick();
    meizzYearHead.onclick();
    meizzMonthHead.onclick();
  }
function meizzNextM()  //往后翻月份
  {
    if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
    meizzSetDay(meizzTheYear,meizzTheMonth);
	  meizzMonthHead.onclick();
	  meizzYearHead.onclick();
	  meizzMonthHead.onclick();
  }　

function meizzSetDay(yy,mm)   //主要的?程序**********
{
  meizzWriteHead(yy,mm);
  for (var i = 0; i < 37; i++){meizzWDay[i]=""};  //??示框的?容全部清空
  var day1 = 1,firstday = new Date(yy,mm-1,1).getDay();  //某月第一天的星期几
  for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
  for (var i = 0; i < 37; i++)
  { var da = eval("document.all.meizzDay"+i)     //??新的一?月的日期星期排列
    if (meizzWDay[i]!="")
      { da.innerHTML = "<b>" + meizzWDay[i] + "</b>";
        da.style.backgroundColor = (yy == new Date().getFullYear() &&
        mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6";
        da.style.cursor="pointer"
      }
    else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
  }
}

function FormatYear(iStr)
{	
	//2007轉換成096
	var tmpStr = parseInt(iStr) - 1911;
	var tmpStr = parseInt(iStr);
	str = new String(tmpStr);
	if(str.length == 2)
		return ("0" + str);
	else
		return str;	
}

function meizzDayClick(n)  //???示框?取日期，主?入函?*************
{
  if(document.all)												//IE
  {
	n = n.innerText;
  }
  else
  {
	n = n.textContent;
  }
  
  var fullDate;
  var yy = meizzTheYear;
  var mm = meizzTheMonth;
  if (mm < 10){mm = "0" + mm;}
  if (outObject)
  {
    if (!n) {outObject.value=""; return;}
    if ( n < 10){n = "0" + n;}
    
    switch(dateStyles)
    {
		case null:
			fullDate = yy + "/" + mm + "/" + n ; //注：在?里你可以?出改成你想要的格式
			break;
		case "-":
			fullDate = yy + "-" + mm + "-" + n ;
			break;
		case "yyyymmdd":
			fullDate = yy + mm + n ;
			break;
		case "yyymmdd":
			fullDate = FormatYear(yy) + mm + n ;
			break;
	}
	outObject.value = fullDate;
    closeLayer(); 
  }
  else {closeLayer(); alert("您所要?出的控件?象并不存在！");}
}

function ClearDay()
{
	outObject.value = '';
	closeLayer();
}
meizzSetDay(meizzTheYear,meizzTheMonth);