var updatesString = '';
var commentsString = '';

/* Create the XMLHttpRequest */
xmlHttp = false;
try {
	xmlHttp = new ActiveXObject("Msxm2.XMLHTTP");
} catch (e) {
	try {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e2) {
		xmlHttp = false;
	}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
	xmlHttp = new XMLHttpRequest();

/* And the second one*/
xmlHttp2 = false;
try {
	xmlHttp2 = new ActiveXObject("Msxm2.XMLHTTP");
} catch (e) {
	try {
		xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e2) {
		xmlHttp2 = false;
	}
}
if (!xmlHttp2 && typeof XMLHttpRequest != 'undefined')
	xmlHttp2 = new XMLHttpRequest();



function sendCommentsRequest() {
	var url = "getComments.php";

	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = processComments;
	
	xmlHttp.send(null);
}

function sendUpdatesRequest() {
	var url = "getUpdates.php";

	xmlHttp2.open("GET", url, true);
	xmlHttp2.onreadystatechange = processUpdates;
	
	xmlHttp2.send(null);
}



function processComments() {
	commentsString = '';
	if (xmlHttp.readyState == 4)	{
		commentsString = xmlHttp.responseText;
		refreshComments();
	}
	setTimeout(sendCommentsRequest, 180000);
}

function processUpdates() {
	updatesString = '';
	if (xmlHttp2.readyState == 4)	{
		updatesString = xmlHttp2.responseText;
		refreshUpdates();
	}
	setTimeout(sendUpdatesRequest, 180000);
}



function refreshUpdates() {
	$('#updates-content').fadeOut("fast", function() {
		document.getElementById('updates-content').innerHTML = updatesString;
		$('#updates-content').fadeIn("fast");
	});
}

function refreshComments() {
	$('#comments-content').fadeOut("fast", function() {
		document.getElementById('comments-content').innerHTML = commentsString;
		$('#comments-content').fadeIn("fast");
	});
}
