// JavaScript Document

function PostComment(field, item_id, location){
	xmlHttpS=GetXmlHttpObject();
	var url="/../front_end_ajax.php";
	url=url+"?toDo=PostComment"
	url=url+"&field="+field
	url=url+"&item_id="+item_id
	url=url+"&name="+document.getElementById('comment_name').value
	url=url+"&comment="+(document.getElementById('comment_body').value).replace(/\n/g, '<br>');
	url=url+"&email="+document.getElementById('comment_email').value
	url=url+"&url="+document.getElementById('comment_url').value
	url=url+"&item_permalink="+location;
	
	url=url+"&sid="+Math.random()
	xmlHttpS.open("GET",url,true)
	xmlHttpS.onreadystatechange=function () {
		if (xmlHttpS.readyState==4 || xmlHttpS.readyState=="complete") { 
			var temp = new Array();
			temp= xmlHttpS.responseText.split("~*^*~");
			if(temp[0]==0){
				document.getElementById('commentArea').innerHTML=temp[1];
				document.getElementById('errorArea').innerHTML="Thank you for your comment";
				document.getElementById('comment_name').value="";
				document.getElementById('comment_email').value="";
				document.getElementById('comment_body').value="";
				document.getElementById('comment_url').value="";
			}
			else {
				document.getElementById('errorArea').innerHTML=temp[1];
			}
		}
	}
	xmlHttpS.send(null);
	
}

function update_ranking(level,blog_id){
	xmlHttpS=GetXmlHttpObject();
	var url="/../front_end_ajax.php";
	url=url+"?toDo=update_ranking"
	url=url+"&blog_id="+blog_id
	url=url+"&level="+level
	url=url+"&sid="+Math.random()
	xmlHttpS.open("GET",url,true)
	xmlHttpS.onreadystatechange=function (){
	if (xmlHttpS.readyState==4 || xmlHttpS.readyState=="complete")
		 { 
		 			document.getElementById('rankingArea').innerHTML=xmlHttpS.responseText;
		 }	
	}
	xmlHttpS.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;
}
