ajax = function(){}
var _a = ajax.prototype;
_a.XMLHTTP_Pids = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"];

_a.XH_XmlHttpInit_ = function () {
  // The following blog post describes what PROG IDs to use to create the
  // XMLHTTP object in Internet Explorer:
  // http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx
  // However we do not (yet) fully trust that this will be OK for old versions
  // of IE on Win9x so we therefore keep the last 2.
  // We got some reports that the post data changed due to the version so we
  // readded version 5 and 4 again.

  /**
   * Candidate Active X types.
   * @type Array<String>
   * @private
   */
   
  var XH_ieProgId_;
  var XH_ACTIVE_X_IDENTS = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0",
                            "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0",
                            "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];

  if (typeof XMLHttpRequest == "undefined" &&
      typeof ActiveXObject != "undefined") {
    for (var i = 0; i < XH_ACTIVE_X_IDENTS.length; i++) {
      var candidate = XH_ACTIVE_X_IDENTS[i];

      try {
        new ActiveXObject(candidate);
        XH_ieProgId_ = candidate;
        break;
      } catch (e) {
        // do nothing; try next choice
      }
    }

    // couldn't find any matches
    if (!XH_ieProgId_) {
      throw Error("Could not create ActiveXObject. ActiveX might be disabled," +
                  " or MSXML might not be installed.");
    }
  }
  if (XH_ieProgId_) {
    return new ActiveXObject(XH_ieProgId_);
  } else {
    return new XMLHttpRequest();
  }
}

_a.getXmlhttpObject = function(){
	var xmlhttp;
	if(window.XMLHttpRequest){
		try{
			xmlhttp = new XMLHttpRequest;
			xmlhttp.overrideMimeType("text/xml");	
		}	
		catch(e){}
	}
	else{
		for (var i=0; i<3; i++){
			var pid = this.XMLHTTP_Pids[i];
			try{
				xmlhttp = new ActiveXObject(pid);
			}
			catch(e){}
			if(xmlhttp){
				this.XMLHTTP_Pids = [pid];
				break;
			}
		}
	}
	if(!xmlhttp){
		window.alert("XMLHTTP not available");
	}
	//alert(xmlhttp);
	//xmlhttp.overrideMimeType("text/xml");
	return xmlhttp;
}

_a.StartRequest = function(url,type,callback){
	try{
		var rand = Math.floor(Math.random()*100000000+1);
		if(url.indexOf("?")<0){
			url = url + "?molihesessionid="+rand;	
		}else{
			url = url + "&molihesessionid="+rand;	
		}
		//alert(url);
		var is = callback ? true : false;
		var http = this.XH_XmlHttpInit_();
		//var http = this.getXmlhttpObject();
		http.open("GET" ,url ,is);
		
		//alert(is);
		if(is){
			http.onreadystatechange = function(){
				if(http.readyState == 4){
					if (http.status==200){
						var o;
						switch(type){
							case "text":
								o = http.responseText;
								break;
							case "xml":
							default:
								o = http.responseXML;
								break;
						}
						callback(o);
					}
				}
			};
		}
		http.send(null);
		if(is){
				return;
		}else{
			
			if(http.readyState != 4){
				window.alert("资源文件加载失败");
				return;
			}else{
				
				switch(type){
					case "text":
						
						return http.responseText;
						alert(http.responseText);
					case "xml":
					default:
						return http.responseXML;
				}
			}
			//alert(http.responseXML);
		}
	}
	catch(e){
		window.alert("网络异常，无法发送请求，请检查您的网络设置或浏览器设置！"+e.message);
		return;
	}
}

_a.StartRequest_Post = function(url,type,postData,callback){
	try{
		var rand = Math.floor(Math.random()*100000000+1);
		if(url.indexOf("?")<0){
			url = url + "?molihesessionid="+rand;	
		}else{
			url = url + "&molihesessionid="+rand;	
		}
		//alert(url);
		var is = callback ? true : false;
		var http = this.XH_XmlHttpInit_();
		//var http = this.getXmlhttpObject();
		http.open("POST" ,url ,is);
		
		//alert(is);
		if(is){
			http.onreadystatechange = function(){
				if(http.readyState == 4){
					if (http.status==200){
						var o;
						switch(type){
							case "text":
								o = http.responseText;
								break;
							case "xml":
							default:
								o = http.responseXML;
								break;
						}
						callback(o);
					}
				}
			};
		}
		
		http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http.setRequestHeader("content-length",postData.length);
		http.send(postData);

		if(is){
				return;
		}else{
			
			if(http.readyState != 4){
				window.alert("资源文件加载失败");
				return;
			}else{
				
				switch(type){
					case "text":
						
						return http.responseText;
						alert(http.responseText);
					case "xml":
					default:
						return http.responseXML;
				}
			}
			//alert(http.responseXML);
		}
	}
	catch(e){
		window.alert("网络异常，无法发送请求，请检查您的网络设置或浏览器设置！"+e.message);
		return;
	}
}


_a.getwin = function (title,content,footer){
	var winstr = "";
	winstr += "<div class=\"apc_02\" onmousedown=\"et.startmove(event);\"><div class=\"apc_05\">"+title+"</div>";
	winstr += "<div class=\"apc_06\"><a href=\"javascript:et.closewin();\" title=\"关闭\"><img src=\"js/images/apc_03.gif\" width=\"23px\" height=\"23px\" border=\"0\" /></a></div></div>";
	winstr += "<div class=\"apc_03\" id=\"openwincontent\">"+content+"</div>";
	winstr += "<div class=\"apc_04\">";
	winstr += "<div class=\"apc_06\"></div>";
	winstr += "<div class=\"apc_06\">"+footer+"</div>";
	winstr += "</div>";
	return winstr;
}

_a.boxcode_js = function(subid,type){
	var str = "<script language=\"javascript\" src=\"http://www.molihe.com/molihe.php?subid="+subid+"&type="+type+"\"></script>";
	return str;
}


