var xmlHttp;
var id;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function printContent(url, div_id) {
	if (url != '') {
		document.write('<div id="'+div_id+'" style="clear:both;margin:auto;height:auto;"></div>');
		id = div_id;
		
		createXMLHttpRequest();
		var xml_url = "/ajax_open.php?url=" + escape(url);
		xmlHttp.open("GET", xml_url, true);
		xmlHttp.onreadystatechange = getContent;
		xmlHttp.send(null);
	}
}

/*
	Get content from XML
*/
function getContent() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var content = xmlHttp.responseXML.getElementsByTagName("contents")[0].firstChild.data;
			setContent(xmlHttp.responseXML.getElementsByTagName("content"));
		}
	}
}

/*
	Print the content at the site
*/
function setContent(contents) {
	var size = contents.length;

	for (var i = 0; i < size; i++) {
		document.getElementById(id).innerHTML += contents[i].firstChild.data;
		/*document.write(contents[i].firstChild.data);*/
	}
}
	
