function AJAX_CreateRequest() {
	var req = null;

	try {	req = new XMLHttpRequest(); }
	catch (trymicrosoft) {
		try {	req = new ActiveXObject("Msxml2.XMLHTTP");	}
		catch (othermicrosoft) {
			try {	req = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (failed) { req = null;	}
		} // catch (othermicrosoft)
	}	// catch (trymicrosoft)
	
	if (req == null)
		alert("Error creating request object!");
	
	return (req);
}

// POST type send
function AJAX_Send(responseXmlHandler, url, parameter) {
	var req = AJAX_CreateRequest();
 	var handlerFunction = getReadyStateHandler(req, responseXmlHandler);
 	req.onreadystatechange = handlerFunction;
	req.open("POST", url, true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(parameter);
}

/*
 * Returns a function that waits for the specified XMLHttpRequest
 * to complete, then passes its XML response
 * to the given handler function.
 * req - The XMLHttpRequest whose state is changing
 * responseXmlHandler - Function to pass the XML response to
 * 10/16/2006 Ivan: Pass req object to handler function instead of just the XML
 */
function getReadyStateHandler(req, responseXmlHandler) {

	// Return an anonymous function that listens to the 
	// XMLHttpRequest instance
	return function () {

		// If the request's status is "complete"
		if (req.readyState == 4) {
			// Check that a successful server response was received
			if (req.status == 200) {
				// Pass the request object to the handler function
				responseXmlHandler(req);
      } else {
				// An HTTP problem has occurred
				alert("HTTP error: "+req.status);
			}
    }
  }
}




function AJAX_BuildUrl(url, parameter) {
	var varReturnValue = "";
	varReturnValue = url + "?tmp=" + new Date().getTime();
	if (parameter.length > 0) varReturnValue += "&" + parameter;
	return (varReturnValue);
}

function replaceText(el, text) {
  if (el != null) {
    clearText(el);
    var newNode = document.createTextNode(text);
    el.appendChild(newNode);
  }
}

function clearText(el) {
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        el.removeChild(childNode);
      }
    }
  }
}

function getText(el) {
  var text = "";
  if (el != null) {
    if (el.childNodes) {
      for (var i = 0; i < el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        if (childNode.nodeValue != null) {
          text = text + childNode.nodeValue;
        }
      }
    }
  }
  return text;
}