var req;

function loadXMLDoc(url) {
	req = false;
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest) {
		try {
			req = new XMLHttpRequest();
		} catch(e) {
			req = false;
		}
	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = false;
			}
		}
	}
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}

function processReqChange() {
	// only if req shows "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			eval(req.responseText);
			setTimeout("loadXMLDoc('../private/ajaxMessaging.asp');", 31000);
		} else {
			window.status = "Error communicating with the server.  Please re-load this page and retry your last action.";
		}
	}
}

function OpenPopupCentered(strURL,intWidth,intHeight,blnResizable) {
	if (blnResizable == true) {
		window.open(strURL,'','width=' + intWidth + ',height=' + intHeight + ',left=' + ((window.screen.availWidth / 2) - (intWidth / 2)) + ',top=' + ((window.screen.availHeight / 2) - (intHeight / 2)) + ',toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes')
	} else {
		window.open(strURL,'','width=' + intWidth + ',height=' + intHeight + ',left=' + ((window.screen.availWidth / 2) - (intWidth / 2)) + ',top=' + ((window.screen.availHeight / 2) - (intHeight / 2)) + ',toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no')
	}
}

function OpenDocumentCentered(strURL,blnResizable) {
	if (blnResizable == true) {	
		window.open(strURL,'','width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100) + ',left=50,top=25,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes')
	} else {
		window.open(strURL,'','width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100) + ',left=50,top=25,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=no')
	}
}

function OpenLinkCentered(strURL) {
	window.open(strURL,'','width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 200) + ',left=50,top=20,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes')
}

function hideSelectState() {
	document.getElementById('map').style.display="none";
}

function ResizeMe(intWidth,intHeight)
{
	//only use left half for 2048 (rdp users)
	if (window.screen.availWidth == 2048) {
		intAvailWidth = 1024
	} else {
		intAvailWidth = window.screen.availWidth
	}
	
	window.resizeTo(intWidth,intHeight);
	window.moveTo((intAvailWidth / 2)-(intWidth / 2),(screen.availHeight / 2)-(intHeight / 2));
}