﻿// JScript 文件
var xmlHttp;
function Examcheck() {
    createXMLHTTP();
    var examtitle = document.getElementById("TextBox1").value;
    examtitle = encodeURIComponent(examtitle);
    if (examtitle == "") {
        document.getElementById("divcount").style.display = "none";
        document.getElementById("divcount").innerHTML = "";
        return;
    }    
    var url = "../AjaxCounts.aspx?ExamTitle=" + examtitle + "&type=" + Math.random(); 

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = count;
    xmlHttp.send(null);
}
function CheckIndexSearch() {
    var obj = document.getElementById("search_type");
    var title = document.getElementById("TextBox1").value;
    title = encodeURIComponent(title);
    if (obj.value == "0") {
        window.open("/Search.aspx?title=" + title);
    }
    if (obj.value == "1") {
        window.open("/SearchBook.aspx?title=" + title);
    }
    if (obj.value == "2") {
        window.open("/SearchArticle.aspx?title=" + title);
    }
}
function checkExamSearch() {
    var examtitle = document.getElementById("TextBox1").value;
    examtitle = encodeURIComponent(examtitle);
    
    window.location.href = "/Exam/Exam_Search.aspx?ExamTitle=" + examtitle;
}
function CheckPublish() {
    createXMLHTTP();
    var text = encodeURI(document.getElementById("txtPublishName").value);
    if (text == "") {
        document.getElementById("divcount").style.display = "none";
        document.getElementById("divcount").innerHTML = "";
        return;
    }
    
    var url = "../AjaxPublishName.aspx?cid=" + text + "&type=" + Math.random();

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = count;    
    xmlHttp.send(null);
}

function checkx() {
    createXMLHTTP();
    var text = document.getElementById("ctl00$TextBox1").value;
    if (text == "") {
        document.getElementById("divcount").style.display = "none";
        document.getElementById("divcount").innerHTML = "";
        return;
    }
    var url = "AjaxCounts.aspx?cid=" + text + "&type=" + Math.random();
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = countx;
    xmlHttp.send(null);
}
function checky() {
    createXMLHTTP();
    var text = document.getElementById("textsou").value;
    if (text == "") {
        document.getElementById("divcount").style.display = "none";
        document.getElementById("divcount").innerHTML = "";
        return;
    }
    var url = "../AjaxCounts.aspx?cid=" + text + "&type=" + Math.random();
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = countx;
    xmlHttp.send(null);
}
function createXMLHTTP() {
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest(); //mozilla浏览器
    }
    else if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        { }
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        { }
        if (!xmlHttp) {
            window.alert("不能创建XMLHttpRequest对象实例！");
            return false;
        }
    }
}
function count() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            if (xmlHttp.responseText != "") {
                if (screen.width == 1400) {
                    document.getElementById("divcount").style.left = "490";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1360) {
                    document.getElementById("divcount").style.left = "470";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1280) {
                    document.getElementById("divcount").style.left = "430";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1024) {
                    document.getElementById("divcount").style.left = "304";
                    document.getElementById("divcount").style.display = "block";                    
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                   
                }
                if (screen.width == 1152) {
                    document.getElementById("divcount").style.left = "366";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
            }
            else {
                document.getElementById("divcount").style.display = "none";
                document.getElementById("divcount").innerHTML = "";
            }
        }
    }
}
function countx() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            if (xmlHttp.responseText != "") {
                if (screen.width == 1400) {
                    document.getElementById("divcount").style.left = "490";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1360) {
                    document.getElementById("divcount").style.left = "470";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1280) {
                    document.getElementById("divcount").style.left = "430";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1024) {
                    document.getElementById("divcount").style.left = "304";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
                if (screen.width == 1152) {
                    document.getElementById("divcount").style.left = "366";
                    document.getElementById("divcount").style.display = "block";
                    document.getElementById("divcount").innerHTML = xmlHttp.responseText;
                }
            }
            else {
                document.getElementById("divcount").style.display = "none";
                document.getElementById("divcount").innerHTML = "";
            }
        }
    }
}
function mousemove(id) {
    document.getElementById(id).style.backgroundColor = "#0478B3";
}
function mouseout(id) {
    document.getElementById(id).style.backgroundColor = "#FFFFFF";
}
function closediv() {
    document.getElementById("divcount").style.display = 'none';
}


function login(name, pass) {
    createXMLHTTP();
    var url = "/AjaxIndex.aspx?flag=login&name=" + name + "&pass=" + pass;
   
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = CheckLogin;
    xmlHttp.send(null);
}
function loginIndex(name, pass) {
    createXMLHTTP();
    var url = "/AjaxIndex.aspx?flag=login&name=" + name + "&pass=" + pass;
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = CheckIndexLogin;
    xmlHttp.send(null);
}
function CheckIndexLogin() {
    if (xmlHttp.readyState == 4)//判断对象状态
    {
        if (xmlHttp.status == 200) {
            var ss = xmlHttp.responseText;
            if (ss == "no") {
                document.getElementById("LoginControl1_TextBox2").value = "";
                alert("登陆失败◎请重新登陆◎！");
            }
            else {
                var res = ss.split("#");
                document.getElementById("divlogin").style.display = "none";
                document.getElementById("divlogined").style.display = "block";
                document.getElementById("divlogined").innerHTML = res[2]+"<span class=\"blue\">欢迎登录！</span> <a href=\"/MemberCenter/\" target=\"_blank\">[会员中心]</a> | <a href=\"#\" title=\"安全退出\" onclick=\"return ExitLogin();\">[安全退出]</a>";
                //alert(document.getElementById("divlogined").innerHTML);
            }
        }
    }
}
function CheckLogin() {
    if (xmlHttp.readyState == 4)//判断对象状态
    {
        if (xmlHttp.status == 200) {
            var ss = xmlHttp.responseText;
            if (ss == "no") {
                document.getElementById("LoginControl1_TextBox2").value = "";
                alert("登陆失败◎请重新登陆◎！");
            }
            else {
                var res = ss.split("#");
                document.getElementById("divlogin").style.display = "none";
                document.getElementById("divlogined").style.display = "block";
                document.getElementById("divlogined").innerHTML = res[1] + "&nbsp;<input type=\"button\" onclick=\"return ExitLogin();\" value=\"退出登陆\" class=\"memberbut\" />&nbsp;"
                + " <input type=\"button\" value=\"赠卡充值\" onclick =\"javascript:window.open('/help/cardprocess.html','_blank','')\"  class=\"memberbut\" tabindex=\"3\" />";
            }
        }
    }
}

function removeSesson() {
    createXMLHTTP();
    var url = "/AjaxIndex.aspx?flag=exit";
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = ResultremoveSesson;
    xmlHttp.send(null);
}
function ResultremoveSesson() {
    if (xmlHttp.readyState == 4)//判断对象状态
    {
        if (xmlHttp.status == 200) {
            var ss = xmlHttp.responseText;
            if (ss == "ok") {
                alert("已安全成功退出!");
            }

            document.getElementById("divlogin").style.display = "block";
            document.getElementById("divlogined").style.display = "none";

        }
    }
}

