var AgentName=navigator.appName;

function UserAgent(){
	var agent=null;
	var callbackHandler=null;
	
	this.post=function(url,param,callback){
		callbackHandler=callback;
		makeRequest(url,param,"POST");
	}
	
	this.get=function(url,param,callback){
		callbackHandler=callback;
		makeRequest(url,param,"GET");
	}
	
	makeRequest=function(url,param,method){
		var asynchronous=false;
		
		if (AgentName.indexOf("Microsoft")!=-1 && window.ActiveXObject){
			agent=new ActiveXObject("Microsoft.XMLHTTP");
		} else if (AgentName.indexOf("Netscape")!=-1 && window.XMLHttpRequest){
			asynchronous=true;
			agent=new XMLHttpRequest();
		} else{ 
			throw "Error - AJAX is not supported by " + AgentName;
		}
		if (agent){
			//Set the function that will be called when the XmlHttpRequest objects state changes
			agent.onreadystatechange =handleResponse; 
			   
			//Set up the connection to captcha_test.html. True sets the request to asynchronous(default) 
			agent.open(method, url, asynchronous);
			
			//Add HTTP headers to the request
			agent.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			agent.setRequestHeader("Content-length", param.length);
			agent.setRequestHeader("Connection", "close");
			
			//Make the request
			agent.send(param);
		}
	}
	
	handleResponse=function(){
		if (agent.readyState==4){
			if (callbackHandler && typeof(callbackHandler)=="function")
				callbackHandler(agent.responseText,agent.responseXML);
			else
				window.status="Warning - need to set callback handler.";
		}
	}
}