
// Creates an XMLHttpRequest object.
function getRequest()
{
	var request = false;
	try 
	{	// Non-microsoft
		request = new XMLHttpRequest();
	} 
	catch (trymicrosoft) 
	{
		try 
		{
			// Internet Explorer 6
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (othermicrosoft) 
		{
			try 
			{	// Internet Explorer 5.5 and later
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (failed) 
			{
				request = false;
			}
		}
	}
	return request;
}

//  Strips leading and trailing spaces of a string.	 
function trim(s) 
{
	s = s.replace(/^\s+/g, "");
	s = s.replace(/\s+$/g, "");
	return s;
}

// Returns the parameter value from query string.
// If no such parameter exists, null is returned.
// This function will NOT work on a POST request.
// This currently works for internal documents only!
function getParameter(parameterName)
{
	//window.top.location.search.substring(1);
	var queryString = document.location.search.substring(1);
	var parameterName = parameterName + "=";

	if (queryString.length > 0)
	{
		begin = queryString.indexOf(parameterName);
		if (begin == -1) return "null";
		begin += parameterName.length;
		end = queryString.indexOf("&", begin);
		if (end == -1) end = queryString.length;		 
		return unescape(queryString.substring(begin, end));
	}
}

// Returns the trimmed value of page element.
function id(name)
{
	return trim(document.getElementById(name).value);
}

// Sets the inner HTML value of a <div> tag.
function setInnerHtml(id, value)
{
	document.getElementById(id).innerHTML = value;
}

	// Sets the value of a document element.
	// @id		Element id
	// @attribute 	Attribute name
	// @value	New attribute value
	function setAttribute(id, attribute, value)
	{
		document.getElementById(id).setAttribute(attribute, value);
	}	