var Cl_AjaxresponseText;
var Cl_AjaxDoSuc	= 0;
var Cl_InstallDir	= "/";
var Cl_ChannelID	= 0;
var Cl_SpareVar		= 0;  //备用变量
var IsDebug			= false;
function ShowDebug(m){
	if(IsDebug){
		alert("[Debug]:"+m);
	}
}
function Cl_CreateAjaxObj()
{
	var XmlHttp;
	//windows
	try {
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
	} catch (e) {
		try {
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				XmlHttp = false;
			}
		}
	}
	//other
	if (!XmlHttp)
	{
		try {
			XmlHttp = new XMLHttpRequest();
		} catch (e) {
			XmlHttp = false;
		}
	}
	return XmlHttp;
}
function Cl_Ajax()
{
	this.XmlHttp= new Cl_CreateAjaxObj();
	this.Url	= null;
	this.ContentType = "application/x-www-form-urlencoded";
	this.HttpMethod = "POST";
	this.SucDo = null;
	this.ErrDo = null;
}
/* Get */
Cl_Ajax.prototype.Get = function() {
	this.ContentType= "text/html";
	this.HttpMethod = "GET";
	if (this.Url!=null){this.SendRequest(null);}
}
/* Post */
Cl_Ajax.prototype.Post = function(PostData) {
	this.ContentType= "application/x-www-form-urlencoded" ;
	this.HttpMethod = "POST";
	if (this.Url!=null){this.SendRequest(PostData);}
}
Cl_Ajax.prototype.SendRequest = function(data){
	if ( this.XmlHttp != null )
	{
		this.XmlHttp.open(this.HttpMethod, this.Url, true);
		if (this.HttpMethod=="POST"){this.XmlHttp.setRequestHeader("content-length",data.length);}
		this.XmlHttp.setRequestHeader("content-type", this.ContentType);
		var thisAjax=this;var thisFunction;
		this.XmlHttp.onreadystatechange = function (){
			if (thisAjax.XmlHttp.readyState==4&&thisAjax.XmlHttp.status==200) {
				Cl_AjaxresponseText = thisAjax.XmlHttp.responseText;
				if (Cl_AjaxresponseText.substring(0,2)=="OK") {Cl_AjaxDoSuc = 1;thisFunction = thisAjax.SucDo;}
				else{thisFunction = thisAjax.ErrDo;}
				if (thisFunction!=null){setTimeout(thisFunction,10);}
				//Cl_AjaxresponseText = Cl_AjaxresponseText.substring(3,Cl_AjaxresponseText.length);
			}else{
				switch(thisAjax.XmlHttp.readyState){
				case 1:
					break;//正在连接服务器;
				case 2:
					break;//正在向服务器发送数据;
				case 3:
					break;//正在接收返回数据;
				default:
					break;//;
				}
			}
		}
		this.XmlHttp.send(data);
	}
}

//GOODSDETAILS
function AjaxGetGoodsDetails(id,t){
	var url = "/Ajax.php?act=memo&GoodsID="+ id +"&t="+ t +"&d="+new Date();
	var Ajax = new Cl_CreateAjaxObj();
	Ajax.open("Get",  url, true);
	Ajax.onreadystatechange=function() {
		if (Ajax.readyState==4&&Ajax.status==200) {

			document.getElementById("GoodsDetails").innerHTML = Ajax.responseText;
		}
	}
	Ajax.send();		
}



function AjaxGetGoodsNew(id,t){
	var url = "/Ajax.php?act=new2&GoodsID="+ id +"&d="+new Date();
	var Ajax = new Cl_CreateAjaxObj();
	Ajax.open("Get",  url, true);
	Ajax.onreadystatechange=function() {
		if (Ajax.readyState==4&&Ajax.status==200) {
				if(Ajax.responseText!=''){
					document.getElementById(t).innerHTML = '<img src=\"/images/new.jpg\" width=\"38\" height=\"13\"/>'; 
				}
		}
	}
	Ajax.send();		
}

function AjaxGetGoodsHot(id,t){
	var url = "/Ajax.php?act=hot2&GoodsID="+ id +"&d="+new Date();
	var Ajax = new Cl_CreateAjaxObj();
	Ajax.open("Get",  url, true);
	Ajax.onreadystatechange=function() {
		if (Ajax.readyState==4&&Ajax.status==200) {
				if(Ajax.responseText!=''){
					document.getElementById(t).innerHTML = '<img src=\"/images/special.jpg\" width=\"46\" height=\"13\"/>'; 
				}
		}
	}
	Ajax.send();		
}

function AjaxGetLeftHtml(Page,t){
	var url = "/dopimg/"+ Page.toLowerCase() +"?d="+new Date();
	var Ajax = new Cl_CreateAjaxObj();
	Ajax.open("Get",  url.toLowerCase(), true);
	Ajax.onreadystatechange=function() {
		if (Ajax.readyState==4&&Ajax.status==200) {
				if(Ajax.responseText!=''){
					document.getElementById(t).innerHTML = Ajax.responseText; 
				}
		}
	}
	Ajax.send();		
}


function AjaxGetdetails(id){
	var Request=new Object();
	Request=GetRequest();
	gOo = Request['gOo'];
	var url = "/Ajax.php?act=category&gOo="+ gOo +"&GoodsID="+ id +"&d="+new Date();
	var Ajax = new Cl_CreateAjaxObj();
	Ajax.open("Get",  url, true);
	Ajax.onreadystatechange=function() {
		if (Ajax.readyState==4&&Ajax.status==200) {
				if(Ajax.responseText!=''){
					location.href = Ajax.responseText;
				}
		}
	}
	Ajax.send();		
}


function GetRequest()
{
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if(url.indexOf("?") != -1)
{ 
  var str = url.substr(1);
    strs = str.split("&");
  for(var i = 0; i < strs.length; i ++)
    { 
     theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
    }
}
return theRequest;
}










