﻿//======================================================================
//
//        Copyright (C) 苏州逸仙软件    
//        All rights reserved
//
//        filename :$safeitemrootname$
//        description :
//
//        created by 周济 at  $time$
//        mail:13912699233@139.com
//
//======================================================================
/*
主框架顶部脚本开始  zhouji add 091216 13912699233@139.com
*/

//验证码参数,用来刷新验证码,没有实际的意义,但是必须
var yzmP = 0;

$(function() {
    //刷新验证码
    $("#yxmImgID").click(function() {
        this.src = M_RootPath + "User/Img.ashx?sname=session_log&yixian=" + (yzmP++);
    });
    $("#yxmImgID").hide();
    $("#TopYZM").focus(function() {
        $("#yxmImgID").show();

    });
    //登录处理
    $("#loginBut").click(function() {
        //资料获取
        var yh = $.trim($("#TopUserName").val());
        var mm = $.trim($("#TopPassWord").val());
        var yz = $.trim($("#TopYZM").val());
        //输入判断
        if (yh == "") {
            $.yixianMsg("请输入用户名");
            return false;
        }
        if (mm == "") {
            $.yixianMsg("请输入密码");
            return false;
        }
        //        if (yz == "") {
        //            $.yixianMsg("请输入验证码");
        //            return false;
        //        }
        //获取验证码资料
        $.getJSON(M_RootPath + "User/loginfunction.ashx?sname=session_log&stype=1", function(json) {
            //            if (yz != $.trim(json.Msg)) {
            //                $.yixianMsg("验证码不正确");
            //                return false;
            //            } else {
            //登录处理
            $.getJSON(M_RootPath + "User/loginfunction.ashx?stype=2&username=" + encodeURI(yh) + "&password=" + encodeURI(mm) + "&usertype=0", function(json) {
                var ref = (json.Msg);
                if (ref == "0") {
                    //登录成功处理
                    var f = $("#LoginForm");
                    f.html("");
                    f.html("<img src=\"" + M_RootPath + "PUBLIC/images/ico_user.gif\" />" + yh + ",欢迎您!   <label>|</label><label><a href=\"" + M_RootPath + "User/UserAdmin/PersonalInfo.aspx\">个人管理中心</a></label><label>|</label><label><a href=\"" + M_RootPath + "User/Exit.aspx\">注销</a></label>");
                } else {
                    if (ref == "1") {
                        $.yixianMsg("可能如下原因不能登陆\n 1.该用户没注册。\n 2.用户名或密码不正确\n 3.该用户没有激活");
                    } else {
                        $.yixianMsg("可能如下原因不能登陆\n 1.该用户没注册。\n 2.用户名或密码不正确\n 3.该用户没有激活");
                    }
                    location.href = M_RootPath + "User/login.aspx";
                }
            }); //登录处理结束
            //            }
        }); //验证码获取结束



    }); //整体登录处理结束

});        //$end




function setHomepage() {
    if (document.all) {
        document.body.style.behavior = "url(#default#homepage)";
        document.body.setHomePage("http://www.ksyx.net");

    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                $.yixianMsg("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
            }
        }
        var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.ksyx.net/');
    }
}

function addFavorite() {
    if (document.all) {
        window.external.addFavorite("http://www.ksyx.net/", "昆山逸仙教育");
    }
    else if (window.sidebar) {
        window.sidebar.addPanel("昆山逸仙教育", "http://www.ksyx.net/", "");
    } else {
        $.yixianMsg("您的浏览器不支持此操作");
    }
}