﻿
function js0014_addselect(str, id, mtype) {
    var searchkey = "";
    //截取
    var kk = str.substring(0, str.length - 1);
    //分割
    var keys = kk.split(',');
    for (var i = 0; i < keys.length; i++) {
        var k = keys[i];
        searchkey += keys[i] + ":";
        var onekey = "";
        $("input:checkbox[id^=chk_" + k + "]").each(function() {
            if ($(this).attr("checked") == true) {
                onekey += $(this).val() + ",";
            }
        });
        if (onekey == "") {
            onekey = "全部";
        }
        else {
            onekey = onekey.substring(0, onekey.length - 1);
        }
        searchkey += onekey + "|";
    }
    searchkey = searchkey.substring(0, searchkey.length - 1);
    js0014_showProductList(id, searchkey, mtype);
   
}

//随机数
var number = Math.random();

//XmlHttpRequest 对象
function js0014_GetHttpObject() {
    if (typeof XMLHttpRequest != "undefined") return new XMLHttpRequest();

    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) { }
    }

    return false;
}

//ajax请求
function js0014_CreateCallback(url, calling, callback) {
    var http = js0014_GetHttpObject();
    http.open("GET", url, true);
    http.onreadystatechange = function() {
        //成功
        if (http.readyState == 1) {
            if (calling != undefined) {
                calling();
            }
        }
        if (http.readyState == 4) {
            if (callback != undefined) {
                if (http.responseText.length > 0) {
                    callback(http.responseText);
                }
            }
        }
    };
    http.send(null);
}

function js0014_showProductList(id, keys, mtype) {
    number++;
    js0014_CreateCallback("/webservice/ajaxproduct.aspx?id=" + id + "&keylist=" + js0014_URLencode(keylist) + "&keys=" + js0014_URLencode(keys) + "&mtype=" + mtype + "&num=" + number, js0014_showProductListCalling, js0014_showProductListCalled);
}

function js0014_showProductListCalling() {
    var html = "<DIV style=\"DISPLAY: block; width:677px;text-align:center;\" class=prCd>";
    html += "<img src=\"/picimages/loading.gif\"/>";
    html += "</DIV>";
    $("#productcontent").html(html);
}

function js0014_showProductListCalled(response) {
    //document.write(response);
    document.getElementById("productcontent").innerHTML = response;
 Initialization();
    // $("#productcontent").html(response);
}

function js0014_URLencode(sStr) {
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g, '%22').replace(/\'/g, '%27').replace(/\//g, '%2F');
}
