window.onload = init;

function init() {
	updateContent('getContent.php?atable=blpoote&ctable=blcompoote&page=first','content');
}

var xmlhttp;

if (window.XMLHttpRequest)	{
	xmlhttp = new XMLHttpRequest(); // Firefox, Opera, Konqueror, Safari, ...
} else if (window.ActiveXObject) {
	xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); // Internet Explorer
} else {
	alert('JavaScript : Your broswer does not allow XML HTTP Request Objects ...'); // Old browser
}

function updateContent(fragment_url, element_id) {
	document.getElementById('comments').style.display = "block";
	if (element_id != 'comments') {
		document.getElementById('comments').style.display = "none";
	}
	var element = document.getElementById(element_id);
	element.innerHTML = 'Loading ...';
	xmlhttp.open("GET", fragment_url);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			element.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

function doAddComment() {
	var nickname = document.commentForm.nick.value;
	var updateText = document.commentForm.updatetxt.value;
	var post_id = document.commentForm.id.value;
	var comtable = document.commentForm.commiez.value;
	var sendstring = 'maincom.php?nick='+nickname+'&updatetxt='+updateText+'&id='+post_id+'&commiez='+comtable+'&edit=comment';
	updateContent(sendstring,'comments');
}