function httpClient() { }
httpClient.prototype ={
	// default is GET, but could be POST
	requestType: "GET",
 		// default is false, but could be true for multiple calls.	
	isAsync: false,
		// where the actual XMLHttpRequest is stored
	xmlhttp: false,
	callback: false,
		// set what you expect to get back from the server
	// default is TEXT, but could also be XML
	responseType: "TEXT",
		// progress indicator
	onSend:function()
	{
		//nothing to do
	},
	onLoad:function()
	{
		//nothing to do
	},
		// display error
	onError:function(error)
	{
		alert(error);
	},
		init:function()
	{
		try
		{
			// mozilla, safari, opera, ie7
			this.xmlhttp = new XMLHttpRequest();
		}
		// this catch will also run through all the MS XML's
		catch(e)
		{
			var XMLHTTP_IDS = new Array("MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
			var success = false;
			for (var i = 0; i <XMLHTTP_IDS.length && !success; i++)
			{
				try
				{	
					this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
					success = true;
				}
				catch(e)
				{
					// do nothing. Non-supported browser
				}
			}
			if (!success)
			{

				this.onError("Unable to create XMLHttpRequest.");
			}
		}
	},
			makeRequest: function(url)
	{
		
		// if not initialized, do it
		if (!this.xmlhttp)
		{
			this.init();
		}
				// opens the connection
		this.xmlhttp.open(this.requestType, url, this.isAsync);
		
		var self = this;

		this.xmlhttp.onreadystatechange = function()		
		{
		// the underscore means it's a private method
			self._readyStateChangeCallback();
		}
		this.xmlhttp.send(url);

		// if it's not async, return the response
		if (!this.isAsync)
		{
		
			// added detection for TEXT or XML types
			if (this.responseType == "TEXT")
			{
				return this.xmlhttp.responseText;
			}
			else if (this.responseType == "XML")
			{
				
				return this.xmlhttp.responseXML;
			}
			else{
				this.onError("Invalid response type");
			}
		}
	},
		_readyStateChangeCallback:function()
	{
		switch(this.xmlhttp.readyState)
		{
			case 2:
			 // displays the loading message
			 this.onSend();
			 break;
			case 4:
 			 // turn off the loading message
 			 
			 this.onLoad();
			 // successful response
			 if(this.xmlhttp.status == 200)
			 {
			 	if(this.responseType == "TEXT")
				{
					
				 	// sends back response text
				 	
				 	this.callback(this.xmlhttp.responseText);
				}
				else if(this.responseType == "XML")
				{
					
					this.callback(this.xmlhttp.responseXML);
				}
				else
				{
					this.onError("invalid response type");
				}
			 }
			 // if there was an error (ie. 404 or 500)
			 else{
			 	this.onError ("HTTP Error Making Request: "+
				"["+this.xmlhttp.status+"]"+this.xmlhttp.statusText);
			 }
			 break;
		}
	}
}
