function AjaxVote(id,i,rating_sum,rating_count,xid,counter)
{
	var div = document.getElementById('extravote_'+id+'_'+xid);
	div.innerHTML='<img src="images/rate_comments/loading.gif" border="0" align="absmiddle" /> '+'<small>Loading...</small>';
	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)
				{
					response = xmlHttp.responseText;
					//alert(response);
					if(response=='thanks')
					{
						div.innerHTML='<small>Thanks</small>';
						var newtotal = rating_count+1;
						var percentage = ((rating_sum + i)/(newtotal));
						document.getElementById('rating_'+id+'_'+xid).style.width=parseInt(percentage*20)+'%';
					}
					if(response=='voted')
					{
						div.innerHTML='<small>You already voted</small>';
					}
				}
			
			}
	  xmlHttp.open("GET","http://www.autotropolis.com/article.manager/modules/mod_articleRating/ajax.php?id="+id+"&i="+i+"&rating_sum="+rating_sum+"&rating_count="+rating_count+"&xid="+xid,true);
	  xmlHttp.send(null);
}
function viewComment()
{
	var status = document.getElementById("view_comment").style.display;
	if(status=="none")
		document.getElementById("view_comment").style.display = "inline";
	else
		document.getElementById("view_comment").style.display = "none";
}
function addComment()
{
	var status = document.getElementById("add_comment").style.display;
	if(status=="none")
		document.getElementById("add_comment").style.display = "inline";
	else
		document.getElementById("add_comment").style.display = "none";
}
function postComment()
{
	var articleId = document.getElementById("articleId").value;
	var name = trim(document.getElementById("name").value);
	var comment = trim(document.getElementById("comment").value);
	if( name=="" || comment=="" )
	{
		alert("Name and Comment fields must not be empty.");
	}
	else
	{
		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)
					{
						var response = xmlHttp.responseText;
						//alert(response);
						if(response=="already")
						{
							document.getElementById("view_comment").style.display = "none";
							document.getElementById("add_comment").style.display = "none";
							alert("You already comment this article");
						}
						else
						{
							document.getElementById("view_comment").innerHTML += response;
							document.getElementById("view_comment").style.display = "inline";
							document.getElementById("add_comment").style.display = "none";
						}
					}
				}
		  xmlHttp.open("GET","http://www.autotropolis.com/article.manager/modules/mod_articleRating/ajaxComment.php?name="+name+"&comment="+comment+"&articleId="+articleId,true);
		  xmlHttp.send(null);
	}
}