function submitComment()
{
	var name=document.getElementById('name').value;
	var title=document.getElementById('title').value;
	var commentToTest=document.getElementById('comment').value;
	var comment=document.getElementById('comment').value;
	for(var i=1; i<100; i++){
		comment=comment.replace("&", "and");
		name=name.replace("&", "and");
		title=title.replace("&", "and");
	}
	var commentArray=commentToTest.split(' ');
	var thisWord='';
	for(var i=0; i<commentArray.length; i++){
		thisWord=commentArray[i];
		if(thisWord.length>50){
			alert('No word can be more than 50 Characters.');
			comment='Write Your Comment';
			document.getElementById('comment').value='Write Your Comment';
			thisWord='';
			return false;
			
		}
	}
	var country=escape(document.getElementById('country').value);
	var i=escape(document.getElementById('i').value);
	if(name!='' && title!='' && comment!='Write Your Comment'){
		var tr = document.getElementById('commentstable').insertRow(-1);
		var td = tr.insertCell(-1);
		if((i%2)==0){
			td.className='roweven';
		}
		else {
			td.className='rowodd';
		}
		var xmlHttp;
		try
	    {
	    // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	    }
	  	catch (e)
	    {
	    // Internet Explorer
	    try
	      {
	      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      }
	    catch (e)
	      {
	      try
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	      catch (e)
		{
		alert("Your browser does not support AJAX!");
		return false;
		}
	      }
	    }
	    xmlHttp.onreadystatechange=function()
	      {
	      if(xmlHttp.readyState!=4){
	      }
	      if(xmlHttp.readyState==4)
			{
			td.innerHTML = xmlHttp.responseText;
			document.getElementById('name').value='';
			document.getElementById('title').value='';
			document.getElementById('country').value='';
			document.getElementById('comment').value='Write Your Comment';
			i=parseInt(i);
			document.getElementById('i').value=i+1;
			}
	    }
	    url="addcomment.php?name="+name+"&title="+title+"&comment="+comment+"&country="+country;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	  }
	  else{
	  	alert('All fields are required, please fill in all fields');
	  }
}
