// JavaScript Document
var xmlHttp
var divid
var div_loader
////////// process comment//////
function processComment(comment_div,news_id,description)
{
	
	divid=comment_div;
	//////////// check the description empty /////////
	if (document.getElementById(description).value=="Write a comment...")
	{
	  return false;
	}
	
	
		str=document.getElementById(description).value;
		
		div_loader=comment_div;
		document.getElementById(div_loader).innerHTML='<img src=images/loader.gif />';
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		var url="process-comment.php";
		url=url+"?description="+str+"&news_id="+news_id;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	
}
//////////// end of comment function //////
////////// process website url //////
function processWebsiteLink()
{
	
	divid="remote_contents";
	str=document.getElementById("description").value;
	//////////// check the description empty /////////
	if (str=="")
	{
	  return false;
	}
	/////////////// check the option selected /////
	
	myOption = -1;
	for (i=document.frmNews.content_options.length-1; i > -1; i--) 
	{
		if (document.frmNews.content_options[i].checked)
		myOption = i; 
	}
	
	if(document.frmNews.content_options[myOption].value!="website")
		return false;

	///////// end of option selected

	
		div_loader="remote_contents";
		document.getElementById(div_loader).innerHTML='<img src=images/loader.gif />';
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		var url="process-website-link.php";
		url=url+"?url="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	
}
//////////// end of website url //////

////////// process Youttube video url //////
function processYoutubeVideo()
{
	
	divid="remote_contents";
	str=document.getElementById("description").value;
	//////////// check the description empty /////////
	if (str=="")
	{
	  return false;
	}
	/////////////// check the option selected /////
	
	myOption = -1;
	for (i=document.frmNews.content_options.length-1; i > -1; i--) 
	{
		if (document.frmNews.content_options[i].checked)
		myOption = i; 
	}
	
	if(document.frmNews.content_options[myOption].value!="video")
		return false;

	///////// end of option selected

	
		div_loader="remote_contents";
		document.getElementById(div_loader).innerHTML='<img src=images/loader.gif />';
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		var url="process-youtube-video.php";
		url=url+"?url="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	
}
//////////// end of youtube video url //////
////////// process next previous //////
function processNextPrevious(str)
{
	
		divid="thumbnail";
		div_loader="thumbnail";
		document.getElementById(div_loader).innerHTML='<img src=images/loader.gif />';
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		var url="process-next-previous.php";
		url=url+"?index="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	
}
//////////// end of youtube video url //////
function focusBox(obj,submitbox)
{
	if(obj.value=="Write a comment...")	
	{
		obj.value="";	
		document.getElementById(submitbox).style.display="block";
	}
	
}

function unFocusBox(obj,submitbox)
{
	if(obj.value=="")	
	{
		obj.value="Write a comment...";	
		document.getElementById(submitbox).style.display="none";
	}
	
}

//// Ajax required functions //////////
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
	document.getElementById(divid).innerHTML=xmlHttp.responseText;
	//document.getElementById(div_loader).innerHTML='';
}
}

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;
}

//// end of ajax coding


