﻿// JScript 文件
var CurrPersonageTab = 0;
var CurrColumnTab = 0;
var CurrBookPro=0;
function ChangeTab(CheckTab, UnCheckTab, UnCheckClassName)
{
    document.getElementById(CheckTab).className="rib2 l";
    document.getElementById(UnCheckTab).className=UnCheckClassName;
    document.getElementById(CheckTab+"_Info").style.display="block";
    document.getElementById(UnCheckTab+"_Info").style.display="none";
    document.getElementById(CheckTab+"_More").style.display="block";
    document.getElementById(UnCheckTab+"_More").style.display="none";
}


function ChangeTab1(CheckTab, UnCheckTab, UnCheckClassName)
{
    document.getElementById(CheckTab).className="midbbs2 l";
    document.getElementById(UnCheckTab).className=UnCheckClassName;
    document.getElementById(CheckTab+"_Info").style.display="block";
    document.getElementById(UnCheckTab+"_Info").style.display="none";
}

function ChangePersonageTab(CheckTab, CheckIndex)
{
    document.getElementById(CheckTab+CurrPersonageTab).style.display="none";
    document.getElementById(CheckTab+CheckIndex).style.display="block";
    CurrPersonageTab=CheckIndex;
}

function ChangeColumnTab(CheckTab, CheckIndex)
{
    document.getElementById(CheckTab+CurrColumnTab).style.display="none";
    document.getElementById(CheckTab+CheckIndex).style.display="block";
    CurrColumnTab=CheckIndex;
}

function ChangeBookProTab(CheckTab, CheckIndex, obj)
{
    document.getElementById("divBookProCategory" + CurrBookPro).className="tb2b t r ";
    document.getElementById("divBookProCategory" + CheckIndex).className="tb2a t r ";
    document.getElementById(CheckTab+CurrBookPro).style.display="none";
    document.getElementById(CheckTab+CheckIndex).style.display="block";
    CurrBookPro=CheckIndex;
}


function GetNewsRightCallBack()
{
    if(ajax.IsReady() == true)
    {
        document.getElementById("divNewsRight").innerHTML = ajax.ResponseText();
    }
}

function GetNewsRight()
{
    var strUrl = "http://" + window.location.host + "/NewsRight.aspx?r=" + Math.random();
    ajax.Get(strUrl, GetNewsRightCallBack)
}

function GetVideoComment(id)
{
    var strUrl = "http://" + window.location.host + "/VideoComment.aspx?id=" + id + "&r=" + Math.random();
    ajax.Get(strUrl, GetVideoCommentCallBack)
}

function GetVideoCommentCallBack()
{
    if(ajax.IsReady() == true)
    {
        document.getElementById("divVideoComment").innerHTML = ajax.ResponseText();
    }
}

function GetNewsBottom(id)
{
    var strUrl = "http://" + window.location.host + "/NewsBottom.aspx?id=" + id + "&r=" + Math.random();
    ajax.Get(strUrl, GetNewsBottomCallBack)
}

function GetNewsBottomCallBack()
{
    if(ajax.IsReady() == true)
    {
        document.getElementById("divNewsBottom").innerHTML = ajax.ResponseText();
        GetNewsRight();
    }
}

function GetNewsBottom1(id)
{
    var strUrl = "http://" + window.location.host + "/NewsBottom.aspx?id=" + id + "&r=" + Math.random();
    ajax.Get(strUrl, GetNewsBottomCallBack1)
}

function GetNewsBottomCallBack1()
{
    if(ajax.IsReady() == true)
    {
        document.getElementById("divNewsBottom").innerHTML = ajax.ResponseText();
    }
}

function GetPageCommon(id, page)
{
    var strUrl = "http://" + window.location.host + "/NewsBottom.aspx?id=" + id + "&page=" + page + "&r=" + Math.random();
    ajax.Get(strUrl, GetPageCommonCallBack)
}

function GetPageCommonCallBack()
{
    if(ajax.IsReady() == true)
    {
        document.getElementById("divNewsBottom").innerHTML = ajax.ResponseText();
    }
}

function GetSubmitComment(id)
{
    var strValidateCode = document.getElementById("txtValidateCode").value;
    if(strValidateCode == "")
    {
        alert("请输入验证码！");
        return;
    }
    var strContent = document.getElementById("txtContent").value;
    if(strContent == "")
    {
        alert("请输入内容！");
        return;
    }
    var strNickName = document.getElementById("txtNickName").value;
    var strIsAnonymity = document.getElementById("chkIsAnonymity").value;
    
    var data="strValidateCode=" + strValidateCode + "&strContent=" + strContent + "&strNickName=" + strNickName + "&strIsAnonymity=" + strIsAnonymity + "&strID=" + id;
    
    var strUrl = "http://" + window.location.host + "/SubmitComment.aspx?id=" + id + "&r=" + Math.random();
    ajax.Post(strUrl, data, GetSubmitCommentCallBack)
}

function GetSubmitCommentCallBack()
{
    if(ajax.IsReady() == true)
    {
        var returnValue = ajax.ResponseText();
        if(returnValue=="1")
        {
            alert("谢谢您的评论！");
            var strID = document.getElementById("hidID").value;
            GetNewsBottom1(strID);
        }
        else if(returnValue == "2")
        {
            alert("验证码不正确或已过期！");
            document.getElementById("imgVerify").src="/ValidateCode.aspx?r=" + Math.random();
        }
        else
        {
            alert(returnValue);
        }
    }
}

function GetVideoSubmitComment(id)
{
    var strValidateCode = document.getElementById("txtValidateCode").value;
    if(strValidateCode == "")
    {
        alert("请输入验证码！");
        return;
    }
    var strContent = document.getElementById("txtContent").value;
    if(strContent == "")
    {
        alert("请输入内容！");
        return;
    }
    var strNickName = document.getElementById("txtNickName").value;
    var strIsAnonymity = document.getElementById("chkIsAnonymity").value;
    
    var data="strValidateCode=" + strValidateCode + "&strContent=" + strContent + "&strNickName=" + strNickName + "&strIsAnonymity=" + strIsAnonymity + "&strID=" + id;
    
    var strUrl = "http://" + window.location.host + "/SubmitComment.aspx?id=" + id + "&r=" + Math.random();
    ajax.Post(strUrl, data, GetVideoSubmitCommentCallBack)
}

function GetVideoSubmitCommentCallBack()
{
    if(ajax.IsReady() == true)
    {
        var returnValue = ajax.ResponseText();
        if(returnValue=="1")
        {
            alert("谢谢您的评论！");
            var strID = document.getElementById("hidID").value;
            GetVideoComment(strID);
        }
        else if(returnValue == "2")
        {
            alert("验证码不正确或已过期！");
            document.getElementById("imgVerify").src="/ValidateCode.aspx?r=" + Math.random();
        }
        else
        {
            alert(returnValue);
        }
    }
}