// JavaScript Document
var xmlHttp;




function ratethis(type,id,point,contid,sememid,memid,positive,negative)
{ 
	  
	  if(type==='positive')
	  {
			
		  type ='1';
		  newpoint=parseInt(point)+parseInt(1);
		 // positive=parseInt(positive)+parseInt(1);
					
					  
	  }
				  
	  else if(type==='negative')
	  {
					
		   type='-1';
		   newpoint=parseInt(point)-parseInt(1);
		  // negative=parseInt(negative)-parseInt(1);
					  
					
	  }

		
	  if(sememid===memid)
	  {


	  	  alert("You cannot rate this because this comment is moderaterd by you.");
		  return;
					
	  }
	  
	  	
	  
	  
xmlHttp = GetXmlHttpObject();

  if (xmlHttp==null)
  {
  
	  alert ("Your browser does not support AJAX!");
	  return;
	  
  } 


var url="ratecomment.php";
url=url+"?type="+type;
url=url+"&commentid="+id;
url=url+"&contid="+contid;
url=url+"&points="+point;

url=url+"&pv="+positive;
url=url+"&nv="+negative;

url=url+"&sid="+Math.random();
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

xmlHttp.onreadystatechange=statechange;

	function statechange()
	{ 
	              /* positive=	document.getElementById("pp").value ;
	                 negative=	document.getElementById("nn").value ;
	                 alert(positive);
					alert(negative);*/
		
	//alert(xmlHttp.responseText);
	var ghq=xmlHttp.responseText;
	      
			if (xmlHttp.readyState==4)
			{
		
				
				     if(ghq!="-1")
					 {
			
					 	
					var 	responce=xmlHttp.responseText.split("|");
					 	/*document.getElementById(id).innerHTML=responce[0]; 
					 	 document.getElementById('pn'+id).innerHTML=responce[1] ;
					*/
	               
	                  document.getElementById(id).innerHTML=responce[1] ;
					
									  					
				
					 
					 }
				
					 if(ghq==="-1")
					 {
					 	

					 	alert("You have already rated this comment"); 
					 	return;
					 
					 
					 }
			
			}
		
		
		
	
	}



}//ratethis

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;

}

