<!--

// ***************** AJAX stuff *************************

// creates a request object with which the data can be
// "tunneled" through
function create_request(){
	var req;					// the request object that will be created
	// if using a regular complaince standard browser
	if (window.XMLHttpRequest){
   	    req = new XMLHttpRequest();
   	}// if using Internet Explorer
	else if (window.ActiveXObject) {
   	    req = new ActiveXObject("Microsoft.XMLHTTP");
   	}
	if (!req) {
    	alert('Cannot create an XMLHTTP instance');
        return false;
    }else{
		return req;
	}
}
 /* the base ajax calling function
  * usually you want to set up a function that calls this one
  * and supplies it with the parameters for a specific <div>tag you need to work with
  * curDiv = the id of the div tag to put HTML into
  * url = the dynamic page waiting for post data, that will return the HTML
  * callback = the function that will be called when data is received by the browser
  * sendStr = a string of name=value pairs seperated by &s, which get sent to the url page
  * show = whether you want to change a hidden div to a visible one
  */
function base_ajax(tagID, url, sendStr, callback){
	var req = create_request();
	if(req){
		req.open("POST", url, true);
		/* when the data has been completely loaded back into the browser
		  * and the status is OK, it puts the text string that was returned
		  * into the tag specified in curDiv, and shows the div (if specified)
		  */
		req.onreadystatechange = function(){
			if (req.readyState == 4 && req.status == 200) {
				if(document.getElementById(tagID)){
					var elem = document.getElementById(tagID);
					elem.innerHTML = req.responseText;
					if(callback){
						eval(callback);
					}
				}
			}	
		}
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(sendStr);
	}
}

function base_ajax_append(tagID, url, sendStr, callback){
	var req = create_request();
	if(req){
		req.open("POST", url, true);
		/* when the data has been completely loaded back into the browser
		  * and the status is OK, it puts the text string that was returned
		  * into the tag specified in curDiv, and shows the div (if specified)
		  */
		req.onreadystatechange = function(){
			if (req.readyState == 4 && req.status == 200) {
				if(document.getElementById(tagID)){
					var elem = document.getElementById(tagID);
					elem.innerHTML += req.responseText;
					if(callback){
						eval(callback);
					}
				}
			}	
		}
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send(sendStr);
	}
}


//-->
