//客户时区
var tmp_timezone = new Date().getTimezoneOffset()/60*-1;

function getWinHeight()
{
    var winHeight = 0;
    if (window.innerHeight)//for Firefox
    {
       winHeight = window.innerHeight;
    }
    else if((document.body) && (document.body.clientHeight))
    {
       winHeight = document.body.clientHeight;
    }
    //通过深入Document内部对body进行检测，获取窗口大小
    if (document.documentElement && document.documentElement.clientHeight)
    {
       //winHeight = document.documentElement.clientHeight;
    }
    return winHeight;
}

function stay_bottom() {
    var windowHeight    = getWinHeight();

    var infoHeight      = document.getElementById("whole").scrollHeight;

    var bottomHeight    = document.getElementById("copyright").scrollHeight;
    
    var contentHeight   = infoHeight + bottomHeight;
    
    var bottom          = document.getElementById("copyright");
    

    if(contentHeight < windowHeight){
        //alert(contentHeight + "小于" + windowHeight);
        bottom.style.position = "absolute";
        bottom.style.width = "100%";
        bottom.style.bottom = "5px";
        bottom.style.left = "0";
    }else{
        //alert(contentHeight + "大于等于" + windowHeight);
        bottom.style.position = "";
        bottom.style.bottom = "";
    }
    
    setTimeout(function(){stay_bottom();},2000);
}

function toLocalTime(serverTime) {
    var dateTimeObject = new Date(serverTime*1000);
    var tmp_hour    = dateTimeObject.getHours();
    var tmp_minute  = dateTimeObject.getMinutes();
    var tmp_second  = dateTimeObject.getSeconds();

    tmp_hour        = (tmp_hour.toString().length == 1 ? "0"+tmp_hour : tmp_hour);
    tmp_minute      = (tmp_minute.toString().length == 1 ? "0"+tmp_minute : tmp_minute);
    tmp_second      = (tmp_second.toString().length == 1 ? "0"+tmp_second : tmp_second);
    
    var tmp_local   = tmp_hour + ":" + tmp_minute + ":" + tmp_second;
    document.write(tmp_local);
}

//output current local date in the format of 00/00/0000
function outputLocalDate() {
    var tmp_date = new Date();
    var tmp_month= tmp_date.getMonth()+1;
    var tmp_day  = tmp_date.getDate();
    var tmp_year = tmp_date.getFullYear();
    
    tmp_month    = (tmp_month < 10 ? "0" + tmp_month.toString() : tmp_month);
    tmp_day      = (tmp_day < 10 ? "0" + tmp_day.toString() : tmp_day);
    tmp_year     = tmp_year;
    
    if(tmp_month == "01") {
        tmp_month = "Jan";
    }
    else if(tmp_month == "02") {
        tmp_month = "Feb";
    }
    else if(tmp_month == "03") {
        tmp_month = "Mar";
    }
    else if(tmp_month == "04") {
        tmp_month = "Apr";
    }
    else if(tmp_month == "05") {
        tmp_month = "May";
    }
    else if(tmp_month == "06") {
        tmp_month = "Jun";
    }
    else if(tmp_month == "07") {
        tmp_month = "Jul";
    }
    else if(tmp_month == "08") {
        tmp_month = "Aug";
    }
    else if(tmp_month == "09") {
        tmp_month = "Sep";
    }
    else if(tmp_month == "10") {
        tmp_month = "Oct";
    }
    else if(tmp_month == "11") {
        tmp_month = "Nov";
    }
    else if(tmp_month == "12") {
        tmp_month = "Dec";
    }
    document.write(tmp_day + " " + tmp_month);
}


//check email
function checkEmail(email) {
    //var regm = /^([a-zA-Z0-9_-]|\.)+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
    var regm = /^[a-zA-Z0-9]+([a-zA-Z0-9_-]|\.)+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
    //var regm = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2}$/;
    //验证Mail的正则表达式,^[a-zA-Z0-9_-]:开头必须为字母,下划线,数字,
    if (!email.match(regm))
    {
      return false;
    }
    else
    {
      return true;
    }
}

//register check
function checkRegister() {
    register_email = document.getElementById("input_email").value;
    if(checkEmail(register_email)) {
        return true;
    }
    else {
        alert("Your email adress is not correct !");
        document.getElementById("input_email").focus();
        document.getElementById("input_email").select();
        return false;
    }
}
