﻿NewsDataList.doClick = function(index, id)
{
    window.open("credit_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_wjtz.doClick = function(index, id)
{
    window.open("wjtz_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_zcfg.doClick = function(index, id)
{
    window.open("policy_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_xqfc.doClick = function(index, id)
{
    window.open("credit_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_cxlt.doClick = function(index, id)
{
    window.open("forum_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_zxpx.doClick = function(index, id)
{
    window.open("Learnkey_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_ggtz.doClick = function(index, id)
{
    window.open("wjtz_type.aspx?newsID=" + id, "_blank");
};
NewsDataList_qyxy.doClick = function(index, id)
{
    window.open("business_type.aspx?newsID=" + id, "_blank");
};

//重写DataList双击事件
NewMemList.doClick = function(index, id)
{
    window.open("MemberInfo.aspx?memID=" + id, "_blank");
};


//更新验证码显示
function changeVCode()
{
    $("VcImg").src = "../VerifyCode.aspx?" + loginTimes;
    loginTimes++;
    $("U_Vc").value = "";
}

//免费注册新会员
function registerNewMenber()
{
    loginTimes++;
    window.location = "Register.aspx";
}

//会员登录
function userLogin()
{
    var uName = $("U_Code").value.trim();
    if (uName == null || uName == "")
    {
        alert("请输入会员名。");
        $("U_Code").select();
        return;
    }
    var uPsw = $("U_Psw").value.trim();
    if (uPsw == null || uPsw == "")
    {
        alert("请输入密码。");
        $("U_Psw").select();
        return;
    }
    var vc = $("U_Vc").value.trim();
    if (vc == null || vc == "")
    {
        alert("请输入验证码。");
        $("U_Vc").select();
        return;
    }
    var res = Vxun.BL.USR.Member.MemberLogin(uName, uPsw, vc);
    if (res.error != null)
    {
        alert(res.error.Message);
        $("U_Psw").value = "";
        changeVCode();
        return;
    }
    if (!res.value)
    {
        alert("登录失败，请尝试刷新页面后重新登录。");
        return;
    }
    window.location = "MemberCenter.aspx";
}

//找回密码
function lostPassword()
{
    loginTimes++;
    window.location = "ResetPassword.aspx";
}

var loginTimes = 0;


function setValA(id)
{
    valA = id;
}

function setValB(id)
{
    valB = id;
}

function vote()
{
    if (valA == null)
    {
        alert("请选择企业信用管理和相关技术应用的投票选项。");
        return;
    }
    if (valB == null)
    {
        alert("请选择企业信用状况的投票选项。");
        return;
    }

    var res = Vxun.BL.SYS.Vote.UpdateVoteForIndex(valA, valB);
    if (res.error != null)
    {
        alert(res.error.Message);
        return;
    }
    browsVote();
}

function browsVote()
{
    openNewDiv('newDiv');
    return false;
}

function openNewDiv(_id)
{
    var m = "mask";
    if (docEle(_id)) document.body.removeChild(docEle(_id));
    if (docEle(m)) document.body.removeChild(docEle(m));

    //mask遮罩层

    var newMask = document.createElement("div");
    newMask.id = m;
    newMask.style.position ="fixed";
    newMask.style.zIndex = "1";
    _scrollWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
    _scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
    newMask.style.width = "100%";
    newMask.style.height = "100%";
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.right = "0px";
    newMask.style.bottom = "0px";
    newMask.style.background = "#33393C";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";    
    document.body.appendChild(newMask);

    //新弹出层

    var newDiv = document.createElement("div");
    newDiv.id = _id;
    newDiv.style.position = "fixed";
    newDiv.style.zIndex = "9999";
    newDivWidth = 400;
    newDivHeight = 320;
    newDiv.style.width = newDivWidth + "px";
    newDiv.style.height = newDivHeight + "px";
    newDiv.style.bottom = "100px";
    newDiv.style.left = "260px";
    newDiv.style.display = "block";
    newDiv.style.background = "#ffffff";
    newDiv.style.border = "1px solid #6B97C1";
    newDiv.style.padding = "20px";

    var res = Vxun.BL.SYS.Vote.GetVoteHtml();
    if (res.error != null)
    {
        alert(res.error.Message);
        return;
    }
    
    newDiv.innerHTML = res.value;
    document.body.appendChild(newDiv);

    //弹出层滚动居中

    function newDivCenter()
    {
//        newDiv.style.top = (document.body.scrollTop + document.body.clientHeight / 2 + newDivHeight/2) + "px";
//        newDiv.style.left = (document.body.scrollLeft + document.body.clientWidth / 2 - newDivWidth/2) + "px";
    }
    if (document.all)
    {
        window.attachEvent("onscroll", newDivCenter);
    }
    else
    {
        window.addEventListener('scroll', newDivCenter, false);
    }

    //关闭新图层和mask遮罩层

    var newA = document.createElement("a");
    newA.href = "#";
    newA.innerHTML = "关闭";
    newA.onclick = function()
    {
        if (document.all)
        {
            window.detachEvent("onscroll", newDivCenter);
        }
        else
        {
            window.removeEventListener('scroll', newDivCenter, false);
        }
        document.body.removeChild(docEle(_id));
        document.body.removeChild(docEle(m));
        return false;
    }
    newDiv.appendChild(newA);
}

var docEle = function()
{
    return document.getElementById(arguments[0]) || false;
}

var valA = null;
var valB = null;
