﻿<!--

//??????????????
var sd_date_start,sd_date_end,sd_g_object
var sd_today = new Date();
var sd_separator=".";
var sd_inover=false;

//mode :??????????????0-?? 1-?? 2-??????????
function sd_change_date(temp,mode)
{
	var t_month,t_year
    if (mode){
        if(mode==1)
        t_month=parseInt(cele_date_month.value,10)+parseInt(temp,10);
        else
        t_month=parseInt(temp)
        if (t_month<cele_date_month.options(0).text) {
            cele_date_month.value=cele_date_month.options(cele_date_month.length-1).text;
            sd_change_date(parseInt(cele_date_year.value,10)-1,0);
            }
        else{
            if (t_month>cele_date_month.options(cele_date_month.length-1).text){
                cele_date_month.value=cele_date_month.options(0).text;
                sd_change_date(parseInt(cele_date_year.value,10)+1,0);
                }
            else
                {cele_date_month.value=t_month;
                 sd_set_cele_date(cele_date_year.value,cele_date_month.value);
                }
        }
    }
    else{
        t_year=parseInt(temp,10);

        if (t_year<cele_date_year.options(0).text) {
            cele_date_year.value=cele_date_year.options(0).text;
            sd_set_cele_date(cele_date_year.value,1);
            }
        else{
            if (parseInt(t_year,10)>parseInt(cele_date_year.options(cele_date_year.length-1).text,10)){
                cele_date_year.value=cele_date_year.options(cele_date_year.length-1).text;
                sd_set_cele_date(cele_date_year.value,12);
                }
            else
                {cele_date_year.value=t_year;
                 sd_set_cele_date(cele_date_year.value,cele_date_month.value);
                }
        }
    }
    window.cele_date.focus();
}

//??????????
function sd_init(d_start,d_end)
{
     var temp_str;
     var i=0
     var j=0
   //  sd_date_start=new Date(2000,7,1)
   // sd_date_end=new Date(2004,8,1)

     window.cele_date.innerHTML="";
     //### here is chang color####################
     //###########################################
     temp_str="<table border=\"1\"   width=\"240\" bgcolor=\"#aaaaaa\" bordercolor=\"white\"><tr><td colspan=7 onmouseover=\"sd_overcolor(this)\">";
     temp_str+="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td width=\"5\">&nbsp;</td><td><input type=\"Button\" value=\"<\" onclick=\"sd_change_date(-1,1)\" onmouseover=\"sd_getlayerfocus()\"  style=\"color: #000000; background-color: #eeeeee;width:25px; padding-left:5px;cursor: hand\"></td>";//??????????
     temp_str+="";//??
     temp_str+="<td><select name=\"cele_date_year\" id=\"cele_date_year\" language=\"javascript\" onchange=\"sd_change_date(this.value,0)\" onmouseover=\"sd_getlayerfocus()\" onblur=\"sd_getlayerfocus()\" style=\"font-size: 8pt; border: 1px #666666 outset;width:55px; background-color: #F4F8FB\">";

     for (i=d_start;i<=d_end;i++)
     {
     temp_str+="<OPTION value=\""+i.toString()+"\">"+i.toString()+"</OPTION>";
     }
     temp_str+="</select></td>";
     temp_str+="" ;//??
     temp_str+="<td><select name=\"cele_date_month\" id=\"cele_date_month\" language=\"javascript\" onchange=\"sd_change_date(this.value,2)\" onmouseover=\"sd_getlayerfocus()\" onblur=\"sd_getlayerfocus()\" style=\"font-size: 8pt; border: 1px #666666 outset;width:40px; background-color: #F4F8FB\">";


     for (i=1;i<=12;i++)
     {
     temp_str+="<OPTION value=\""+i.toString()+"\">"+i.toString()+"</OPTION>";
     }
     temp_str+="</select></td>";
     temp_str+="";//??????
     temp_str+="<td><input type=\"Button\" value=\">\" onclick=\"sd_change_date(1,1)\" onmouseover=\"sd_getlayerfocus()\"  style=\"color: #000000; background-color: #eeeeee;width:25px; padding-left:5px;cursor: hand\"></td>";
     temp_str+="";//????????
     temp_str+="<td><input type=\"Button\" value=\"none\" onclick=\"clear_date()\" onmouseover=\"sd_getlayerfocus()\"  style=\"color: #000000; background-color: #eeeeee;width:45px;padding-left:3px; cursor: hand\"></td>";


     temp_str+="<td width=\"5\">&nbsp;</td><tr></table></td></tr><tr>";
     temp_str+="<td onmouseover=\"sd_overcolor(this)\" width=\"14%\" align=\"center\"><font color=red>Sun</font></td>";
     temp_str+="<td width=\"14%\" align=\"center\">Mon</td>"; 
     temp_str+="<td width=\"14%\" align=\"center\">Tue</td>"; 
     temp_str+="<td width=\"14%\" align=\"center\">Wed</td>";
     temp_str+="<td width=\"14%\" align=\"center\">Thu</td>";
     temp_str+="<td width=\"14%\" align=\"center\">Fri</td>"; 
     temp_str+="<td width=\"14%\" align=\"center\"><font color=red>Sat</font></td></tr>";
     for (i=1 ;i<=6 ;i++)
     {
     temp_str+="<tr>";
        for(j=1;j<=7;j++){
            temp_str+="<td align=\"center\" name=\"c"+i+"_"+j+"\" id=\"c"+i+"_"+j+"\" style=\"CURSOR: hand;COLOR:#000000\"  onmouseover=\"sd_overcolor(this)\" onmouseout=\"sd_outcolor(this)\" onclick=\"sd_td_click(this)\">01</td>";
            }
     temp_str+="</tr>";
     }
     temp_str+="</td></tr>";
     temp_str+="<tr><td colspan=\"7\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td width =\"5\">&nbsp;</td><td id=\"selectDateID\"></td><td>";
     temp_str+="&nbsp;<select id=\"hourID\" style=\"width:40px\">";
     for (var i=0;i<24;i++) {
       if(i<10)  
         temp_str+=" <option value="+i+">0"+i+"</option>";
       else
         temp_str+=" <option value="+i+">"+i+"</option>"; 
     }
     temp_str+="</select >";
     temp_str+="</td><td>:</td><td><select  id=\"minuteID\"  style=\"width:40px\">";
     for (var i=0;i<60;i++) {
       if(i<10)  
         temp_str+=" <option value="+i+">0"+i+"</option>";
       else
         temp_str+=" <option value="+i+">"+i+"</option>"; 
     }
     temp_str+="</select></td><td></td> <td width=\"40%\"><input type=\"button\" name=\"ok\" value=\"OK\" onclick=\"selectDateTime(hourID,minuteID)\"  style=\"color: #000000; background-color: #eeeeee;width:45px;padding-left:3px; cursor: hand\"></td></tr></table></td></tr>"
     temp_str+="</table>";
     window.cele_date.innerHTML=temp_str;
}


