function createXmlHttpRequest() {
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	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;
		}
	}
	
	return xmlhttp;
}

function getXHTML(xmlhttp, url, elementId, waitIndicator) {
	var element = document.getElementById(elementId);
	
	if (element != null) {
		var waitElement = null;
	
		waitElement = document.getElementById(waitIndicator);
		waitElement.style.visibility = 'visible';
		
		xmlhttp.open("GET", url, true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState == 4) {
				element.innerHTML = xmlhttp.responseText;
				
				waitElement.style.visibility = 'hidden';
			}
		}
	
	 	xmlhttp.send(null);
 	}
}

var loggedinRequest = createXmlHttpRequest();
var unreadRequest = createXmlHttpRequest();
var lastUpdated = 0;

function refreshStatus() {
        var now = new Date().getTime();
	
	if (now - lastUpdated >= 25 * 1000) {
		getXHTML(loggedinRequest, 'LoggedInXML.php', 'loggedInList', 'loggedinWait');
		getXHTML(unreadRequest, 'UnreadXML.php', 'unreadList', 'unreadWait');
		lastUpdated = now;
	}
}

function initDynamicContent() {
	refreshStatus();
	setInterval('refreshStatus()', 30000);
}

