// this is an ajax script that retrieves press releases from a database and places the preformatted data into the displayArticle div on the press_release.html page without reloading the page. It retrieves the data using the GetPressRelease.php script by submitting the id embedded in the link for each press release listed on the press_release.html page.

function getPressRelease(id)
{
	 var responseDisplayArticle = document.getElementById("displayArticle");	

		 try
		 {
			 var requester = new XMLHttpRequest();
		 }

		catch (error)
		{
			try
			 {
			 var requester = new ActiveXObject("Microsoft.XMLHTTP");
			 }

			 catch (error)
			 {
			 var requester = null;
			 }
		  }

    if (requester != null)
			{
			  var ajaxLink = this;
			  ajaxLink._timer = setTimeout(function()
				  {
					requester.abort();       
					 writeError("The server timed out while making your request.");
				  }, 
				10000);       

					 ///************* the location of the php script goes here////////////////
			  requester.open("GET", "GetPressRelease.php?id=" + encodeURIComponent(id), true);

			  requester.onreadystatechange = function()
					 {
							if (requester.readyState == 4)
							{
								clearTimeout(ajaxLink._timer);        

							  if (requester.status == 200 || requester.status == 304)
								  {         
										responseDisplayArticle.innerHTML= requester.responseText;   //this line fills the contents of the div element.
										changeDisplay('displayArticle'); //changeDisplay function replaces current div with the displayArticle div
								   }
							  else
									 {
										writeError("The server was unable to be contacted.");
									 }
								}
						 };

				  requester.send(null); //this initiates the send sequence and now we wait for the reply which is monitored by the				onreadystatechange function above.

    } //requester !=null

  } //getPressRelease()

  //writeError: function(errorMsg)

  function writeError(errorMsg)
  {
    alert(errorMsg);
  }

