﻿var iN;
var serverH;
var serverM;
var serverS;

function ShowTimeNow()
{
    iN = parseFloat(iN) + 1;
    servertime = parseFloat(serverH * 3600) + parseFloat(serverM * 60) + parseFloat(serverS);
    nowtime = parseFloat(servertime) + parseFloat(iN);
    
    hours = Math.floor(nowtime / 3600);
    mins = Math.floor((nowtime - hours * 3600) / 60); 
    secs = Math.floor(nowtime - hours * 3600 - mins * 60); 
    timeVal = "beijing time : ";
    
    timeVal += ((hours<10)? "0":"") + hours;
    timeVal += ((mins<10)? ":0":":") + mins;
    timeVal += ((secs<10)? ":0":":") + secs;
    //timeVal += ((hours<12)? "AM":"PM");
    document.getElementById("span_Clock").innerHTML = timeVal;
    timerID = setTimeout("ShowTimeNow()",1000);
}

function StartShowTime()
{
    serverH = document.getElementById("serverHour").value; 
    serverM = document.getElementById("serverMinute").value; 
    serverS = document.getElementById("serverSecond").value; 
    //alert(serverH + ":" + serverM + ":" + serverS);
    
    iN = 0;
    ShowTimeNow();
}


//function ShowTimeNow()
//{
//    var now = new Date();
//    var hours = now.getHours();
//    var mins = now.getMinutes();
//    var secs = now.getSeconds();
//    var timeVal = "beijing time : ";
//    
//    timeVal += ((hours<10)? "0":"") + hours;
//    timeVal += ((mins<10)? ":0":":") + mins;
//    timeVal += ((secs<10)? ":0":":") + secs;
//    //timeVal += ((hours<12)? "AM":"PM");
//    document.getElementById("span_Clock").innerHTML = timeVal;
//    timerID = setTimeout("ShowTimeNow()",1000);
//}

