//日历 var date_start,date_end,g_object var today = new Date(); var separator="-"; var inover=false; //mode :时间变换的类型0-年 1-月 2-直接选择月 function 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_monthcele_date_month.options(cele_date_month.length-1).text){ cele_date_month.value=cele_date_month.options(0).text; change_date(parseInt(cele_date_year.value,10)+1,0); } else {cele_date_month.value=t_month; set_cele_date(cele_date_year.value,cele_date_month.value); } } } else{ t_year=parseInt(temp,10); if (t_yearparseInt(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; set_cele_date(cele_date_year.value,12); } else {cele_date_year.value=t_year; set_cele_date(cele_date_year.value,cele_date_month.value); } } } window.cele_date.focus(); } //初始化日历 function init(d_start,d_end) { var temp_str; var i=0 var j=0 date_start=new Date(2004,7,1) date_end=new Date(2009,8,1) document.writeln("
-
"); window.cele_date.innerHTML=""; temp_str=""; for (i=1 ;i<=6 ;i++) { temp_str+=""; for(j=1;j<=7;j++){ temp_str+="" } temp_str+="" } temp_str+="
"; temp_str+="-"; temp_str+="" temp_str+="-"; temp_str+="" temp_str+="-"; temp_str+="" temp_str+=">\" onclick=\"change_date(1,1)\" onmouseover=\"getlayerfocus()\" style=\"color: #000099; background-color: #BFBFBF; cursor: hand\">"; temp_str+="
" temp_str+="";temp_str+="一"; temp_str+="二"; temp_str+="三" temp_str+="四";temp_str+="五"; temp_str+="六
?
"; window.cele_date.innerHTML=temp_str; } function 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=\"#DDDDDD\""); 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()==today.getDate())&&(cele_date_month.value==today.getMonth()+1)&&(cele_date_year.value==today.getYear())){ eval("c"+p+"_"+j+".bgColor=\"#EFFB64\""); } if (nd>date_end || nddocument.body.clientWidth) window.cele_date.style.posLeft+=eP.offsetWidth-window.cele_date.clientWidth; if (d_start!=""){ if (d_start=="today"){ date_start=new Date(today.getYear(),today.getMonth(),today.getDate()); }else{ s=d_start.split(separator); date_start=new Date(s[0],s[1]-1,s[2]); } }else{ date_start=new Date(2004,1,1); } if (d_end!=""){ s=d_end.split(separator); date_end=new Date(s[0],s[1]-1,s[2]); }else{ date_end=new Date(2009,1,1); } g_object=t_object cur_d=new Date() set_cele_date(cur_d.getYear(),cur_d.getMonth()+1); window.cele_date.style.display="block"; window.cele_date.focus(); } function td_click(t_object) { 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<=date_end && t_d>=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; g_object.value=year+separator+month+separator+day; window.cele_date.style.display="none";}; } } function h_cele_date() { window.cele_date.style.display="none"; } function overcolor(obj) { if (obj.style.cursor=="hand") obj.style.color = "#FFFFFF"; inover=true; window.cele_date.focus(); } function outcolor(obj) { obj.style.color = "#000000"; inover=false; } function 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+separator+month+separator+day; } function hilayer() { if (inover==false) { var lay=document.all.cele_date; lay.style.display="none"; } } function getlayerfocus() { inover=true; } function lostlayerfocus() { inover=false; } init(); //日历结束