 
function addcomments_ajax(cname,cmail,cdesc,ans_id,comment_url,comment_action,comment_submited,comment_questonid,answerblock,comment_captcha)
{	
	//comment_process_q_
	if(ans_id == "" || ans_id == '0')
		que_ans_id = '_q_'+comment_questonid;
	else
		que_ans_id = ans_id;
	
	document.getElementById("comment_process"+que_ans_id).style.visibility = "visible";
	document.getElementById("comment_process"+que_ans_id).style.display = "block";
	document.getElementById("comment_responce"+que_ans_id).style.visibility = "hidden";
	document.getElementById("comment_responce"+que_ans_id).style.display = "none";
	
	if(answerblock == "") answerblock = 0;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url=comment_url+"/askquestion/questionanswerajax.php";
	url=url+"?commentName="+cname+"&commentEmail="+cmail+"&commentDesc="+cdesc+"&answerid="+ans_id+"&hdnaction="+comment_action+"&hdnsubmited="+comment_submited+"&hdnquestionid="+comment_questonid+"&commentcaptcha="+comment_captcha;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function stateChanged()
	{
		if (xmlHttp.readyState==4)
		{ 
	
		  if(xmlHttp.responseText != "") 
		  {
		  	
		  
		  	document.getElementById("comment_process"+que_ans_id).style.visibility = "hidden";
			document.getElementById("comment_process"+que_ans_id).style.display = "none";
			document.getElementById("comment_responce"+que_ans_id).style.visibility = "visible";
			document.getElementById("comment_responce"+que_ans_id).style.display = "block";
			
			var str1 = xmlHttp.responseText;
			
		  	if(str1.indexOf("Error") >= 0)
		  	{
			  	alert(str1);
			  	return;
		  	}
		   	alert("Your comment is inserted successfully");
		   		
		   	
		   	
		   		   	
		   	if(ans_id == "")ans_id = 0;
		  	if(ans_id == 0) {
		  		if(xmlHttp.responseText != "")
		  			document.getElementById("commentshow").innerHTML = xmlHttp.responseText;
		  		document.getElementById("commentshow").style.visibility = "hidden";
		  		document.getElementById("commentshow").style.display = "none";
		  		
		  		showhide_comment('');
		  		
		  	}
		  	else {
		  		if(xmlHttp.responseText != "")
		  			document.getElementById("commentshow"+ans_id).innerHTML = xmlHttp.responseText;
		  			
		  		document.getElementById("commentshow"+ans_id).style.visibility = "hidden";
		  		document.getElementById("commentshow"+ans_id).style.display = "none";
		  		showhide_comment(ans_id);
		  	
		  	}
		  		
		  	displayblock(answerblock);
		  	if(answerblock == 0 )answerblock = "";
		  	document.getElementById("clsmanagequestion_commentName"+answerblock).value = "";
		  	document.getElementById("clsmanagequestion_commentEmail"+answerblock).value	= "";
		  	document.getElementById("clsmanagequestion_commentDesc"+answerblock).value	= ""
		  	document.getElementById("clsmanagequestion_captcha"+answerblock).value	= ""
		  }
	  
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
} 
	
function rate_answer(ratecount,comment_answerid,comment_questonid,comment_action,comment_submited,comment_url,URLImage)
{
	
		
	document.getElementById("div_process"+comment_answerid).style.visibility = "visible";
	document.getElementById("div_process"+comment_answerid).style.display = "block";
	document.getElementById("responcelist"+comment_answerid).style.visibility = "hidden";
	document.getElementById("responcelist"+comment_answerid).style.display = "none";
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url=comment_url+"/askquestion/questionanswerajax.php";
	url=url+"?answerid="+comment_answerid+"&hdnaction="+comment_action+"&hdnsubmited="+comment_submited+"&hdnquestionid="+comment_questonid+"&rate="+ratecount;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=function stateChanged(){
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("div_process"+comment_answerid).style.visibility = "hidden";
		document.getElementById("div_process"+comment_answerid).style.display = "none";
		document.getElementById("responcelist"+comment_answerid).style.visibility = "visible";
		document.getElementById("responcelist"+comment_answerid).style.display = "block";
	
	  if(xmlHttp.responseText != "")
	  {	  	
	  	var str1 = xmlHttp.responseText;
	
	  	if(str1.indexOf("You have already rated") >= 0)
	  	{
		  	alert(str1);
		  	return;
	  	}
		  	
	
		  	
	  	alert("Thank you for ratting this answer");
	  	
	  	var arrString = str1.split(",");
	  	var replyid = arrString[0];
	  	var rattingavg = arrString[1];
	
	  	var rattingcount = arrString[2];
	  	var countratting = "<span id='ratecount_"+replyid+"'>(current rating : <strong>"+rattingavg+" / 5 </strong> with <strong>"+rattingcount+"</strong> votes)</span>";
	  	document.getElementById("ratecount_"+comment_answerid).innerHTML = countratting;
	  	var arrRatting = new Array();;
	  	
	  	for(i=1;i<=5;i++)
	  	{
	  		if(Math.floor(rattingavg) >= i)
    		{
        		arrRatting[i] = "ratingstar_fill";
        		
        	}
	    	else if(Math.ceil(rattingavg) == i)
	    	{
	    		arrRatting[i] = "rating_halffill";
	    		//document.getElementById("rate_img" + i + "_"+comment_answerid).src = arrRatting[i] ;
	    	}
            else 
            {
                arrRatting[i] = "ratingstar_blank";
              //  document.getElementById("rate_img" + i + "_"+comment_answerid).src = arrRatting[i] ;
            }
            document.getElementById("rate_img" + i + "_"+comment_answerid).src = URLImage+arrRatting[i]+".gif" ;
            document.getElementById("rate_img" + i + "_"+comment_answerid).alt = arrRatting[i] ;
	  	}
                
	  	
	  	
	  
	  	
	  }
	 
 
   
   displayblock(answerblock);
	
	
	}}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

} 

function reportAbuse(questionid, answerid ,comment_url ) 
{	
	if(answerid == "")
		var queansid = "_q_"+questionid;
	else
		var queansid = answerid;
	
	document.getElementById("process_abuse"+queansid).style.visibility = "visible";
	document.getElementById("process_abuse"+queansid).style.display = "block";
	document.getElementById("responseabuse"+queansid).style.visibility = "hidden";
	document.getElementById("responseabuse"+queansid).style.display = "none";
	xmlHttp=GetXmlHttpObject();
	submited = 1;
	
	
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url=comment_url+"askquestion/qareportabuse.php";

	if (confirm("Are you sure you want to flag this comment as offensive or inapproriate?")) 
	{	
			
		url=url+"?questionid="+questionid+"&replyid="+answerid+"&abusereported=Y";
		url=url+"&sid="+Math.random();

		xmlHttp.onreadystatechange=function stateChanged()
		{
			if (xmlHttp.readyState==4)
			{
				if(xmlHttp.responseText != "" )
				{	
					document.getElementById("process_abuse"+queansid).style.visibility = "hidden";
					document.getElementById("process_abuse"+queansid).style.display = "none";
					document.getElementById("responseabuse"+queansid).style.visibility = "visible";
					document.getElementById("responseabuse"+queansid).style.display = "block";	
								
					var response = (xmlHttp.responseText == 1)? "Your request has been submited.":"Sorry we can not abuse this question/answer";
					alert(response);
					//document.getElementById("ratecount_"+comment_answerid).innerHTML = xmlHttp.responseText;
				}
			
			}
		}
	}
	else
	{
		document.getElementById("process_abuse"+queansid).style.visibility = "hidden";
		document.getElementById("process_abuse"+queansid).style.display = "none";
		document.getElementById("responseabuse"+queansid).style.visibility = "visible";
		document.getElementById("responseabuse"+queansid).style.display = "block";
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
	
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;
} 

