function GetXmlHttpObject(handler)
{   var objXMLHttp=null
	 if (window.XMLHttpRequest)
	 {
		objXMLHttp=new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject)
	 {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	 return objXMLHttp;
}

function stateChanged_test()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		/*document.getElementById("show_comment_table").innerHTML=xmlHttp.responseText;
		document.getElementById("txt_comment").value = '';
		var val = document.getElementById("comment_value").innerHTML;
		var vval = Number(val);
		document.getElementById("comment_value").innerHTML = ++vval ;*/
		var str = xmlHttp.responseText;
		temp = str.split('#123#');		
		document.getElementById("security_code").value="";		
		document.getElementById('notposting').innerHTML=temp[0];		
		if(temp[1] != undefined)
		{
			document.getElementById("show_comment_table").innerHTML=temp[1];
		}
		document.getElementById("txt_comment").value="";
		var val = document.getElementById("comment_value").innerHTML;
		var vval = Number(val);
		document.getElementById("comment_value").innerHTML = ++vval ;

	}
}

function post_article_comment(path)
{
	if(document.post_comment.txt_comment.value.length<=0)
	{
		alert("Please enter Comment !");
		document.post_comment.txt_comment.focus();
		return false;
	}
	
	if(document.post_comment.txt_comment.value.length>= 256)
	{
		alert("Too Big Comment ! Only 255 Characters are allowed");
		document.post_comment.txt_comment.focus();
		return false;
	}
	if(document.getElementById("security_code").value.length<=0)
	{
		alert("Enter the security code!");
		document.getElementById("security_code").focus();
		return false;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"article/article_comment_insert.php"
	
	var urls="id="+document.post_comment.article_id.value;
	urls=urls+"&comment="+document.post_comment.txt_comment.value;
	urls=urls+"&captcha="+document.getElementById("security_code").value;
	urls=urls+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_test; 

	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.send(urls);
}
