/* Js Document */
function addComment(game_id, comment, userid){
	var flag=0;
	if(game_id <= 0){
		alert('Invalid game specified!');
		flag=1;
	}
	if(trim(comment)=="" || trim(comment)==trim("Enter your message here (255 characters or less)") || trim(comment)=="hi"){
		alert('Please enter some text for your message.');
		flag=1;
	}
	if(comment.length > 255){
		alert('Your message is ' + comment.length + ' characters long. It should be 255 characters or less. Please enter a shorter message!');
		flag=1;
	}
	var xmlHttp;
	if(flag==0){
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)
      {
		  	document.getElementById('review_div').innerHTML="";
	      document.getElementById('review_div').innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","add_comment.php?gameid="+game_id+"&comment="+comment+"&userid="+userid,true);
  xmlHttp.send(null);  
	}
}
//Trim the space in the given string
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

