var xmlHttp

function addComment(forum_topicid)
{	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	message = document.getElementById('message').value;
	if (message == "Write your comment here.") { alert("Please enter a comment."); }
	else {
	name = document.getElementById('name').value;
	  
	var url="addcomment.php"
	url=url+"?forum_topicid="+forum_topicid
	url=url+"&message="+message
	url=url+"&name="+name
	xmlHttp.onreadystatechange=showComments 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
}
	
function showComments() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert("Thanks for the feedback");
		document.getElementById('comments').style.display='';
		document.getElementById("thecomments").innerHTML=xmlHttp.responseText 
		window.location.hash="comments"; 
	} 
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
	 	xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
	 	{
	  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  	}
	 	catch (e)
	  	{
	  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	}
	return xmlHttp;
}
