﻿
//加入收藏
function Collect() {
    if (document.all) { window.external.addFavorite("http://www.360kxr.com/", "开心人网上药店"); }
    else if (window.sidebar) { window.sidebar.addPanel("开心人网上药店", "http://www.360kxr.com/", ""); }
}

//输出mini购物车
$.get("/shoppingcart/minicart?t=" + new Date(), function(data) { $("#cart").html(data); });

var hoverLI;
var hoverID;
//Jquery下拉菜单
$(document).ready(function() {

    $("#header a,#header li").attr("onfocus", "this.blur()");
});

$("#indexSubNav li:not('#index')").hover(function() {
    hoverID = this.id;
    hoverLI = this;
    $("#down_" + hoverID).css({ top: $(hoverLI).position().top + 80, left: $(hoverLI).position().left + 151 });
    $("#down_" + hoverID).show();
    $("#down_" + hoverID).hover(function() { $("#down_" + hoverID).show(); $(hoverLI).addClass("current"); }, function() { $("#down_" + hoverID).hide(); $(hoverLI).removeClass("current"); });

}, function() { $("#down_" + hoverID).hide(); });
//主导航下拉菜单效果end

//频道名高亮效果begin
$("#indexSubNav li").click(function() { $("#indexSubNav li[class='current']").removeClass("current"); $(this).addClass("current"); });

var url = window.location.toString().split("/");
if (url[url.length - 1] == "") {
    $("#index").addClass("current");
}
else {
    var channelName = decodeURI(url[url.length - 1].split("-")[0]);
    var allLi = $("#indexSubNav li");
    $.each(allLi, function(i, n) {
        if ($.trim($(n).text()) == $.trim(channelName)) {
            $("#" + n.id).addClass("current");
        }
    });
}

//频道名高亮效果end

//去掉商品分类最后分割线begin
if ($("ul:has('.siderNavContentDetails'):last")) {
    $(".siderNavContentDetails:last").removeClass("siNavConDesBorder");
}
//去掉商品分类最后分割线end

//搜索JS
function searchaction() {
    var keyword = $("#keyWord").val();
    if (keyword != "") {
        keyword = keyword.replace("-", "").replace(".", "").replace("|", "");
        window.location.href = "/search/" + encodeURIComponent(keyword) + ".html"; return true;
    }
    else {
        alert("请输入关键词！");
        return false;
    }
}
$("#searchbutton").click(function() { searchaction(); });
$("#keyWord").keypress(function(e) { if (e.keyCode == 13) { $("#searchbutton").click(); return false; } });
var url = window.location.href.toLowerCase();
if (url.indexOf("/search.") > -1) {
    url = url.substr(url.indexOf("/search.") + 8);
    url = url.replace(".html", "");
    var result = url.split('-');
    if (result.length == 1) {
        $("#keyWord").val(decodeURI(result));
    }
    else {
        $("#keyWord").val(decodeURI(result[8]));
    }
}

//搜索提示
$("#keyWord").css("color", "#999");
$("#keyWord:not('#searchbutton')").focus(function() {

    $("#keyWord").val("");
    $("#keyWord").css("color", "#000000");

});
$("#keyWord").blur(function() {
    if ($("#keyWord").val() == "") {
        $("#keyWord").val("请输入您要查询的商品名称");
        $("#keyWord").css("color", "#999");
    }
});

$("#selcetValue").click(function() {
    $("ul.selcetDownMenu").slideDown('fast').show();
    $("div.selcetDown").hover(function() { }, function() { $("ul.selcetDownMenu").slideUp('slow'); });
});
$("ul.selcetDownMenu li").click(
					           function() {
					               $("#selcetValue").text($(this).text());
					               $("ul.selcetDownMenu").css("display", "none");
					           }
					                       );

//显示登录状态
$.get("/memberaction/loginstate.aspx?ReturnUrl=" + escape(window.location.href) + "&t=" + new Date(), function(data) { $("#logoName").html(data); });

//为热门关键字添加事件
function KeyWordClick(adID) {
    $.post("/ CommonAjax/AsynAddClick/", "id=" + adID + "&t=" + new Date(), null, "text");
}


