var ajaxweb;
var webfetchtimer = -1;

window.onload= function (evt) {
	window.top.ajaxweb = window.top.getXmlHttpRequestObject();
}

function ajaxerror(e1, et, e3) {
	if (e1 == null && et == null) {
		alert('Your browser does not appear to support AJAX.');
	} else {
		if (e1 == 500) {
			alert('You have encountered an error. This may be due to ongoing maintenance, if the problem persists after a refresh please contact support. Error at ' + e3 + ': ' + e1);
		} else if (window.top.ErrorsOn != 0) {
			alert('Ajax Error at ' + e3 + ': ' + e1 + ', ' + et);
		}
	}
}

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
	        try{ return new ActiveXObject("MSXML3.XMLHTTP") }catch(e){}
	        try{ return new ActiveXObject("MSXML2.XMLHTTP.3.0") }catch(e){}
	        try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
	        try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
	}
}

function closepm(w) {
	var oldpm = getObj(w);
	if (oldpm != null) {
		oldpm.parentNode.removeChild(oldpm);
	}
	oldpm = null;
	}


function RemoveDock2() {
}

function SetupDiv(id, pmWindowx, left, top, width, height, text) {
		pmWindowx.style.zIndex = 10010;
		pmWindowx.style.position = "absolute";
		pmWindowx.style.cursor = "pointer";
		pmWindowx.innerHTML =  text;
		pmWindowx.style.left = left;
		pmWindowx.style.top =  top;
		pmWindowx.style.width = width;
		pmWindowx.style.height = height;
		//AddWindow(id, left, top, pmWindowx, width, height);
	}

function newerror(err, responsetext, u) {
	var txt = '';
	txt="Name: " + err.name + " (" + err.message + ", " + err.number + ")\n\nError description: " + err.description + "\n\n" + responsetext;
//	txt+="\n\nName: " + e.name + " (" + e.message + ", " + e.number + ")\n\nError description: " + e.description;
	alert(txt)
}

function WebFetch(URL) {
	clearTimeout(webfetchtimer);
	webfetchtimer = setTimeout(function Anonymous() {sendFetch(URL)}, 1000);
}


function sendFetch(doc){
	clearTimeout(webfetchtimer);
	if (ajaxweb != null) {

	        try {
			if (ajaxweb.readyState != 0) {
				ajaxweb.abort(); 
			}
		} catch(e) {
		}			

		ajaxweb.open('GET','' + doc + (doc.match(/\?/) == null ? "?" : "&") + (new Date()).getTime(),true);
		ajaxweb.setRequestHeader("Cache-Control", "no-cache");
		ajaxweb.setRequestHeader("Pragma", "no-cache");
		ajaxweb.onreadystatechange = function(){
 
			if (ajaxweb.readyState == 4 && ajaxweb.status == 200) {
 
				if (ajaxweb.responseText){
					var rt = ajaxweb.responseText;
				        try {
						var r = eval(rt);
					} catch(e) {
						newerror(e, rt, doc);
					}
				}
			} else if (ajaxweb.readyState == 4 && ajaxweb.status != 200) {
				ajaxerror(ajaxweb.status, ajaxweb.statusText + ' ' + ajaxweb.responseText, 'Routine 4b');
			}
		};


		ajaxweb.send(null);
	} else {
		//ajaxerror(null, null, 'Routine 4');
	}
}	