﻿
$("#btnIndexLogin").click(function() {
    var indexusername = $("#txtIndexUsername").val();
    var indexpassword = $("#txtIndexPassword").val();
    if (indexusername == "") { alert("请输入用户名"); return; }
    if (indexpassword == "") { alert("请输入密码"); return; }

    var data = { username: indexusername, password: indexpassword };
    $.post("http://www.169gold.com/cn/IndexLogin.ashx", data, function(result) {
        if (result == "none") { alert("用户名不存在"); return; }
        if (result == "uncheck") { alert("用户名未通过审核"); return; }
        if (result == "error") { alert("密码错误"); return; }
        if (result == "success") { alert("登录成功"); location.reload(); return; }
        if (result == "" || result == null) { alert("登录失败,请重试"); return; }
    })
})

$(function(){
    checkuserlogin();
})

function checkuserlogin()
{
    $.get("http://www.169gold.com/cn/CheckUserLogin.ashx?dt="+new Date(), function(result) {
        
        if (result == "unlogin")
            return;
        $(".Top_LO").html("&nbsp;&nbsp;&nbsp;&nbsp;欢迎您，" + result + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='../cn/Member.aspx'>会员中心</a>&nbsp;&nbsp;&nbsp;<a onclick='indexlogout();' href='#'>退出登录</a>");
        
    })
}
function indexlogout()
{
    if(!confirm("确认退出?"))
        return;
    $.get("http://www.169gold.com/cn/Logout.ashx",function(result){
        if(result=="logout")
        {
            alert("退出成功");
            location.reload();
        }
    })
}

function checkmcl(indexvarpid,indexvarmtype)
{
    if (indexvarpid != "" && indexvarmtype != "") 
    {
        var data = { varpid: indexvarpid, varmtype: indexvarmtype };
        $.post("http://www.169gold.com/cn/CheckUserType.ashx",data, function(result) {
            if (result == "unlogin")
                { 
                    if(!confirm("注册成为黄金台会员方可查看,是否现在注册？点取消立即登录")){location.href="../cn/login.aspx";return;}
                    else{location.href="http://www.169gold.com/cn/Member_reg.aspx";return;}
                }
            if (result == "unutype")
                { alert("会员权限不够,无法查看！升级您的会员服务！");location.href="../cn/Member_NewsInfo.aspx?id=5"; return; }
            location.href="http://www.169gold.com/cn/Member_NewsInfo.aspx?id="+indexvarpid;
        })
    }
}

$("#btnSearch").click(function(){
    var keyword = $("#txtKeyword").val();
    if(keyword=="")
    {
        alert("请输入关键字");
        return;
    }
    keyword = escape(keyword);
    location.href="http://www.169gold.com/cn/search.aspx?keyword="+keyword;
})


function GetTimeFromTimeZone(timeZone)
{
    var lDate = new Date();
    var localTime = lDate .getTime();
    var localOffset = lDate .getTimezoneOffset() * 60000; //本地和0时区的偏移
    var utc = localTime + localOffset; //得到0时区时间
    var placeTime= utc + (3600000*timeZone); //当地时间
    //alert("本地时间： " +lDate .toLocaleString()+"<br/>UTC时间： "+ new Date(utc).toLocaleString());    
    return new Date(placeTime);
}

function GetDateTimes()
{
    var localDate = new Date();
    $("#localDate").html(localDate.getFullYear()+"年"+Number(localDate.getMonth()+1)+"月"+localDate.getDate()+"日");
    
    var BeijingTime = GetTimeFromTimeZone(8);
    var BeijingHour = BeijingTime.getHours()<10 ? "0"+BeijingTime.getHours() : BeijingTime.getHours();
    var BeijingMinu = BeijingTime.getMinutes()<10 ? "0"+BeijingTime.getMinutes() : BeijingTime.getMinutes();
    $("#BeijingTime").html("北京&nbsp;" + BeijingHour +":"+BeijingMinu);
    
    var LondonTime = GetTimeFromTimeZone(0);
    var LondonHour = LondonTime.getHours()<10 ? "0"+LondonTime.getHours() : LondonTime.getHours();
    var LondonMinu = LondonTime.getMinutes()<10 ? "0"+LondonTime.getMinutes() : LondonTime.getMinutes();
    $("#LondonTime").html("伦敦&nbsp;" + LondonHour +":" +  LondonMinu);
    
    var NewyorkTime = GetTimeFromTimeZone(-5);
    var NewyorkHour = NewyorkTime.getHours()<10 ? "0"+NewyorkTime.getHours() : NewyorkTime.getHours();
    var NewyorkMinu = NewyorkTime.getMinutes()<10 ? "0"+NewyorkTime.getMinutes() : NewyorkTime.getMinutes();
    $("#NewyorkTime").html("纽约&nbsp;" + NewyorkHour + ":" + NewyorkMinu);
    
    var ChicagoTime = GetTimeFromTimeZone(-8);
    var ChicagoHour = ChicagoTime.getHours()<10 ? "0"+ChicagoTime.getHours() : ChicagoTime.getHours();
    var ChicagoMinu = ChicagoTime.getMinutes()<10 ? "0"+ChicagoTime.getMinutes() : ChicagoTime.getMinutes();
    $("#ChicagoTime").html("芝加哥&nbsp;" + ChicagoHour + " : "+ ChicagoMinu);
    
}

$(function(){
    GetDateTimes();
})


$("#txtIndexUsername").keypress(function(e){
    if(!e) e = window.event;//火狐中是 window.event
    if((e.keyCode || e.which) == 13){
        $("#btnIndexLogin").click();
    }
})
$("#txtIndexPassword").keypress(function(e){
    if(!e) e = window.event;//火狐中是 window.event
    if((e.keyCode || e.which) == 13){
        $("#btnIndexLogin").click();
    }
})
$("#txtKeyword").keypress(function(e){
    if(!e) e = window.event;//火狐中是 window.event
    if((e.keyCode || e.which) == 13){
        $("#btnSearch").click();
    }
})


//走势图会总页
function bindzsimg(spid){
    $("span[id^='"+spid+"']").bind("mouseover", function() {
        $("span[id^='"+spid+"']").attr("class", "");
        $(this).attr("class", "hover");
        $("img[id^='con_"+spid+"_']").attr("class", "none");
        $("#" + $(this).attr("id").replace(spid, "con_"+spid+"_")).attr("class", "");
    })
}

