/**************************************
Namespace:smzobj  Javascript Files
Author:Shamozhu [沙漠猪]
Contact:QQ:64247121 Msn:shamozhu@hotmail.com
Copyright:Shamozhu [沙漠猪]
*****************************************/
var Smz = new Object();
Smz.Ajax = function(type, url, onload, params, contentType) {
    this.req = null;
    this.url = url;
    this.params = params;
    if (type) {
        this.type = type;
    } else {
        this.type = "get";
    }
    if (!contentType && type == "post") {
        this.contentType = "application/x-www-form-urlencoded; charset=utf-8";
    } else {
        this.contentType = contentType;
    }
    this.onload = onload;
    this.responseText = null;
    this.GetHttpRequest();
}

Smz.Ajax.prototype.GetHttpRequest = function() {
    if (window.ActiveXObject) {
        this.req = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        this.req = new XMLHttpRequest();
    }
}

Smz.Ajax.prototype.SendRequest = function() {
    var loader = this;
    this.req.onreadystatechange = function() {
        loader.OnReadyState.call(loader);
    }
    this.req.open(this.type, this.url, true);
    if (this.contentType) {
        this.req.setRequestHeader("Content-Type", this.contentType);
    }
    this.req.send(this.params);
}

Smz.Ajax.prototype.OnReadyState = function() {
    var ready = this.req.readyState;
    var data;
    if (ready == 4) {
        if (this.req.status == 200 || this.req.status == 0) {
            this.responseText = this.req.responseText;
        } else {
            this.responseText = "false";
        }
    } else {
        this.responseText = "load";
    }
    this.onload.call(this, this);
}
Smz.SetData = function(id) {
    var url = "GetEliteProduct.aspx";
    var param = "classId=" + escape(id);
    //alert(param);
    var ajax = new Smz.Ajax("post", url, Smz.ShowPic, param);
    ajax.SendRequest();
}
Smz.ShowPic = function(data) {
    var s = data.responseText;
    if (s != "false" && s != "load" && s != "") {
        var list = s.split("|");
        if (list.length > 1) {
            var o = $("productClassImg");
            o.src = list[0];
            o.alt = list[1];
            o.style.width = "272px";
            o.style.height = "278px";

        }
    } else if (s == "load") {
//        var o = $("productClassImg");
//        o.style.width = "31px";
//        o.style.height = "31px";
//        o.src = "/images/ajax-loading.gif";
//        o.alt = "正存加载，请稍后！";
    }
}