// the following functions are used for the AJAX part
function createxmlhttp() {
  try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
  } catch(e) {};
  var xmlhttp=false;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) { xmlhttp = false; }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) { xmlhttp=false; }
  }
  if(!xmlhttp) {
      alert("XMLHttpRequest could not be created!");
  }
  return xmlhttp;
}

function requestData (url, data, sendMethod, receiveMethod, divID, unLoadingText) {
	receiveMethod = ('' + receiveMethod).toUpperCase ();
	if (receiveMethod == 'TRANSFER' && document.getElementById (divID) == null) {
		loadingBoxRemoval (unLoadingText);
		return;
	}
	var xmlhttp = createxmlhttp();

	xmlhttp.onreadystatechange = function() {	
		if(xmlhttp.readyState==4 && xmlhttp.status==200) {
			loadingBoxRemoval (unLoadingText);

			if (receiveMethod == 'TRANSFER') {
				document.getElementById (divID).innerHTML = xmlhttp.responseText;
				// execute the returned java script
				var s = xmlhttp.responseText.split ("<scr" + "ipt>");
				for (var i = 0; i < s.length; ++i) {
					var p = s [i].indexOf ("</scr" + "ipt>");
					if (p > -1)
						eval (s [i].substr (0, p));
				}
			} else {
				eval (xmlhttp.responseText);
			}
		}
	}

	if (('' + sendMethod).toUpperCase () != 'GET') {
		// separate the url and the data
		if (typeof (data) == 'undefined') data = '';
		xmlhttp.open ('POST', url, true);
		xmlhttp.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader ('Content-Length', data.length);
		xmlhttp.send(data);
	} else {
		xmlhttp.open("GET", url + '?' + data, true);
		xmlhttp.send(null);
	}
}

// my escape
function myEscape (s) {
	s = '' + s;
	while (s.indexOf ('&') > -1) s = s.replace ('&', '%26');
	return s;
}
