function XMLHttp(){
//netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}


XMLHttp.prototype.create = function(){
 
	if (typeof XMLHttpRequest == 'undefined') {
		  XMLHttpRequest = function () {
		    var msxmls = ['MSXML3', 'MSXML2', 'Microsoft']
  			  for (var i=0; i < msxmls.length; i++) {
			      try {
			        return new ActiveXObject(msxmls[i]+'.XMLHTTP')
    			  }
			      catch (e) { }
    		 }
    		 throw new Error("No XML component installed!")
  		}
	}

	return new XMLHttpRequest();	
} 


XMLHttp.prototype.browserIsCompatible = function(){
	var bool = false;

	if (typeof XMLHttpRequest == 'undefined') {
	      var msxmls = ['MSXML3', 'MSXML2', 'Microsoft']
  		  for (var i=0; i < msxmls.length; i++) {
		      try {
		        if (new ActiveXObject(msxmls[i]+'.XMLHTTP')){
					bool = true;	
					break;
				}
    		  }
		      catch (e) { }
    	 }
	}else{
		bool = true;
	}

	
	return bool;
}

XMLHttp.prototype.requestURL = function(  url, method, postData, handler  ){
	if ( ! url ) 	{ alert("No URL Specified for Request"); return }
	if ( ! method ) { method = 'GET'; } else { method = method.toUpperCase(); }



	//Create a new request object
    var req = this.create();
    req.open(method, url, true);
    req.onreadystatechange = function(){ handler(req) };

	// Set the request header and build the post string
	// If the method is post
	var postDataString = null;
	if ( method == 'POST'){
    	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	
		postDataString = '';
		for( var i = 0; postData.length > i; i++ ){
			if ( postDataString.length > 0 ){ postDataString += "&"; }
			postDataString += postData[i].key +"=" + encodeURI( postData[i].value  );
		}
		
	}

    /* Send the request */
    req.send( postDataString );
}

XMLHttp.prototype.setHandler = function(handler) {
	this.handler = handler;
}