function sd_set_cele_date(year,month)
{
   var i,j,p,k
   var nd=new Date(year,month-1,1);
   event.cancelBubble=true;
   cele_date_year.value=year;
   cele_date_month.value=month;
   k=nd.getDay()-1
   var temp;
   for (i=1;i<=6;i++)
      for(j=1;j<=7;j++)
      {
      eval("c"+i+"_"+j+".innerHTML=\"\"");
      eval("c"+i+"_"+j+".bgColor=\"#eeeeee\"");
      eval("c"+i+"_"+j+".style.cursor=\"hand\"");
      }
   while(month-1==nd.getMonth())
    { j=(nd.getDay() +1);
      p=parseInt((nd.getDate()+k) / 7)+1;
      eval("c"+p+"_"+j+".innerHTML="+"\""+nd.getDate()+"\"");
      if ((nd.getDate()==sd_today.getDate())&&(cele_date_month.value==sd_today.getMonth()+1)&&(cele_date_year.value==sd_today.getYear())){
      	 eval("c"+p+"_"+j+".bgColor=\"#EFFB64\"");
      }
      if (nd>sd_date_end || nd<sd_date_start)
      {
      eval("c"+p+"_"+j+".bgColor=\"#FF9999\"");
      eval("c"+p+"_"+j+".style.cursor=\"text\"");
      }
      nd=new Date(nd.valueOf() + 86400000)
    }
}

