//startTime由stat.cgi传输到网页

//时钟
var ctimer;
time= new Date(startTime-1000);
secpre=time.getSeconds();

function init(){
//if (document.all){
//tim2.style.left=tim1.style.posLeft;
//tim2.style.top=tim1.style.posTop+tim1.offsetHeight-6;
settimes();
//}
}

function settimes(){
var time = new Date(startTime);
secs=time.getSeconds();
if(secpre != secs){secpre=secs;startTime += 1000;}
hours=time.getHours();
mins=time.getMinutes();
if(mins<10) mins="0"+mins;
if(secs<10) secs="0"+secs;
timeString=hours+":"+mins+":"+secs;
//tim1.innerHTML=timeString;
//tim2.innerHTML=timeString;
//timetable.innerHTML=timeString;//2003-3-31 11:51
altercontent();
ctimer=setTimeout('settimes()',960);
}

//适应新层技术的2003-3-31 11:51
function altercontent(){
//if IE 4+
if (document.all)
timetable.innerHTML=timeString;
//else if NS 4
else if (document.layers){
document.ns4timetable.document.ns4timetable.
document.write(timeString);
document.ns4timetable.document.ns4timetable2.
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("timetable");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(timeString);
while (el.hasChildNodes())
el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}

//日历
var calendarString="";

colors = new Array(8);
colors[0]="#edeef1";
colors[1]="#d6dae4";
colors[2]="#bec5d6";
colors[3]="#9ba5bf";
colors[4]="#bec5d6";
colors[5]="#d6dae4";
colors[6]="#edeef1";
colors[7]="#fdfdfd";

monthdays = new Array(12);
monthdays[0]=31;
monthdays[1]=28;
monthdays[2]=31;
monthdays[3]=30;
monthdays[4]=31;
monthdays[5]=30;
monthdays[6]=31;
monthdays[7]=31;
monthdays[8]=30;
monthdays[9]=31;
monthdays[10]=30;
monthdays[11]=31;

//var linkcount=0;
//function addlink(month,day,href){
//var entry = new Array(3);
//entry[0] = month;
//entry[1] = day;
//entry[2] = href;
//this[linkcount++]=entry;
//}
//Array.prototype.addlink = addlink;
//linkdays = new Array();

time = new Date(startTime);
thisday = time.getDay();
thisdate = time.getDate();
thismonth = time.getMonth();
thisyear = time.getFullYear();//getYear();
if(thisyear<100) thisyear+=1900;
//thisyear=thisyear % 100;
//thisyear=(thisyear<50)?(2000+thisyear):(1900+thisyear);

var dataString=thismonth+1;
dataString=thisyear+"年"+dataString+"月"+thisdate+"日"; //公历日期

if((thisyear % 4 == 0 && thisyear % 100 != 0)||thisyear % 400 == 0) monthdays[1]++;
startspaces=thisdate;
while(startspaces>7) startspaces-=7;
startspaces = thisday - startspaces + 1;
if(startspaces<0) startspaces+=7;

calendarString = "<table align=center border=0 cellpadding=2 cellspacing=0 style=\"font-size:9pt;line-height:9pt;\">";
var colorNo=0;
weekday=new Array(7);
weekday[0]="日";
weekday[1]="一";
weekday[2]="二";
weekday[3]="三";
weekday[4]="四";
weekday[5]="五";
weekday[6]="六";
calendarString += "<tr>";
for(s=0;s<7;s++){
calendarString += "<td align=center bgcolor=" + colors[colorNo++] + ">" + weekday[s] +"</td>";
}
calendarString += "</tr><tr>";

for(s=0;s<startspaces;s++){
if(colorNo>7){colorNo=0;}
calendarString += "<td bgcolor=" + colors[colorNo++] + ">&nbsp</td>";
}

count=1;
while(count<=monthdays[thismonth]){
for(b=startspaces;b<7;b++){
if(colorNo>7){colorNo=0;}
calendarString += "<td align=center bgcolor=" + colors[colorNo++] + ">";
//linktrue=false;
//for(c=0;c<linkdays.length;c++){
//if(linkdays[c] != null){
//if((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)){
//calendarString += "<a href=" + linkdays[c][2] + ">";
//linktrue=true;
//}
//}
//}
if(count==thisdate){
calendarString += "<font color=FFFF00>"+count+"</font>";
}
else{
if(count<=monthdays[thismonth]){
//if(count<10){calendarString += "&nbsp";}
calendarString += count;
}
else{calendarString += "&nbsp";}
}
//if(linktrue) calendarString += "</a>";
calendarString += "</td>";
count++;
}
//calendarString += "";
if(count<=monthdays[thismonth]){calendarString += "</tr><tr>";}
startspaces=0;
}
calendarString += "</table>";

