

function XHConn()
{
	var xmlhttp = null;
	var bComplete = false;
	var async = true;

	// create httprequest object.
	try 
	{ 
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch( E ) 
	{ 
		try 
		{ 
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		catch( E ) 
		{ 
			try 
			{ 
				xmlhttp = new XMLHttpRequest(); 
			}
			catch( E ) 
			{ 
				xmlhttp = false; 
			}
		}
	}
	
	// check it.
	if( xmlhttp == null ) 
	{
		return null;
	}

	// setter for async.
	this.setasync = function( fvalue )
	{
		async = fvalue;
		return true;
	}
	
	// the connect function.
	this.connect = function( sURL, sMethod, sVars, fnDone )
	{
		if( !xmlhttp ) 
		{
			return false;
		}
		
		bComplete = false;
		sMethod = sMethod.toUpperCase();
		
		try 
		{
			if( sMethod == "GET" )
			{
				// build URL.
				if( sVars != "" )
				{
					RequestUrl = sURL + "?" + sVars;
				}
				else
				{
					RequestUrl = sURL;
				}
				
				// open it.
				xmlhttp.open( sMethod, RequestUrl, async );
				
				// clear vars so we don't send it.
				sVars = "";
			}
			else
			{
				xmlhttp.open( sMethod, sURL, true );
				xmlhttp.setRequestHeader( "Method", "POST " + sURL + " HTTP/1.1" );
				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
	
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 && bComplete == false )
				{
					bComplete = true;
					try
					{
						if( fnDone != null )
						{
							fnDone( xmlhttp );
						}
					}
					catch( E )
					{
					}
				}
			};

			xmlhttp.send( sVars );
		}
		
		catch(z)
		{ 
			return false; 
		}
		
		return true;
	
	};
	
	// done!
	return this;
}