// JavaScript Document
	 var ajax = new GLM.AJAX();
	 var str;
	 var userID;
	 function ajaxCallback(content)
	  {
        return;
		//alert(content); //displays the contents of the page.
		//showAllComments();
	  }
		  
	  function showBox(id)
	  {
				document.getElementById(id).style.display = 'block';
				document.getElementById(id).style.visibility = 'visible';
	  }
	  function hideBox(id)
	  {
				document.getElementById(id).style.display = 'none';
				document.getElementById(id).style.visibility = 'hidden';
				document.getElementById("txt"+id).value = "";
	  }
	  function postReply(id)
	  {
			str='';
			userID = '';
			userID = document.getElementById('curUID').value;
			
			str = "CommentID="+id+"&ReplyText="+document.getElementById('txt'+id).value + "&V_UserID=" + userID;
			ajax.callPage(path+"ajaxArticleComments.php?action=reply", ajaxCallback, "POST" , str);
			hideBox(id);
			showAllComments();
	  }
   
	  function postComment(id)
	  {
	    str='';
		userID = '';
		userID = document.getElementById('curUID').value;
		
		str = "articleid="+id+"&CommentText="+ document.getElementById('userComment').value + "&V_UserID=" + userID+"&lang_id="+document.getElementById('LanguageID').value;
		ajax.callPage(path+"ajaxArticleComments.php?action=comment", ajaxCallComment, "POST" , str);
		document.getElementById('userComment').value = "";
		}
	  function ajaxCallComment(content)
	  {
        //return;
		//alert(content); //displays the contents of the page.
		showAllComments();
		
	  }
	  //To show all the comments in the AllComment div at each operation
	  function showAllComments()
	  {
		str='';
		str = "ArticleID="+document.getElementById('articleid').value;
		ajax.callPage(path+"ajaxArticleComments.php", ajaxShowComment, "POST" , str);
	  }
	  function ajaxShowComment(content)
	  {
	     //alert(content);
		 document.getElementById('AllComments').innerHTML = content;
		 totalComments = document.getElementById('totalComments').innerHTML;
		 document.getElementById('showComments').innerHTML = totalComments;
	  }
	  
	  function addToFavorites(aid)
	  {
			str = '' ;
			userID = '';
			userID = document.getElementById('curUID').value;
			
			if(userID == "")
			{
				alert("Please login to add this article into your favorites.");
				return;
			}
			else
			{
				
				str = "action=favorites&aid="+aid+"&userID="+userID;
				ajax.callPage(callpage, ajaxAddToFavorites, "POST" , str);
			}
	  }
	  function ajaxAddToFavorites(content)
	  {
	    alert(content);	
	  }
	  
	  function reportAbuse(aid)
	  {
	  	 //alert(aid);
		userID = '';
		userID = document.getElementById('curUID').value;
		if(userID == "")
		{
		  alert("Please login for reporting abuse article");
		  return;
		}
		else
		{
		 ajax.callPage(path+"ajaxArticleComments.php?action=abuse&aid="+aid, ajaxReportAbuse);
		}
	  }
	  function ajaxReportAbuse(content)
	  {
	    if(content)
		{
			alert(content);
		}
	  } 
	  
	  function getTotalRating()
	  {
			aid = document.getElementById('articleid').value;
			str = "action=trating&aid="+aid;
			ajax.callPage(callpage, ajaxTotalRating, "POST" , str);
	  }
		
	  function ajaxTotalRating(content)
	  {
			var rdata = content.split(':');
			var str = "";
			//alert(image); return;
			//alert(rdata[0]+rdata[1]);
			var num = rdata[0];
			for(i=1;i<=5;i++)
			{
				if(i<=num)
					str += "<img src='"+imagepath+"star_f.gif'>";
				else
					str += "<img src='"+imagepath+"star_empty.gif'>";
			}
			document.getElementById('totalRating').innerHTML = str ;
			document.getElementById('ratingCount').innerHTML =  rdata[1] ;
			if(rdata[1] > 0)
			{
				showBox('ratingHide');
			}
	  }
	  
	  
function reportUsefull(aid)
{
	userID = '';
	userID = document.getElementById('curUID').value;
	if(userID == "")
	{
		alert("Please login to send your feedback");
		return;
	}
	else
	{
	 ajax.callPage(path+"ajaxArticleComments.php?action=usefull&aid="+aid, ajaxReportUsefull);
	}
	}
	function ajaxReportUsefull(content)
	{
		if(content)
	{
		alert(content);
	}
}

function check_blank()
{
  var error='';
	if(document.getElementById('anonymous_name').checked == true )
  {
			if (trimAll(document.frm_poll.Name.value) == "")
      {
           error = "Please enter Name as Anonymous Identity. \n";
      }
  }
  if ( trimAll(document.frm_poll.Comment.value) == "")
  {
    error += "Please enter Comment.";
	}
	
	if(error != '')
	{
			alert(error);
			return false;
	}
  else
  {
    return true;
  }
}

	  
