var xmlhttp;
var IE = document.all?true:false

/*
 * ajax handler for changing the state of an article
 * @param ID - the ID of the article to change
 * @param state - the new state 
 */
function change_article_state(ID, state) // calling the server
{
	if (window.XMLHttpRequest)
		xmlhttp = new XMLHttpRequest();
	else
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	var url = "antx_ajax.php"; // my php script that handles stuff
	url = url+"?action=change_article_state";
	url = url+"&ID="+ID;
	url = url+"&state="+state;
	url = url+"&sid="+Math.random();

	xmlhttp.open("GET",url,true);
	xmlhttp.myID = ID; // attach the ID to the xmlhttp object to pass it over to the callback function
	xmlhttp.onreadystatechange=change_article_state_2; // update call for the "placeholder"
	xmlhttp.send(null);
}
/* updating the html in the browser */
function change_article_state_2()
{
	if (xmlhttp.readyState==4)
		document.getElementById("article_"+xmlhttp.myID).innerHTML=xmlhttp.responseText;
}


/*
 * ajax handler for changing the state of a comment
 * @param ID - the ID of the comment to change
 * @param state - the new state 
 */
function change_comment_state(ID, state) // calling the server
{
	if (window.XMLHttpRequest)
		xmlhttp = new XMLHttpRequest();
	else
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	var url = "antx_ajax.php"; // my php script that handles stuff
	url = url+"?action=change_comment_state";
	url = url+"&ID="+ID;
	url = url+"&state="+state;
	url = url+"&sid="+Math.random();

	xmlhttp.open("GET",url,true);
	xmlhttp.myID = ID; // attach the ID to the xmlhttp object to pass it over to the callback function
	xmlhttp.onreadystatechange=change_comment_state_2; // update call for the "placeholder"
	xmlhttp.send(null);
}
/* updating the html in the browser */
function change_comment_state_2()
{
	if (xmlhttp.readyState==4)
		document.getElementById("comment_"+xmlhttp.myID).innerHTML=xmlhttp.responseText;
}
