﻿document.writeln('<div id=dropblueDateLayer style="position: absolute; width: 182; height: 166; z-index: 999999999999999; display: none">');
document.writeln('<span id=tmpSelectYearLayer  style="z-index: 9999;position: absolute;top: 2; left: 18;display: none"></span>');
document.writeln('<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 2; left: 75;display: none"></span>');
document.writeln('<table border=0 cellspacing=1 cellpadding=0 width=182 height=160 bgcolor=#A6C9E2 onselectstart="return false">');
document.writeln('  <tr><td width=182 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=180 height=23>');
document.writeln('      <tr align=center><td width=20 align=center bgcolor=#A6C9E2 style="font-family:宋体;font-size:12px;cursor: hand;color: #000000" ');
document.writeln('        onclick="dropbluePrevM()" title="向前翻　月" Author=dropblue>&lt;&lt;');
document.writeln('        </td><td width=140 align=center style="font-family:宋体;font-size:13px;cursor:default" Author=dropblue>');
document.writeln('        <span Author=dropblue id=dropblueYearHead onclick="tmpSelectYearInnerHTML(this.innerText)"></span>&nbsp;年&nbsp;<span');
document.writeln('         id=dropblueMonthHead Author=dropblue onclick="tmpSelectMonthInnerHTML(this.innerText)"></span>&nbsp;月</td>');
document.writeln('        <td width=20 bgcolor=#A6C9E2 align=center style="font-family:宋体;font-size:12px;cursor: hand;color: #000000" ');
document.writeln('         onclick="dropblueNextM()" title="往后翻　月" Author=dropblue>&gt;&gt;</td></tr>');
document.writeln('    </table></td></tr>');
document.writeln('  <tr><td width=182 height=18 bgcolor=#70A8D2>');
document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=180 height=1 style="cursor:default">');
document.writeln('<tr align=center><td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>日</td>');
document.writeln('<td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>一</td><td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>二</td>');
document.writeln('<td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>三</td><td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>四</td>');
document.writeln('<td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>五</td><td style="font-family:宋体;font-size:13px;color:#FFFFFF" Author=dropblue>六</td></tr>');
document.writeln('</table></td></tr>');
document.writeln('  <tr><td width=182 height=120>');
document.writeln('    <table border=0 cellspacing=2 cellpadding=0 width=180 height=120 bgcolor=#FFFFFF>');
var n=0; for (j=0;j<6;j++){     document.writeln(' <tr align=center>'); for (i=0;i<7;i++){
document.writeln('<td width=24 height=20 id=dropblueDay'+n+' style="font-family:宋体;font-size:12px;border-color:#A6C9E2;border-width:1px;border-style:solid;" Author=dropblue></td>');n++;}
document.writeln('</tr>');}
document.writeln('    </table></td></tr><tr><td>');
document.writeln('        <table border=0 cellspacing=1 cellpadding=0 width=180 height=20 bgcolor=#FFFFFF>');
document.writeln('          <tr><td width=20 Author=dropblue bgcolor=#A6C9E2 align=center  title="向前翻　年" onclick="dropbluePrevY()" onfocus="this.blur()" style="font-family:宋体;font-size:12px;cursor: hand;color: #000000">&lt;&lt;</td> ');
document.writeln('             <td width=20 Author=dropblue bgcolor=#A6C9E2 align=center title="向前翻　月" onfocus="this.blur()" onclick="dropbluePrevM()" style="font-family:宋体;font-size:12px;cursor: hand;color: #000000">&lt;</td> ');
document.writeln('             <td Author=dropblue align=center width=20></td> ');
document.writeln('             <td width=40 Author=dropblue bgcolor=#A6C9E2 align=center title="转到今天的日期" onfocus="this.blur()" onclick="dropblueToday()" style="font-family:宋体;font-size:12px;cursor: hand;color: #000000">今天</td> ');
document.writeln('             <td Author=dropblue align=center width=20></td> ');
document.writeln('             <td width=20 Author=dropblue bgcolor=#A6C9E2 align=center title="往后翻　月" onfocus="this.blur()" onclick="dropblueNextM()" style="font-family:宋体;font-size:12px;cursor: hand;color: #000000">&gt;</td> ');
document.writeln('             <td width=20 Author=dropblue bgcolor=#A6C9E2 align=center title="往后翻　年" onfocus="this.blur()" onclick="dropblueNextY()" style="font-family:宋体;font-size:12px;cursor: hand;color: #000000">&gt;&gt;</td> ');
document.writeln('</tr></table></td></tr></table></div>');　

var dropblue_outobj;
var dropbluedTBgcolor=1;

function setday(tt,obj){
  if (arguments.length >  2){alert("对不起！传入本控件的参数太多！");return;}
  if (arguments.length == 0){alert("对不起！您没有传回本控件任何参数！");return;}
  var dads  = document.all.dropblueDateLayer.style;var th = tt;
  var ttop  = tt.offsetTop;    
  var thei  = tt.clientHeight;  
  var tleft = tt.offsetLeft;    
  var ttyp  = tt.type;         
  while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
  dads.left = tleft;
  dropblue_outobj = (arguments.length == 1) ? th : obj;
  dads.display = '';
  event.returnValue=false;
}　

var dropblueMonHead = new Array(12);               
    dropblueMonHead[0] = 31; dropblueMonHead[1] = 28; dropblueMonHead[2] = 31; dropblueMonHead[3] = 30; dropblueMonHead[4]  = 31; dropblueMonHead[5]  = 30;
    dropblueMonHead[6] = 31; dropblueMonHead[7] = 31; dropblueMonHead[8] = 30; dropblueMonHead[9] = 31; dropblueMonHead[10] = 30; dropblueMonHead[11] = 31;　

