
/*                      * * * Ajax - Try/Catch Blocks of Code * * *
 
   To create the XMLHttpRequest object, this function uses the special programming technique
   known as "try and catch". Basically it attempts to "try" a piece of code and if the piece
   of code causes an error, it "catches" that error and keeps going. Normally, when an error
   occurs the code will stop running, however, the "catch" traps the error and lets the code
   continue.

   The createRequestObject() function is going to "try" three different ways to make a new 
   XMLHttpRequest object. Each time the function fails and get an error, it will catch the 
   error and try the next command. 

   Note: If the "try" is successful, then the "catch" code will not be run because it is     
         only used when there is an error.
*/

function createRequestObject()
  {
   var request_o;  			// Declare the variable to hold the object.

   // Browser Support Code. Function creates an XMLHttpRequest object.	
   try
     {
      // For Opera 8.0+, Firefox and Safari browsers, start a XMLHttpRequest.
      request_o = new XMLHttpRequest();
     }
   catch (e)
     {
      // Internet Explorer Browsers.
      try
        {
         // Try the first kind of active x object.
	 request_o = new ActiveXObject("Msxml2.XMLHTTP");
	}
      catch (e)
        {
	 try
	   {
	    // Try the second kind of active x object.            
	    request_o = new ActiveXObject("Microsoft.XMLHTTP");
	   }
         catch (e)
	   {
	    // Something went wrong.
	    alert("Your browser does not support XMLHttpRequest ,which also means it does not support Ajax!");
	    return false;
	   }
	}
     }
   return request_o; 			// Return the object.
  }

