function ajaxFunction()
{
 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;
      }
    }
  }
 return  xmlHttp;
}// end function
function printpage(autono,tp)
{
	window.open('printpage.php?autono='+ autono,'','width=610,height=700,scrollbars=yes');
}

function add_click(autono)
{
	document.getElementById("email_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=17 align=center width='550px'><font face='Arial' color='#2D629E' size='2'><b>Loading...</b></font></td></tr></table>";
	NewxmlHttp=ajaxFunction();
	NewxmlHttp.onreadystatechange=function()
	{
		if (NewxmlHttp.readyState==4) 
			{
				if (NewxmlHttp.status!=404)
				{	
				   if((NewxmlHttp.responseText).length > 0)
					{
						document.getElementById("email_div").innerHTML = NewxmlHttp.responseText;					
					}
				}
			
			}
			
	}
	datafile = "/email_story.php?autono="+autono;
	NewxmlHttp.open("GET", datafile, true);
	NewxmlHttp.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp.send(null);
	 
}
function cancel_click()
	{
		
		 document.getElementById("email_div").innerHTML = "";
	
	}
function send_mail(toname,bcc,sender,file_path,referrer,headline,autono,summary,copy)
{
	
	if(toname == "")
	{
		alert("\"To\" field cannot be left blank");
		//alert(copy);
		document.getElementById(toname).value="";
		return false;
	}
	if(sender == "")
	{
		alert("Your Email address cannot be left blank");
		document.getElementById(sender).value="";
		return false;
	}
	document.getElementById("email_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=17 align=center width='550px'><font face='Arial' color='#2D629E' size='2'><b>Sending Mail...</b></font></td></tr></table>";
	NewxmlHttp2=ajaxFunction();
	NewxmlHttp2.onreadystatechange=function()
	{
		if (NewxmlHttp2.readyState==4) 
			{
				if (NewxmlHttp2.status!=404)
				{	
				   if((NewxmlHttp2.responseText).length > 0)
					{
						document.getElementById("email_div").innerHTML = NewxmlHttp2.responseText;					
					}
				}
			
			}
			
	}
	datafile = "ajx_sendmail.php?autono="+autono+"&toname="+toname+"&bcc="+bcc+"&sender="+sender+"&file_path="+file_path+"&headline="+headline+"&summary="+summary+"&referrer="+referrer+"&copy="+copy;
	//alert(datafile);

	NewxmlHttp2.open("GET", datafile, true);
	NewxmlHttp2.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp2.send(null);
	
}
function rate_post(autono,rate,heading)
{
	document.getElementById("email_div").innerHTML = "<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=17 align=center width='550px'><font face='Arial' color='#2D629E' size='2'><b>Rating...</b></font></td></tr></table>";
	NewxmlHttp3=ajaxFunction();
	NewxmlHttp3.onreadystatechange=function()
	{
		if (NewxmlHttp3.readyState==4) 
			{
				if (NewxmlHttp3.status!=404)
				{	
				   if((NewxmlHttp3.responseText).length > 0)
					{
						document.getElementById("showSRate").innerHTML=NewxmlHttp3.responseText;					
						document.getElementById("email_div").innerHTML ="<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=17 align=center width='550px'><font face='Arial' color='#2D629E' size='2'><b>Vote sucessfully posted.</b></font></td></tr></table>";										
					}
				}
			
			}
			
	}
	datafile = "/ajx_storyrate.php?autono="+autono+"&rate="+rate+"&heading="+heading;
	NewxmlHttp3.open("GET", datafile, true);
	NewxmlHttp3.setRequestHeader("Cache-Control","no-cache"); 
	NewxmlHttp3.send(null);
}
function post_comment()
{
	
	vemail=document.frmcomment.cemail;
	
	if(vemail==false)
	{
		return false;
	}
	if(document.frmcomment.cname.value=="")
	{
		alert("Enter Your Name");
		document.frmcomment.cname.focus();
		return false;
	}
	if(document.frmcomment.cemail.value=="")
	{
		alert("Enter Your Email");
		document.frmcomment.cemail.focus();
		return false;
	}
	else{
		if(common_echeck(vemail)==false)
		{
			return false;
		}
			
	}
	if(document.frmcomment.newscomment.value=="")
	{
		alert("Enter Your Comment");
		document.frmcomment.newscomment.focus();
		return false;
	}

   NewxmlHttp4=ajaxFunction();
   NewxmlHttp4.onreadystatechange=function()
   {    
		if (NewxmlHttp4.readyState==4) 
			{   
				if (NewxmlHttp4.status!=404)
				{	
					//alert(NewxmlHttp4.responseText);
					document.getElementById("compost_mes").innerHTML = NewxmlHttp4.responseText;					
				}
			
			}	
	
   }
   
	var cname=encodeURIComponent(document.getElementById("cname").value)
	var cemail=encodeURIComponent(document.getElementById("cemail").value)
	var newscomment=encodeURIComponent(document.getElementById("newscomment").value)
	var autono=document.getElementById("autono").value
	var parameters="autono="+autono+"&cname="+cname+"&cemail="+cemail+"&newscomment="+newscomment;
   document.frmcomment.cname.value="";
   document.frmcomment.cemail.value="";
   document.frmcomment.newscomment.value="";
   datafile = "/ajx_compost.php";
   NewxmlHttp4.open("POST", datafile, true);

   //NewxmlHttp4.setRequestHeader("Cache-Control","no-cache"); 
   NewxmlHttp4.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   NewxmlHttp4.send(parameters)
   //NewxmlHttp4.send(null);
   return false;

}
function showRepBox(active_i)
{
	//hideBox(active_i);
	document.getElementById(active_i).style.display = "";
	return false;

}
function callReply(id,totcomment)
{
	repname=document.getElementById('repname'+id).value;
	repemail=document.getElementById('repemail'+id).value;
	repcomment=document.getElementById('repcomment'+id).value;
    
	if(repname == "")
	{
			alert("please enter the name");
			return false;
	}
	else if(repemail == "")
	{
		alert("please enter the Email");
		return false;
	}
	else if(repcomment == "")
	{
		alert("please enter the Reply Comment");
		return false;
	}
	else
	{
		
	    document.frmComPost.action="save_replycom.php?id="+id;
		document.frmComPost.submit();
        return true;

	}
	


}