//s_object??????????????d_start-d_end??????????????????????????????????
//var sd_afterTime=" 00:00:00";
var sd_afterTime="";
function sd_showdate(eP,d_start,d_end,t_object)
{
	window.cele_date.style.display="";
	//window.cele_date.style.zIndex=99
	var s,cur_d
	var eT = eP.offsetTop;
	var eH = eP.offsetHeight+eT;
	var dH = window.cele_date.style.pixelHeight;
	var sT = document.body.scrollTop;
	var sL = document.body.scrollLeft;
	var oldTime=t_object.value;	
	var beforetime="";
	//alert(" 1: "+oldTime.length);
	if (oldTime.length>10){
	    sd_afterTime=oldTime.substring(10,oldTime.length);
	    beforetime=oldTime.substring(0,10);
	}
	event.cancelBubble=true;
	window.cele_date.style.posLeft = event.clientX-event.offsetX+sL-5;
	window.cele_date.style.posTop = event.clientY-event.offsetY+eH+sT;
	
	if (window.cele_date.style.posLeft+window.cele_date.clientWidth>document.body.clientWidth) {
   	 window.cele_date.style.posLeft+=eP.offsetWidth-window.cele_date.clientWidth;
   	 }
	//if (window.cele_date.style.posTop+window.cele_date.clientHeight>document.body.clientHeight) window.cele_date.style.posTop-=(eP.offsetHeight+window.cele_date.clientHeight+5);

	if (d_start!=""){ 
	    if (d_start=="today"){
	        sd_date_start=new Date(sd_today.getYear(),sd_today.getMonth(),sd_today.getDate());
	    }else{
	        s=d_start.split(sd_separator);
	        sd_date_start=new Date(s[0],s[1]-1,s[2]);
	    }
	}else{
	    sd_date_start=new Date(1900,1,1);
	}

	if (d_end!=""){
	    s=d_end.split(sd_separator);
	    sd_date_end=new Date(s[0],s[1]-1,s[2]);
	}else{
	    sd_date_end=new Date(3000,1,1);
	}

	sd_g_object=t_object;

	cur_d=new Date();
	
	if (beforetime.length>9){
	    s=beforetime.split(sd_separator);
	    cur_d=new Date(s[0],s[1]-1,s[2]);
	    
	}
	//sd_set_cele_date(cur_d.getYear()-18,cur_d.getMonth()+1);
	sd_set_cele_date(cur_d.getYear(),cur_d.getMonth()+1);
	
//	window.cele_date.style.display="block";
	window.cele_date.focus(); 
}
var selectDate="";
function sd_td_click(t_object){
 selectDate="";
	var t_d
	if (parseInt(t_object.innerHTML,10)>=1 && parseInt(t_object.innerHTML,10)<=31 )
	{
		t_d=new Date(cele_date_year.value,cele_date_month.value-1,t_object.innerHTML)
		if (t_d<=sd_date_end && t_d>=sd_date_start)
		{
			var year = cele_date_year.value;
			var month = cele_date_month.value;
			var day = t_object.innerHTML;
			if (parseInt(month)<10) month = "0" + month;
			if (parseInt(day)<10) day = "0" + day;            
			//sd_g_object.value=year+sd_separator+month+sd_separator+day+sd_afterTime;
			selectDate = year+sd_separator+month+sd_separator+day;
			document.getElementById("selectDateID").innerHTML = selectDate;
			//window.cele_date.style.display="none";
		};
	}
}

function selectDateTime(hourObj,minuteObj){
   
	 var hourValue = hourObj.options[hourObj.selectedIndex].text;
	 var minuteValue = minuteObj.options[minuteObj.selectedIndex].text;
	 sd_g_object.value="";
	 if(selectDate==""){
  	   var today =  new Date();
  	   var year = today.getYear();
  	   var month = today.getMonth()+1;
  	   var day = today.getDate();
  	   if (parseInt(month)<10) month = "0" + month;
	   if (parseInt(day)<10) day = "0" + day;  
	    selectDate =year+sd_separator+month+sd_separator+day;    
	   }
	 sd_g_object.value = selectDate+" "+hourValue+":"+minuteValue;
	 window.cele_date.style.display="none";
}
function clear_date() {
	sd_g_object.value="";
	selectDate="";
	document.getElementById("selectDateID").innerHTML = "";
	window.cele_date.style.display="none";
}
function sd_h_cele_date()
{
	window.cele_date.style.display="none";
}

function sd_overcolor(obj)
{
  if (obj.style.cursor=="hand"){
  	obj.style.backgroundColor = "red";
  	obj.style.color = "#FFFFFF";
  	sd_inover=true;
  	window.cele_date.focus();
  }
}

function sd_outcolor(obj)
{
  obj.style.color = "#000000";
  obj.style.backgroundColor = "";
  sd_inover=false;
}


function sd_getNow(o){
    var Stamp=new Date();
    var year = Stamp.getYear();
    var month = Stamp.getMonth()+1;
    var day = Stamp.getDate();
    if(month<10){
	month="0"+month;
    }
    if(day<10){
	day="0"+day;
    }
    o.value=year+sd_separator+month+sd_separator+day;
}
function sd_hilayer()
{
	if (sd_inover==false)
	{
		var lay=document.all.cele_date;
		lay.style.display="none";
	}
}
function sd_getlayerfocus()
{
	sd_inover=true;
}
function sd_lostlayerfocus()
{
	sd_inover=false;
}
// ??????????
function sd_body_init(){
	document.write("<div name=\"cele_date\" id=\"cele_date\"  style=\"display:none\"  width=\"240\"  style=\"POSITION: absolute;\" onClick=\"event.cancelBubble=true;\"  onMouseout=\"sd_lostlayerfocus()\"></div>");
	var enddate=new Date()
	sd_init(enddate.getYear()-10,enddate.getYear());

	//sd_init(1905,1998)
}

sd_body_init();
//-->