var xmlHttp1

function addComment()
{

	var comment =document.productForm.comment.value;
	var path =document.productForm.path.value;
	var pid =document.productForm.pid.value;
	comment = comment.replace(/\n/g,"<br/>").replace(/\r/g,"");
	//comment = comment.replace(/\n\r?/g, '<br />');
	//alert(comment);

	var url=path+"index.php?option=com_jegroupbuy&view=jegroupbuy&task=addComments";
	url=url+"&comment="+comment+"&pid="+pid+"&tmpl=component";
	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttp1.onreadystatechange= stateChanged;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);
}

function stateChanged()
{
	if (xmlHttp1.readyState==4)
	{
		if (xmlHttp1.status == 200)
		{
			var response = xmlHttp1.responseText;
			document.getElementById("commentContainer").innerHTML = response;
			document.productForm.comment.value = "";
		}
	}
}

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

}
