

function getAjaxObject(){
	var l_xmlhttp;
	//returns either a valid XMLHttpRequest object or null
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		l_xmlhttp=new XMLHttpRequest();
		return l_xmlhttp;
	}
	else if (window.ActiveXObject){
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		return l_xmlhttp;
	}
	else{
		alert("Your browser does not support XMLHTTP!");
		return null;
	}
}

function testAjaxStatus(a_xmlhttp){
	var l_strMessage = "Ajax request status: " + a_xmlhttp.status + "\n"
	//test the status
	switch(a_xmlhttp.status){
	case 200:
		//every thing was ok
		return true
		break
	case 301:
		//access denied
		l_strMessage += "The URL has been moved permanently."
		break
	case 302:
		//access denied
		l_strMessage += "The request was redirected to another URL/URI."
		break
	case 305:
		//access denied
		l_strMessage += "Use Proxy (the request must use a proxy to access the resource requested)"
		break
	case 404:
		//url not found
		l_strMessage += "Requested URL is not found."
		break
	case 403:
		//access denied
		l_strMessage += "Access to the URL, was denied."
		break
	case 405:
		//access denied
		l_strMessage += "Unacceptable request method."
		break
	case 407:
		//access denied
		l_strMessage += "Proxy authentication is required."
		break
	default:
		//http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
		l_strMessage += "Un handled error.\n\n"
		l_strMessage += "For info. see: 'http://en.wikipedia.org/wiki/List_of_HTTP_status_codes'"
		break
	}
	//alert(l_strMessage)
	//code has run to here, so return the message
	return l_strMessage

}
