function createRequestObject()
{
	var xmlhttp = false;
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && new ActiveXObject("Microsoft.XMLHTTP")) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp=false;
		}
	}
	return xmlhttp;
}

function removeAllChildren(targetElement) {
    if (targetElement && targetElement.childNodes) {
        for (var rloop = targetElement.childNodes.length -1; rloop >= 0 ; rloop--) {
            targetElement.removeChild(targetElement.childNodes[rloop]);
        }
    }
}

/*
	this function may be set as the onkeypress event for the suggest fields
	it supresses them from submitting the form they are contained by when a user hits
	the enter on one of the suggested options
*/
function disableEnterKey(e)
{
	var key;

	if(window.event)
	{
		key = window.event.keyCode;     //IE
	}
	else
	{
		key = e.which;     //firefox
	}
	if(key == 13)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function ajaxRequest(url, f){
	r = createRequestObject();
	r.open("GET",url,true);
	r.onreadystatechange = function(){if(r.readyState==4){ f(r.responseText) }} ;	//Thanks, javascript closures!
	r.send(null);
	return r;
}

function ajaxReplace(url, el){
	ajaxRequest(url, function(t){el.innerHTML=t;});
}