function Ajax()
{
	/**
	 * Gets the contents of the form as a URL encoded String
	 * suitable for appending to a url
	 * @return string with encoded form values, begins with &
	 */
	function getParameters()
	{
		// Setup the return String
		var returnString = "";
	    
	    // Loop thru forms
	    for (var a = 0; a < document.forms.length; a++)
	    {
			// Get the form values
			var formElements = document.forms[a].elements;
		    
			// Loop through the array, building up the url
			// in the format '&name=value'
			for (var b = 0; b < formElements.length; b++)
			{
				var el = formElements[b];
				
				if (!el.disabled && el.name)
				{
					if (el.type == "radio" || el.type == "checkbox")
					{
						if (el.checked)
							returnString += "&" + escape(el.name) + "=" + escape(el.value);
					}
					else if (el.type == "select-multiple")
					{
						for (var c = 0; c < el.options.length; c++)
						{
							if (el.options[c].selected)
								returnString += "&" + escape(el.name) + "=" + escape(el.options[c].value);
						}
					}
					else if (el.name != "m")
					{
						returnString += "&" + escape(el.name) + "=" + escape(el.value);
					}
				}
			}
		}
	    
		// Add a timestamp so the url will be unique (to avoid cached calls)
		//returnString += "&ms=" + new Date().getTime();
		
		// Return the values
		return returnString;
	}
	
	/**
	 * Get the XmlHttpRequest object
	 */
	function getXmlHttpRequest()
	{
		var httpRequest;
		
		if (window.XMLHttpRequest)
			httpRequest = new XMLHttpRequest();
		else if (window.ActiveXObject)
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			
		return httpRequest;
	}
	
	/**
	 * Get the contents of the URL via an Ajax call
	 * url - to get content from (e.g. /struts-ajax/sampleajax.do?ask=COMMAND_NAME_1) 
	 * elementName - name of select list to populate
	 */
	this.loadSelect = function(url, elementName)
	{
		// Get the (form based) params to push up as part of the get request
		//url = url + this.getParameters();
		var parameters = getParameters();
 
		var httpRequest = getXmlHttpRequest();
		
		// Do the Ajax call
		httpRequest.open("post", url, true);	

		// KSA/SLD 05/01/2008 Online Catalog - Need to load additional parameters when onlineProductLine
		if (elementName == 'onlineProductLine')
			httpRequest.onreadystatechange = function(){processOnlineCatalogSelect(httpRequest, "productLine")};
		else
		if (elementName == 'lineInfo')
			httpRequest.onreadystatechange = function(){processOnlineCatalogLineSelect(httpRequest)};
		else
			httpRequest.onreadystatechange = function(){processSelect(httpRequest, elementName)};
		
      	httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      	httpRequest.setRequestHeader("Content-length", parameters.length);
    	httpRequest.setRequestHeader("Connection", "close");
	    httpRequest.send(parameters);
	}
	
	/**
	 * Set as the callback method for when XmlHttpRequest state changes
	 * httpRequest - XmlHttpRequest object
	 * elementName - name of select list to populate
	 */
	function processSelect(httpRequest, elementName)
	{
		if (httpRequest.readyState == 4) // Complete
		{
			if (httpRequest.status == 200) // OK response
			{
				var el = document.getElementsByName(elementName)[0];
				el.length = 0;
				
			  	if (httpRequest.responseText != "")
			  	{
				  	var options = httpRequest.responseText.split("!");
					
			  		for (var i = 0; i < options.length; i++)
			  		{
			  			var nodes = options[i].split("|");
			  			el.options.add(new Option(nodes[1], nodes[0]));
					}
				}
			}
		}
	}
	
	/**
	 * Set as the callback method for when XmlHttpRequest state changes
	 * httpRequest - XmlHttpRequest object
	 * elementName - name of select list to populate
	 */
	function processOnlineCatalogSelect(httpRequest, elementName)
	{
		if (httpRequest.readyState == 4) // Complete
		{
			if (httpRequest.status == 200) // OK response
			{
				var el = document.getElementsByName(elementName)[0];
				el.length = 0;
				
			  	if (httpRequest.responseText != "")
			  	{
				  	var options = httpRequest.responseText.split("!");
 					
			  		for (var i = 0; i < options.length; i++)
			  		{
			  			var nodes = options[i].split("|");
			  			
			  			// Load other page information for online catalog
			  			if (nodes[0] == 'pageNumber' || nodes[0] == 'catalogPagePath')
			  			{
			  				var el2 = document.getElementsByName(nodes[0]);
			  				el2[0].value = nodes[1];
			  			}
			  			else
			  			if (nodes[0] != "")
			  				el.options.add(new Option(nodes[1], nodes[0]));		// drop down option
					}
					
					buildAvailabilityRow();
				}
			}
		}
	}
	
	/**
	 * Set as the callback method for when XmlHttpRequest state changes
	 * httpRequest - XmlHttpRequest object
	 * elementName - name of select list to populate
	 */
	function processOnlineCatalogLineSelect(httpRequest)
	{
		if (httpRequest.readyState == 4) // Complete
		{
			if (httpRequest.status == 200) // OK response
			{				
			  	if (httpRequest.responseText != "")
			  	{
				  	var options = httpRequest.responseText.split("!");
					
			  		for (var i = 0; i < options.length; i++)
			  		{
			  			var nodes = options[i].split("|");
 			  			
			  			// Load other page information for online catalog
			  			if (nodes[0] == 'pageNumber' || nodes[0] == 'catalogPagePath')
			  			{
			  				var el2 = document.getElementsByName(nodes[0]);
			  				el2[0].value = nodes[1];
			  			}			  			
					}
					
					lineOrPageChange = "page";
					buildAvailabilityRow();
				}
			}
		}
	}
}