//function to post ajax data
//function_name is the callback function name that automatically recieves the http_request 
//function_name(http_request)
function ajaxPost(url, parameters) 
{
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) 
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	//http_request.onreadystatechange = function() { alertContents(http_request); }
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

//function to post ajax data
//function_name is the callback function name that automatically recieves the http_request 
//function_name(http_request)
function ajaxPostFunction(function_name)// ,),),) multiple parameters can be added
{
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) 
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	
	if(arguments.length > 1)
	{
		var params = new Array();
		var cnt = 0;
		for(var i=1; i<arguments.length; i++)
		{
			params[cnt] = arguments[i];
			cnt++;
		}
	}
	if(params != null)
		function_name(http_request, params)
	else	
		function_name(http_request);
}

//main function to read ajax data
//xmlfile is the url to the xml file
//divID is teh div to fill with data
//function_name is the callback function name that automatically recieves the xmlObj and divID
//function_name(divID, xmlObj)
function ajaxReadAndLoad(xmlfile, divID, function_name)
{
	var xmlObj = null;
	var currentclass = "content";
	if(window.XMLHttpRequest)
		xmlObj = new XMLHttpRequest();
	else if(window.ActiveXObject)
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	else 
		return;

	//this will look to see if there 
	//are other values that need to be added
	//to the call back function lists
	//of arguements
	if(arguments.length > 3)
	{
		var params = new Array();
		var cnt = 0;
		for(var i=3; i<arguments.length; i++)
		{
			params[cnt] = arguments[i];
			cnt++;
		}
	}

	xmlObj.onreadystatechange = function()
	{
		if(xmlObj.readyState == 4)
		{
			if(params != null)
			{
				function_name(divID, xmlObj, params)
			}	
			else	
			{
				function_name(divID, xmlObj);
			}	
		}
	}
	xmlObj.open ('GET', xmlfile, true);
	xmlObj.send ('');
}
//main function to read ajax data
//xmlfile is the url to the xml file
//function_name is the callback function name that automatically recieves the xmlObj and divID
//function_name(divID, xmlObj)
function ajaxRead(xmlfile,function_name)
{
	var xmlObj = null;
	var currentclass = "content";
	if(window.XMLHttpRequest)
		xmlObj = new XMLHttpRequest();
	else if(window.ActiveXObject)
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	else 
		return;

	//this will look to see if there 
	//are other values that need to be added
	//to the call back function lists
	//of arguements
	if(arguments.length > 2)
	{
		var params = new Array();
		var cnt = 0;
		for(var i=2; i<arguments.length; i++)
		{
			params[cnt] = arguments[i];
			cnt++;
		}
	}

	xmlObj.onreadystatechange = function()
	{
		if(xmlObj.readyState == 4)
		{
			if(params != null)
				function_name(xmlObj, params)
			else	
				function_name(xmlObj);
		}
	}
	xmlObj.open ('GET', xmlfile, true);
	xmlObj.send ('');
}
