﻿/******************************************************************************
* filename: index.js
* Include Modul Scripting
* (C) NSW程序部 2011-11-13
* (C) NSW(http://www.nsw88.com)
*******************************************************************************/

function initCommonHeader() {
    $.get("/ajax.ashx?action=initcommonheader&t=" + Math.random(), function (rsp) {
        $j("headerCartCount").html(gav(rsp, "prod_count"));
        var IM = gav(rsp, "showIM");
        showIM(IM);
        var username = gav(rsp, "username");
        if (username.length > 0) {
            $j("commonHeaderGuest").hide();
            $j("commonHeaderUsername").html(username);
            $j("commonHeaderUser").fadeIn(80);
        }
    });
}

/********************* 根据key获取 ajax对象节点值getAjaxVal* xMsg : xml对象* key : 节点的属性key********************/
function gav(xMsg, key) {
    var jMsg = $(xMsg);
    var s = $(jMsg.find("node[key=" + key + "]")).text();
    return s;
}
//是否显示在线客服
function showIM(res) {
    if ($("#bodd").html() != "") {
        if (res == "True") {
            $("#bodd").show();
            $("#kefubtn").hide();
            $("#divOranIm").show();
        }
        else {
            $("#bodd").hide();
            $("#kefubtn").show();
            $("#divOranIm").hide();
        }
    }
}


//查询
function SearchKeyWord() {
 var keyword=$("#seachkeywords").val();

window.location.href="/Search/index.aspx?kwd="+keyword;
 
}

//初始化头部热门关键词
function initCommonHeaderKeywords(_s) {
    if (_s == "") _s = "6";
    $.post("/ajax.ashx?action=initcommonheaderkeywords&t=" + Math.random(), {
        s: _s
    }, function (msg) {
        $j("commonHeaderkeywords").html(msg);
    });
}
