/*
  Quick Links Functions
*/
var _viewer = "quicktext";
var AjaxServerPageName = "ajaxserver.php";
var XmlHttp;
var _contentA = "today";
var _contentB = "news";
var _contentC = "links";
  
function _quicklink(link_id)
{
  try
  {
    switch (link_id)
    {
      case "A" :
	  ResetViewer();
	  LoadContent(_contentA);
	  break
	
	  case "B" :
	  ResetViewer();
	  LoadContent(_contentB);
	  break
	
	  case "C" :
	  ResetViewer();
	  LoadContent(_contentC);
	  break
    }
  }
  catch(oc)
  {
    alert("oops something went wrong!");
  }
}

function LoadContent(content_type)
{
  try
  {
    var randomnumber=Math.floor(Math.random()*101)

	// URL to get states for a given country
	var requestUrl = AjaxServerPageName + "?action=" + encodeURIComponent(content_type) + "&unique=" + encodeURIComponent(randomnumber);
	
	CreateXmlHttp();
	
	// If browser supports XMLHTTPRequest object
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = GetContent;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl, true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}
  }
  catch(oc)
  {
    alert("unable to retrieve content");
  }
}

//Called when response comes back from server
function GetContent()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			
			document.getElementById(_viewer).innerHTML = XmlHttp.responseText;
			//alert(XmlHttp.responseText);
		}
		else
		{
			document.getElementById(_viewer).innerHTML = "sorry, cant get content at this time.";
		}
			
	}
}

function ResetViewer()
{
  try
  {
    document.getElementById(_viewer).innerText = "";
    return true
  }
  catch(oc)
  {
    ResetViewer();
  }
}

function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

