var contentHandler = new TagHandler(null); 
var objAjax = null;

function Ajax(tagName,url) {
	//do {
	//} while (objAjax);

	objAjax = createXMLHttpRequest();
	objAjax.open('get', url);
	objAjax.onreadystatechange = responseHandler;
	contentHandler.tagName = tagName;
	setTimeout ('objAjax', 500);
	objAjax.send(null); 
}


function createXMLHttpRequest(){
	try { return new XMLHttpRequest(); } catch(e) {}
	try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {}
	try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) {}
	return null;

}

function TagHandler(tagName)
{
	var tagName;
	return tagName;
}

function responseHandler() {
	var objCurrent = document.getElementById(contentHandler.tagName)

	if(objAjax.readyState == 0) { objCurrent.innerHTML = 'Loading.'; }
	if(objAjax.readyState == 1) { objCurrent.innerHTML = 'Loading..'; }
	if(objAjax.readyState == 2) { objCurrent.innerHTML = 'Loading...'; }
	if(objAjax.readyState == 3) { objCurrent.innerHTML = 'Loading....'; }

	if(objAjax.readyState == 4)
	{
		if(objAjax.status == 200)
		{
			objCurrent.innerHTML = '';
			var updateContent = objAjax.responseText;
			if(updateContent) {
				objCurrent.innerHTML = updateContent;
			}
		}
		else if(objAjax.status == 404)
		{
			// Retrive error message or redirect to error page
			objCurrent.innerHTML = 'File not found';
		}
		else
		{
			// Give a catch all error message
			objCurrent.innerHTML = 'We are currently experiencing technical difficulties and are addressing the issue.';
		}

		//set a tabindex to - 1 to help screen readers focus on the changed content. Then set the focus to the changed content.
		objCurrent.tabIndex = -1;
		objCurrent.focus();
	}
}