﻿
//加入收藏
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); });

//输出mini购物车
$.get("/shoppingcart/minicart?t=" + new Date(), function(data) { $("#cartShop").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 ($.trim(keyword) != "" && keyword.indexOf("*") == -1 && keyword.indexOf("/") == -1 && keyword.indexOf(".") == -1 && keyword.indexOf("-") == -1) {
        if (keyword == "请输入商品名称或拼音首字母  如希爱力或xal") {
            window.location.href = "http://www.360kxr.com/drugs.html";return false;
        } else {
            keyword = keyword.replace("-", "").replace(".", "").replace("|", "");
            keyword = $.trim(keyword);
            window.location.href = "/Search_V2/?id=" + encodeURIComponent(keyword); 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_V2/?id=") > -1) {
    url = url.substr(url.indexOf("/Search_V2/?id=") + 8);
    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() {
		if ($("#keyWord").val() == "请输入商品名称或拼音首字母  如希爱力或xal")	{
			$("#keyWord").val("");
			$("#keyWord").css("color", "#000000");
		}

});
$("#keyWord").blur(function() {
    if ($("#keyWord").val() == "") {
        $("#keyWord").val("请输入商品名称或拼音首字母  如希爱力或xal");
        $("#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");
					           }
);


//显示登录状态
if (!$.cookie("Top_Flag_Cookie")) {
    $.get("/memberaction/loginstate.aspx?ReturnUrl=" + escape(window.location.href) + "&t=" + new Date(), function(data) { $("#logoName").html(data); });
}
$.get("/memberaction/SimpleLoginState.aspx?ReturnUrl=" + escape(window.location.href) + "&t=" + new Date(), function(data) { $("#ZT_logoName").html(data); });

//显示用户消息
$.get("/memberaction/UserMessageCount.aspx?t=" + new Date(), function(data) { $("#mesCount").html(data); });

//为热门关键字添加事件
function KeyWordClick(adID) {
    $.post("/ CommonAjax/AsynAddClick/", "id=" + adID + "&t=" + new Date(), null, "text");
}


