// Creates an XMLHttpRequest object instance
function createXmlHttpRequestObject()
{
   // will store the reference to the XMLHttpRequest object
   var xmlHttp;
   
   // this should work for all browsers except IE6 and older
   try
   {
      // try to create XMLHttpRequest object
	  xmlHttp = new XMLHttpRequest();
   }
   catch(e)
   {
     // assume IE 7 or older
	  var XmlHttpVersions = new Array('MSXML2.XMLHTTP.7.0',
	                                   'MSXML2.XMLHTTP.6.0',
									           'MSXML2.XMLHTTP.5.0',
									           'MSXML2.XMLHTTP.4.0',
									           'MSXML2.XMLHTTP.3.0',
									           'MSXML2.XMLHTTP');
	  // try every prog id until one works
	  for(var i=0; i < XmlHttpVersions.length && !xmlHttp; i++)
	  {
	     try
		 {
	       // try to create XMLHttpRequest object
		    xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
		 }
		 catch(e)
		 {
		    // no action
		 }
	  }
   }
   // return the created object or display an error message
   if(!xmlHttp)
   {
	   // Disable error message
      // alert("Error creating the XMLHttpRequest object.");
   }
   else
   {
      return(xmlHttp);
   }
}

function processKeyword(_source)
{   
   // Instantiate an instance of the XMLHttpRequest object
   var xmlHttp = createXmlHttpRequestObject();

   // only continue if xmlHttp isn't void
   if(xmlHttp)
   {
     // try to connect to the server
	  try
	  {
	     // obtain the keyword
	     var keyword = escape(document.getElementById('q').value);
		 	  
	     // create the params string
	     var params = "keyword=" + keyword + "&source=" + _source;
	  
	     // initiate the asynchronous HTTP request
	     xmlHttp.open("GET", "/research/rda/global_includes/logkeyword.php?" + params, true);
	     // xmlHttp.onreadystatechange = handleRequestStateChange; // Not necessary for this purpose
	     xmlHttp.send(null);
	   }
	   // display the error in case of failure
	   catch(e)
	   {
		  // Disabled error message
	     // alert("Unable to connect to the server:\n" + e.toString());
	   }
   }
}

