function AjaxUtilities()
{

	function addEvent( obj, type, fn )
	{
		if ( obj.attachEvent )
		{
			obj['e'+type+fn] = fn;
			obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
			obj.attachEvent( 'on'+type, obj[type+fn] );
		}
		else
		{
			obj.addEventListener( type, fn, false );
		}
	}


	function addEventByName(name, type, fn)
	{
		addEventById(document.getElementById(name), type, fn);
	}


	function addOnPageLoadEvent(fn)
	{
		addEvent(window, "load", fn);
	}




	/**
	 * checkResponseForExceptions
	 * Checks to see if response is an AJAX exception and handles appropriately
	 * @param {Object} response
	 */
	function checkResponseForExceptions(response)
	{
		if (response.serviceexception)
		{
			if (self.showAjaxExceptions && showAjaxExceptions)
			{

				alert(response.serviceexception.code + ":" + response.serviceexception.type + ":" + response.serviceexception.message);
				alert("Detail: " + response.serviceexception.detail);
			}
			return false;
		}
		return true;
	}


	function getErrorCodeFromException(response)
	{
		if (response.serviceexception)
		{
			return response.serviceexception.code;
		}
		return "TAJ-5566";
	}

	function getMessageFromException(response)
	{
		if (response.serviceexception)
		{
			return response.serviceexception.message;
		}
		return "TAJ-5567";
	}

	function getDetailFromException(response)
	{
		if (response.serviceexception)
		{
			return response.serviceexception.detail;
		}
		return "TAJ-5568";
	}





	this.addEvent = addEvent;
	this.addEventByName = addEventByName;
	this.addOnPageLoadEvent = addOnPageLoadEvent;
	this.checkResponseForExceptions = checkResponseForExceptions;
	this.getErrorCodeFromException = getErrorCodeFromException;
	this.getMessageFromException = getMessageFromException;
	this.getDetailFromException = getDetailFromException;
}








