 var xmlHttp
			
function LoadRate2(page,usediv)
{
	
 document.getElementById("check").value = '1';
	 xmlHttp=GetXmlHttpObject()
	 xmlHttp.onreadystatechange = function(){
			 //Check page is completed and there were no problems.
			 if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
					//Write data returned to page
					document.getElementById(usediv).style.display='block';	
					document.getElementById(usediv).innerHTML = xmlHttp.responseText;
			 }
			 else
			 {
				
		
			 }
	 }
	 xmlHttp.open("GET", page,true);
	 xmlHttp.send(null);
	 //Stop any link loading normaly
	 return false;
}

function sendComment(id,check,path)
{
	var username = document.getElementById('username').value;
	var email = document.getElementById('email').value;
	var comment = document.getElementById('comment').value;
	var check = document.getElementById('check').value;
	if(check == '0')	
		var str = id+'-'+username+'-'+email+'-'+'0'+'-'+comment;
	else
	{
		var rating = document.getElementById('rating').value;
		var str = id+'-'+username+'-'+email+'-'+rating+'-'+comment;
	}
	
	var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
	if(username == "") {
	inlineMsg('username','You must enter your name.',2);
	return false;
	}
	if(!username.match(nameRegex)) {
	inlineMsg('username','You have entered an invalid name.',2);
	return false;
	}
	if(email == "") {
	inlineMsg('email','<strong>Error</strong><br />You must enter your email id.',2);
	return false;
	}
	if(!email.match(emailRegex)) {
	inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email id.',2);
	return false;
	}
	if(comment == "") {
	inlineMsg('comment','<strong>Error</strong><br />You must enter comment.',2);
	return false;
	}
	
	document.getElementById("username").value=""
	document.getElementById("email").value=""
	document.getElementById("comment").value=""
	
	if (str.length==0)
	{ 
		document.getElementById("viewAjaxComment").innerHTML=""
		return
	}
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url=path+"comment.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function()
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("viewAjaxComment").innerHTML=xmlHttp.responseText 
		}
		else
		{
			var image_path = path+'images/ajax-loader.gif';
			document.getElementById("viewAjaxComment").innerHTML='<div align="center" style="padding:80px 100px; font-weight:bold"><img src='+image_path+' style="padding-left:20px;" border="0"></div>';
		}
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function sendReplyComment(article_id,id,path)
{
	var name = document.getElementById(id+'_name').value;
	var email = document.getElementById(id+'_email').value;
	var message = document.getElementById(id+'_message').value;
	
	var str = id+'-'+name+'-'+email+'-'+message+'-'+article_id;
	
	var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
	if(name == "") {
	alert('You must enter your name.');
	return false;
	}
	if(!name.match(nameRegex)) {
	alert('You must enter your name.');
	return false;
	}
	if(email == "") {
	alert('You must enter your email id.');
	return false;
	}
	if(!email.match(emailRegex)) {
	alert('You have entered an invalid email id.');
	return false;
	}
	if(message == "") {
	alert('You must enter your message.');
	return false;
	}
	
	if (str.length==0)
	{ 
		document.getElementById(id+"_viewReplyComment").innerHTML=""
		return
	}
	
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url=path+"reply_comment.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	
	xmlHttp.onreadystatechange=function()
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById(id+"_viewReplyComment").innerHTML=xmlHttp.responseText 
		}
		else
		{
			var image_path = path+'images/ajax-loader.gif';
			document.getElementById(id+"_viewReplyComment").innerHTML='<img src='+image_path+' style="padding-left:20px;" border="0">Sending Comment..';
		}
	}
	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;
}
