var xmlhttp = null;
function sendRequest()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	var commentator = document.getElementById('commentator').value;
	var email = document.getElementById('email').value;
	var key = document.getElementById('key').value;
	var pid = document.getElementById('pid').value;
	var verify = document.getElementById('verify').value;
	var comment = document.getElementById('comment').value;
	var url="/modules/article/comment.php?pid="+pid;
	var params="";
	params=params+"commentator="+commentator;
	params=params+"&key="+key;
	params=params+"&email="+email;
	params=params+"&verify="+verify;
	params=params+"&comment="+comment;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	document.getElementById('comment').value="";
	document.getElementById('verify').value="";;
	if(commentator!=1)
	{
		var temp=getRand();
	}
}
function getRand()
{
	var key = Math.floor( Math.random() * 10000);
	document.getElementById("captcha").innerHTML='<img src="verify.php?mode=create&key=' + key + '" width="77" height="20" onclick="getRand()" />';
	document.getElementById("secretkey").innerHTML='<input type="hidden" name="key" value="'+ key +'" id="key" />';

}
function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("txtComments").innerHTML=xmlhttp.responseText;
	}
}
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{// code for IE6, IE5
	return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
