﻿window.onload = function() {
	httpObjBlog = createXMLHttpRequest(displayBlog);
	httpObjTweet = createXMLHttpRequest(displayTweet);
	if (httpObjBlog && httpObjTweet) {
		httpObjBlog.open("GET", "http://www.another-square.com/blogarticle.php", true);
		httpObjBlog.send(null);
		httpObjTweet.open("GET", "http://www.another-square.com/tweet.php", true);
		httpObjTweet.send(null);
	}
}

function displayBlog() {
	if ((httpObjBlog.readyState == 4) && (httpObjBlog.status == 200)) {
		document.getElementById("blogarticle").innerHTML = httpObjBlog.responseText;
	} else {
		document.getElementById("blogarticle").innerHTML = "\n\t\t\t<img src=\"http://www.another-square.com/img/ajax-loader.gif\" alt=\"Loading...\" /><br />\n\t\t\t";
	}
}

function displayTweet() {
	if ((httpObjTweet.readyState == 4) && (httpObjTweet.status == 200)) {
		document.getElementById("tweet").innerHTML = httpObjTweet.responseText;
	} else {
		document.getElementById("tweet").innerHTML = "\n\t\t\t<img src=\"http://www.another-square.com/img/ajax-loader.gif\" alt=\"Loading...\" /><br />\n\t\t\t<a href=\"http://twitter.com/ipv4\" target=\"_blank\">follow me on Twitter</a><br />\n\t\t\t";
	}
}