/*
	FILENAME: jsweld/ajax/ajax.js
	AUTHOR: Philip Siedow-Thompson (psiedow@co.weld.co.us)
	WRITTEN: 4/2/2009
	REVISIONS: none
	DEPENDENCIES: none
*/


		/* 
			FUNCTION:
			DESCRIPTION:
			ARGUMENTS:
			RETURNS:
		*/

var jsweld;
	jsweld = (jsweld)?jsweld:{};
	jsweld.ajax = {};
	
	/*------------------------------------------------------------------------------------
		JSWELD.AJAX.getXMLHttpRequest - returns an XMLHTTPREQUEST OBJECT
	--------------------------------------------------------------------------------------*/
	jsweld.ajax.getXmlHttpRequest = function()
	{
		var http = null;
		
		try
		{
			try {http = new XMLHttpRequest();}
				catch(e){http = new ActiveXObject("Msxml2.XMLHTTP");}
		}
		catch(e){/*CANNOT CREATE*/}
		
		return http;
	}
	
	/*------------------------------------------------------------------------------------
		JSWELD.AJAX.XMLCONNECTION - calendar constants.
	--------------------------------------------------------------------------------------*/
	jsweld.ajax.xmlDownload = function(a_url,a_callback)
	{
		this.url = a_url;
		this.used = false;
		this.http = jsweld.ajax.getXmlHttpRequest();
		
		var httpRef = this.http;
			httpRef.open("GET",this.url,true);
			httpRef.onreadystatechange = function()
			{
				if(httpRef.readyState==4)
					{
						a_callback(httpRef.responseXML);
					}
			}
	}
	jsweld.ajax.xmlDownload.prototype.send = function()
	{
		if(!this.used) 
		{
			this.used = true;
			this.http.send(null);
		}
		else throw new Error("Connection in use."); 
	}
