﻿
$.post("/globe/", { action: 7, rd: Math.random() }, function(res) {
    if (res != 0) {
        var html = "";
        html += "<tr>";
        html += "<td><span class=\"F12\">您好！欢迎回来<a href=\"http://i.23544.com/user/\">" + res.split("|")[2] + "</a><a href='http://i.23544.com'>[进入会员中心]</a><a  href='http://www.23544.com/LogOut.aspx' class=\"F12\">安全退出</a></td>";
        html += "</tr>";
        $("#t_login_div").html(html);
    }
})
function UserLogin_Dex() {
    var fusername = $("#fusername").val();
    var fpassword = $("#fpassword").val();
    var isread = 1;
    $.post("/globe/", { action: 3, rd: Math.random(), username: fusername, password: fpassword, isread: isread }, function(res) {
        if (res != "0") {
            var html = "";
            html += "<tr>";
            html += "<td><span class=\"F12\">您好！欢迎回来<a href=\"http://i.23544.com/user/\">" + res.split("|")[0] + ",欢迎回来!</a><a href='http://i.23544.com'>[进入会员中心]</a><a  href='http://www.23544.com/LogOut.aspx' class=\"F12\">安全退出</a></td>";
            html += "</tr>";
            $("#t_login_div").html(html);

            html = "";
            if (document.getElementById("comentlist_submit") != undefined) {
                html += "<div class=\"hrow_l\">";
                html += "用户：";
                html += "</div>";
                html += "<div class=\"hrow_r\">";
                html += res.split("|")[0];
                html += "</div>";
                $("#comentlist_submit").html(html);
            }
            
        }
        else {
            alert("用户名或密码错误,请重新输入?");
            return;
        }
    })
}

//顶部导航控制
var timeoutpt;
$("#Alist").mouseover(function() {
    clearTimeout(timeoutpt);
    $("#MallGoodsList").show();
})
$("#Alist").mouseout(function() {
    timeoutpt = setTimeout("MallGoodsList()", 300);
})
$("#MallGoodsList").mouseover(function() {
    clearTimeout(timeoutpt);
})
$("#MallGoodsList").mouseout(function() {
    timeoutpt = setTimeout("MallGoodsList()", 300);
})
function MallGoodsList() {
    $("#MallGoodsList").slideUp();
}


var timeoutpt1;
$("#Blist").mouseover(function() {
    clearTimeout(timeoutpt1);
    $("#BMallGoodsList").show();
})
$("#Blist").mouseout(function() {
timeoutpt1 = setTimeout("MallGoodsList1()", 300);
})
$("#BMallGoodsList").mouseover(function() {
    clearTimeout(timeoutpt1);
})
$("#BMallGoodsList").mouseout(function() {
timeoutpt1 = setTimeout("MallGoodsList1()", 300);
})
function MallGoodsList1() {
    $("#BMallGoodsList").slideUp();
}



/*智能搜索*/
var theIndex = 0;
var searchText = "";
function AutoSearchByData() {
    $("#SearchText").keyup(function() {
        if (searchText != this.value) {
            searchText = this.value;
            $.post("/globe/", { key: encodeURIComponent(this.value), mat: Math.random(), action: 22 }, function(res) {
                if (res != "") {
                    var html = "";
                    var list = res.split('|');
                    for (var i = 0; i < list.length; i++) {
                        var value = list[i].split('、');
                        if (i == 0) {
                            html += "<li tvalue='" + value[0] + "' class='hover'>";
                        }
                        else {
                            html += "<li tvalue='" + value[0] + "'>";
                        }

                        html += "<span>" + value[0].replace($("#SearchText").val(), "<b>" + $("#SearchText").val() + "</b>") + "</span><em>约" + value[1] + "个</em>";
                        html += "</li>";
                    }
                    $("#SearchListBox").html(html);
                    $("#SearchListBox").show();
                    $("#SearchListBox li").each(function() {
                        if ($(this).attr("class") != "hover") {
                            $(this).mouseover(function() {
                                $(this).attr("class", "hover");
                            })
                            $(this).mouseout(function() {
                                $(this).attr("class", "");
                            })
                        }
                        $(this).click(function() {
                            $("#SearchText").val($(this).attr("tvalue"));
                            $(this).attr("class", "hover");
                            $("#SearchListBox").hide();
                        })
                    })
                }
                else {
                    theIndex = 0;
                    $("#SearchListBox").hide();
                }
            })
        }
    })
}

//自动搜索
function AutoSearch() {
    $("body").click(function() {
        $("#SearchListBox").hide();
        theIndex = 0;
    })
    AutoSearchByData();
    $("#SearchText").keydown(function(event) {
        var liList = $("#SearchListBox li");
        var key = event.keyCode || event.which || event.charCode;
        if ($("#SearchListBox").css("display") != "none") {
            if (key == "38") {//上
                $("#SearchText").unbind("keyup"); //解除
                if (theIndex != 0 && theIndex < liList.length) {
                    theIndex = theIndex - 1;
                }
                else {
                    theIndex = liList.length - 1;
                }
                liList.each(function(i) {
                    if (i == theIndex) {
                        $("#SearchText").val($(this).attr("tvalue"));
                        $(this).addClass("hover");

                    }
                    else {
                        $(this).removeClass("hover");
                    }
                })
            }

            if (key == "40") {
                $("#SearchText").unbind("keyup"); //解除
                if (theIndex <= liList.length) {
                    theIndex = theIndex + 1;
                }
                if (theIndex == liList.length) {
                    theIndex = 0;
                }
                liList.each(function(i) {
                    if (i == theIndex) {
                        $("#SearchText").val($(this).attr("tvalue"));
                        $(this).addClass("hover");
                    }
                    else {
                        $(this).removeClass("hover");
                    }
                })
            }
            if (key != "38" && key != "40") {
                AutoSearchByData();
            }
        };
    })
    /*智能搜索*/
}

AutoSearch();


function HideDisplay() {
    $("#mall-Classzone").slideUp(1000);
}

var kefuTimeOut;
function M_T_T() {
    kefuTimeOut = setTimeout("MouseOutFunction()", 300);
}
function MouseOverFunction() {
    clearTimeout(kefuTimeOut);
    $("#MallNavServer").show();
}
function MouseOutFunction() {
    $("#MallNavServer").hide();
}


function addCookie() {
    if (document.all) {
        try { window.external.addFavorite('http://www.23544.com', '练爱食光校园零食网！'); }
        catch (e1) {
            try
   { window.external.addToFavoritesBar('http://www.23544.com', '练爱食光校园零食网！'); }
            catch (e2)
   { alert('加入收藏失败，请您手工加入。') }
        }
    }
    else if (window.external) { window.sidebar.addPanel('http://www.23544.com', '练爱食光校园零食网！', ""); }
    else { alert('加入收藏失败，请您手工加入。') }
}
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.23544.com');
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
            catch (e) { alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 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', urls);

}


