﻿function doRegister() {
    window.open('/SignIn/Register.aspx');
}

function selectTag(showContent, selfObj) {
    // 标签
    var tag = document.getElementById("tags").getElementsByTagName("li");
    var taglength = tag.length;
    for (i = 0; i < taglength; i++) {
        tag[i].className = "";
    }
    selfObj.parentNode.className = "selectTag";
    // 标签内容
    for (i = 0; j = document.getElementById("tagContent" + i); i++) {
        j.style.display = "none";
    }
    document.getElementById(showContent).style.display = "block";
}

function SearchGetFouce() {
    if (document.getElementById("TxtSearch").value == "请输入关键词") {
        document.getElementById("TxtSearch").value = "";
    }
}

function doFindPwd() {
    window.open('/SignIn/StudentLogin.aspx');
}

function doQuit() {
    location.href = "SignIn/Quit.aspx";
}

function doUser() {
    window.open('/Student/index.aspx');
}

function createString() {
    var name = encodeURI($("#TxtName").val());
    var pwd = encodeURI($("#TxtPwd").val());
    var str = { name: name, pwd: pwd};
    return str;
}

function doRequest() {
    var cookieEnabled = (navigator.cookieEnabled) ? true : false;
    if (!cookieEnabled) {
        alert("请开启浏览器COOKIE功能！");
        return;
    }
    if ($("#TxtName").val() == "" || $("#TxtPwd").val() == "")
        window.open('/SignIn/StudentLogin.aspx');
    else {
        $.get("/SignIn/Login.aspx", createString(), function(data) {
            if (decodeURI(data) == "0") {
                $("#errorDIV").html("登陆失败！");
                $("#errorDIV").show();
            }
            else {
                $("#loginDIV").hide();
                $("#welcomeDIV").show();
                $("#lblName").html(decodeURI(data));
            }
       });
    }
}

$(document).ready(function() {
    $.get("/SignIn/CheckLogin.aspx", "",
         function(data) {
             if (decodeURI(data) != "NO") {
                 $("#loginDIV").hide();
                 $("#welcomeDIV").show();
                 $("#lblName").html(decodeURI(data));
             } else {
                 $("#welcomeDIV").hide();
                 $("#loginDIV").show();
             }
         });
     })

 function doSearch() {
     if (document.getElementById("TxtSearch").value.length <= 0)
         alert("请输入要搜索的关键词");
     else {
         window.open( "/SignIn/SearchPage.aspx?str=" + escape(document.getElementById("TxtSearch").value));
     }
 }
