﻿        function TopStudentLogin(){
            var LoginName = jQuery("#txtTopLoginName").val();
            var Password = jQuery("#txtTopPassword").val();
            if(LoginName == ""){
                alert("请输入用户名");
                return;
            }
            else if(Password == ""){
                alert("请输入密码");
                return;
            }
            var data = {
                LoginName : LoginName,
                Password : Password,
                LoginTime : new Date().getMilliseconds()
            };
            jQuery.post(ApplicationPath + "common/ashx/Login_Submit.ashx", data, function(res){                
                if(res != ""){
                    if(res.indexOf("@@LoginSuccess") >= 0){                        
                        jQuery("#Login_Before").hide();
                        jQuery("#Login_After #Login_After_StudentName").html(res.split('|')[1])
                        jQuery("#Login_After").fadeIn();
                        return;
                    }
                    else{
                        alert(res);
                        return;
                    }
                }
            });
        }
        
        function CheckStudentLogin(){
            var data = {
                LoginTime : new Date().getMilliseconds()
            };
            jQuery.get(ApplicationPath + "common/ashx/Login_CheckLogin.ashx", data, function(res){
                if(res.indexOf("@@LoginAfter") >= 0){                        
                    jQuery("#Login_Before").hide();
                    jQuery("#Login_After #Login_After_StudentName").html(res.split('|')[1])
                    jQuery("#Login_After").show();
                    return;
                }
            });
        }
        CheckStudentLogin();//验证是否登录
        
        function StudentLogout(){
            if(!confirm("是否确认退出？")){
                return;
            }
            var data = {
                LoginTime : new Date().getMilliseconds()
            };
            jQuery.get(ApplicationPath + "common/ashx/Logout_Submit.ashx", data, function(res){
                if(res == "@@LogoutSuccess"){                        
                    jQuery("#Login_After").hide();
                    jQuery("#Login_Before").fadeIn();
                    event.returnValue=false; 
                    location.replace(ApplicationPath + "index.html");
                    return;
                }
                else{
                    alert(res);
                    return;
                }
            });
        }
        
        var linkLoginUrl = jQuery("#linkLogin").attr("href");
        var docUrl = document.URL;
        jQuery("#linkLogin").attr("href", linkLoginUrl + "?from=" + docUrl);
