﻿/******************************************************************************
* filename: index.js
* Include Modul Scripting
* (C) NSW程序部 2011-11-13
* (C) NSW(http://www.nsw88.com)
*******************************************************************************/
function ResumeError() { return true; } window.onerror = ResumeError; 
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();
 var cp=$("#selid").val();
window.location.href="/Search/index.aspx?kwd="+keyword+"&kid="+cp;
 
}

//加入收藏
function addBookmark() {
    var _title = document.title;
    var url = document.URL;
    if (window.sidebar) {
        window.sidebar.addPanel(_title, url, "");
    }
    else
        if (window.opera && window.print) {
        var __mbm = document.createElement('a');
        __mbm.setAttribute('rel', 'sidebar');
        __mbm.setAttribute('href', url);
        __mbm.setAttribute('title', _title);
        __mbm.click();
    }
    else
        if (document.all) {
        window.external.AddFavorite(url, _title);
    }
}

//初始化头部热门关键词
function initCommonHeaderKeywords(_s) {

    if (_s == "") _s = "6";
    $.post("/ajax.ashx?action=initcommonheaderkeywords&t=" + Math.random(), {
        s: _s
    }, function (msg) {
        $j("commonHeaderkeywords").html(msg);
    });
}