var dropblueTheYear=new Date().getFullYear(); 
var dropblueTheMonth=new Date().getMonth()+1; 
var dropblueWDay=new Array(37);               

function document.onclick(){ 
  with(window.event.srcElement){
    if (tagName != "INPUT" && getAttribute("Author")==null)
    document.all.dropblueDateLayer.style.display="none";
  }
}　

function dropblueWriteHead(yy,mm){
    document.all.dropblueYearHead.innerText  = yy;
    document.all.dropblueMonthHead.innerText = mm;
}　

function tmpSelectYearInnerHTML(strYear){
  if (strYear.match(/\D/)!=null){alert("年份输入参数不是数字！");return;}
  var m = (strYear) ? strYear : new Date().getFullYear();
  if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间！");return;}
  var n = m - 60;
  if (n < 1000) n = 1000;
  if (n + 120 > 9999) n = 9974;
  var s = "<select Author=dropblue name=tmpSelectYear style='font-family:宋体;font-size: 12px' "
     s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
     s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
     s += "dropblueTheYear = this.value; dropblueSetDay(dropblueTheYear,dropblueTheMonth)'>\r\n";
  var selectInnerHTML = s;
  for (var i = n; i < n + 120; 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="";
  document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML;
  document.all.tmpSelectYear.focus();
}　

function tmpSelectMonthInnerHTML(strMonth){
  if (strMonth.match(/\D/)!=null){alert("月份输入参数不是数字！");return;}
  var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
  var s = "<select Author=dropblue name=tmpSelectMonth style='font-family:宋体;font-size: 12px' "
     s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' "
     s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";"
     s += "dropblueTheMonth = this.value; dropblueSetDay(dropblueTheYear,dropblueTheMonth)'>\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="";
  document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
  document.all.tmpSelectMonth.focus();
}　

function closeLayer(){
    document.all.dropblueDateLayer.style.display="none";
}　

function document.onkeydown(){
    if (window.event.keyCode==27)document.all.dropblueDateLayer.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){
    var c=dropblueMonHead[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 dropbluePrevY(){
    if(dropblueTheYear > 999 && dropblueTheYear <10000){dropblueTheYear--;}
    else{alert("年份超出范围（1000-9999）！");}
    dropblueSetDay(dropblueTheYear,dropblueTheMonth);
}

function dropblueNextY(){
    if(dropblueTheYear > 999 && dropblueTheYear <10000){dropblueTheYear++;}
    else{alert("年份超出范围（1000-9999）！");}
    dropblueSetDay(dropblueTheYear,dropblueTheMonth);
}

function dropblueToday(){
    dropblueTheYear = new Date().getFullYear();
    dropblueTheMonth = new Date().getMonth()+1;
    dropblueSetDay(dropblueTheYear,dropblueTheMonth);
}

function dropbluePrevM(){
    if(dropblueTheMonth>1){dropblueTheMonth--}else{dropblueTheYear--;dropblueTheMonth=12;}
    dropblueSetDay(dropblueTheYear,dropblueTheMonth);
}

function dropblueNextM(){
    if(dropblueTheMonth==12){dropblueTheYear++;dropblueTheMonth=1}else{dropblueTheMonth++}
    dropblueSetDay(dropblueTheYear,dropblueTheMonth);
}　

function dropblueSetDay(yy,mm){
  dropblueWriteHead(yy,mm);
  for (var i = 0; i < 42; i++){dropblueWDay[i]=""};  
  var day1 = 1,firstday = new Date(yy,mm-1,1).getDay();  
  for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){dropblueWDay[i]=day1;day1++;}
  for (var i = 0; i < 42; i++){
    var da = eval("document.all.dropblueDay"+i)     
    if (dropblueWDay[i]!=""){
        da.innerHTML = "" + dropblueWDay[i] + "";
        da.style.backgroundColor = (yy == new Date().getFullYear() &&
        mm == new Date().getMonth()+1 && dropblueWDay[i] == new Date().getDate()) ? "#FFF18B" : "#E2F0F7";
        da.style.cursor="hand"
        da.setAttribute("onclick",function(){dropblueDayClick(this.innerText);});
        da.setAttribute("onmouseover",function(){dataTimeOnmouseover(this);});
        da.setAttribute("onmouseout",function(){dataTimeOnmouseout(this);});
      }
    else{
        da.innerHTML="&nbsp;";
        da.style.backgroundColor="#E2F0F7";
        da.style.cursor="default";
        da.setAttribute("onclick",null);
        da.setAttribute("onmouseover",null);
        da.setAttribute("onmouseout",null);
    }
  }
}

function dropblueDayClick(n){
  var yy = dropblueTheYear;
  var mm = dropblueTheMonth;
  if (mm < 10){mm = "0" + mm;}
  if (dropblue_outobj){
    if (!n) {dropblue_outobj.value=""; return;}
    if ( n < 10){n = "0" + n;}
    dropblue_outobj.value= yy + "-" + mm + "-" + n ; 
    closeLayer(); 
  }
  else {closeLayer(); alert("您所要输出的控件对象并不存在！");}
}

function dataTimeOnmouseover(obj){
    dropbluedTBgcolor=obj.style.backgroundColor;
    obj.style.backgroundColor="#A6C9E2";
}

function dataTimeOnmouseout(obj){
    obj.style.backgroundColor=dropbluedTBgcolor;
}

dropblueSetDay(dropblueTheYear,dropblueTheMonth);
