function HtmlAjaxLoader()
{	
	var m_Form;
	var m_TargetContainer;
	var m_Timeout;
	var m_RequestMethod;
	var m_Url;
	
	var m_ErrorEventHandler;
	var m_LoadedEventHandler;
	
	m_Timeout = 5000;
	
	this.GetForm = function()
	{
		return m_Form;
	};//endmethod GetForm
	
	this.SetForm = function(form)
	{
		m_Form = form;
	};//endmethod SetForm
	
	this.GetTargetContainer = function()
	{
		return m_TargetContainer;
	};//endmethod GetTargetContainer
	
	this.SetTargetContainer = function(targetContainer)
	{
		m_TargetContainer = targetContainer;
	};//endmethod SetTargetContainer
	
	this.GetTimeout = function()
	{
		return m_Timeout;
	};//endmethod GetTimeout
	
	this.SetTimeout = function(timeout)
	{
		m_Timeout = timeout;
	};//endmethod SetTimeout
	
	this.GetRequestMethod = function()
	{
		return m_RequestMethod;
	};//endmethod GetRequestMethod
	
	this.SetRequestMethod = function(requestMethod)
	{
		m_RequestMethod = requestMethod;
	};//endmethod SetRequestMethod
	
	this.GetUrl = function()
	{
		return m_Url;
	};//endmethod GetUrl
	
	this.SetUrl = function(url)
	{
		m_Url = url;
	};//endmethod SetUrl
	
	this.GetErrorEventHandler = function()
	{
		return m_ErrorEventHandler;
	};//endmethod GetErrorEventHandler;
	
	this.SetErrorEventHandler = function(eventHandler)
	{
		m_ErrorEventHandler = eventHandler;
	};//endmethod SetErrorEventHandler;
	
	this.GetLoadedEventHandler = function()
	{
		return m_LoadedEventHandler;
	};//endmethod GetLoadedEventHandler;
	
	this.SetLoadedEventHandler = function(eventHandler)
	{
		m_LoadedEventHandler = eventHandler;
	};//endmethod SetLoadedEventHandler;
	
	this.SendRequest = function()
	{
		var requestMethod = new AjaxRequestMethod();
		
		if (m_RequestMethod == requestMethod.Get)
		{
			if (m_Form == null)
			{
				dojo.xhrGet({ 
					url: 		m_Url,
					
					handleAs: 	"text",
					
					//Time in milliseconds								 
					timeout: 	m_Timeout,
					
					//The LOAD function will be called on a successful response.
					load: 		OnHtmlDocumentLoaded,
					
					// The ERROR function will be called in an error case.
					error: 		OnHtmlDocumentLoadError
		       });
			}
			else
			{
				dojo.xhrGet({ 
					url: 		m_Url, 
					
					handleAs: 	"text",
					
					form:		m_Form,
					
					//Time in milliseconds								 
					timeout: 	m_Timeout,
					
					//The LOAD function will be called on a successful response.
					load: 		OnHtmlDocumentLoaded,
					
					// The ERROR function will be called in an error case.
					error: 		OnHtmlDocumentLoadError
		       });
			}//endif
		}
		else if (m_RequestMethod == requestMethod.Post)
		{
			if (m_Form == null)
			{
				dojo.xhrPost({ 
					url: 		m_Url, 
					
					handleAs: 	"text",
					
					//Time in milliseconds								 
					timeout: 	m_Timeout,
					
					//The LOAD function will be called on a successful response.
					load: 		OnHtmlDocumentLoaded,
					
					// The ERROR function will be called in an error case.
					error: 		OnHtmlDocumentLoadError
		       });
			}
			else
			{
				dojo.xhrPost({ 
					url: 		m_Url, 
					
					handleAs: 	"text",
					
					form:		m_Form,
					
					//Time in milliseconds								 
					timeout: 	m_Timeout,
					
					//The LOAD function will be called on a successful response.
					load: 		OnHtmlDocumentLoaded,
					
					// The ERROR function will be called in an error case.
					error: 		OnHtmlDocumentLoadError
		       });
			}//endif
		}//endif
	};//endmethod SendReponse
	
	function OnHtmlDocumentLoadError(response, ioArgs)
	{
		if (m_ErrorEventHandler != null)
		{
			m_ErrorEventHandler(response, ioArgs);
		}
		else
		{
			alert(response);
		}//endif
	}//endfunction OnHtmlDocumentLoadError
	
	function OnHtmlDocumentLoaded(response, ioArgs)
	{
		var targetContainer 	= document.getElementById(m_TargetContainer);
		var transformedOutput	= null;
		
		targetContainer.innerHTML = "";				
		
		try
		{
			targetContainer.appendChild(response);
		}//endtry
		catch (e) 
		{
			targetContainer.innerHTML = response;
		}//endcatch
		
		ExecuteJavascripts(response);
		
		if (m_LoadedEventHandler != null)
		{
			m_LoadedEventHandler(response, ioArgs);
		}
	}//endfunction OnHtmlDocumentLoaded
	
	function ExecuteJavascripts(scripts)
	{	
		try
		{	if(scripts != '')	
			{	var script = "";
				scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
		       	                         if (scripts !== null) script += arguments[1] + '\n';
	 	        	                        return '';});
				if(script) 
				{
					(window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
				}//endif
			}//endif
			return false;
		}
		catch(e)
		{	
			alert(e);
		}
	}
}//endclass HtmlAjaxLoader

