
  function ajaxRequest(url, opts) {

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	  try {
		  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
			  try {
				  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				  } catch (e2) {
					  xmlHttp = false;
					  }
					  }
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

var events = 
  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];

var options = {
      method: 'post',
      asynchronous: true,
      parameters: '',
	  onException: function(originalRequest, ex) {}
};

  for (property in opts) {
    options[property] = opts[property];
  }

  if(options.method == 'get')
	  url = url + '?' + options.parameters;
   xmlHttp.open(options.method, url, options.asynchronous);

   if (options.method == 'post') {
	   xmlHttp.setRequestHeader("content-length", options.parameters.length);
	   xmlHttp.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	   if (xmlHttp.overrideMimeType)
		   xmlHttp.setRequestHeader('Connection', 'close');
   }
   xmlHttp.onreadystatechange = function() {
	   var state = xmlHttp.readyState;
	   var event = events[state];

	   if (event == 'Complete') {
		  try {
			(options['on' + xmlHttp.status])(xmlHttp);
		  } catch (e) {
			(options['onException'])(xmlHttp, e);
		  }
	   }

		try {
		  (options['on' + event] || Prototype.emptyFunction)(xmlHttp);
		} catch (e) {
		  (options['onException'])(xmlHttp, e);
		}

		if (event == 'Complete')
			xmlHttp.onreadystatechange = function() {};

   };

   var body = options.postBody ? options.postBody : options.parameters;
   xmlHttp.send(options.method == 'post' ? body : null);

  }


/*
function ajax_load(url, pid) {
   ajaxRequest(url, {
	                 onComplete: function(originalRequest) {
					   $(pid).innerHTML = originalRequest.responseText;
                     }
   });
}
*/
