$(function()
{
    var server_local_time = $('#server_local_time').val();
    var server_start_time = $('#server_start_time').val();

    nowTime = new Date();
    cur_sec = parseInt(nowTime.getTime() / 1000);
    delta_secs = server_local_time - cur_sec;

    d_secs = 24 * 60 * 60;
    h_secs = 60 * 60;
    m_secs = 60;

    function GetRTime()
    {
        nowTime = new Date();
        left_secs = server_start_time - (parseInt(nowTime.getTime() / 1000) + delta_secs);

        left_h = parseInt(left_secs / h_secs);
        left_m = parseInt((left_secs % h_secs) / m_secs);
        left_s = parseInt(left_secs % m_secs);

        //判断还有多少时间
        if(left_secs <= 0) {
            location.reload(true);
        }
//        判断是否为个位数
        function add_zero(time,id){
            if(time<10){
                document.getElementById(id).innerHTML ="0"+time;
            }
            else {
                document.getElementById(id).innerHTML =time;
            }
        }
        add_zero(left_h,"hour");
        add_zero(left_m,"min");
        add_zero(left_s,"second");
//      刷新浏览器
        if(left_s == "00"&&(left_m =="00"&& left_h == "00")){
            //直接刷新
            location.reload(true);
        }
    }
    setInterval(GetRTime,1000);
});
