	// AJAX FrameWork
	// Coded by Chris Collins
	// August 16, 2005

	var AJAX; // Container to hold AJAX HTTP Request Object
	var MsXMLHttpRequestVersion = false; // If IE HTTP Version is known, set it here.

    // Create an XMLHttpRequest Object
	function CreateAJAX(){
        // check the dom to see if this is IE or not
        if (window.XMLHttpRequest){
    		// Not IE
            AJAX = new XMLHttpRequest();
        } else if (window.ActiveXObject){
    		// Is IE! Booo!
            // Instantiate the latest MS ActiveX Objects
            if (MsXMLHttpRequestVersion){
                AJAX = new ActiveXObject(MsXMLHttpRequestVersion);
            } else {
        	    // Loop through the various versions of XMLHTTP to ensure we're using the latest.
        	    var versions = ['Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
                for (var i=0;i<versions.length;i++){
                    try {
            		    // Try to create the object
            		    // If it doesn't work, we'll try again
            		    // If it does work, we'll save a reference to the proper one to speed up future instantiations
                        AJAX = new ActiveXObject(versions[i]);
                        if (AJAX){
                            MsXMLHttpRequestVersion = versions[i];
                            break;
                        }
                    }
                    catch (objException){
                    	// Trap; try next one
                    }
                }
            }
        }
	}

    // Perform AJAX Request.
    function AJAXRequest(url, data, method){
		method = method.toLowerCase(); // Either GET or POST
		// Display Hourglass and status
		document.body.style.cursor = 'wait';
		window.status = 'Sending Request...';
		// Create AJAX HTTP Object
		CreateAJAX();
		// Send Data
		// Do GET
		if (method == 'get'){
   			AJAX.open('get', url+'?'+data);
          	AJAX.onreadystatechange = AJAXReturn; 
       		AJAX.send(null);
		}
		// Do POST
		if (method == 'post'){
        	AJAX.abort;
        	AJAX.open('post',url);
          	AJAX.onreadystatechange = AJAXReturn; 
        	AJAX.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        	AJAX.send(data);
		}
    	// Return cursor to normal arrow and update status
		document.body.style.cursor = 'default';
		window.status = 'Done';
    }
    
    // Perform AJAX Return.
    function AJAXReturn(){
		// Update Window Status
		window.status = 'Waiting for data...';
    	if (AJAX.readyState == 4){ // Finished loading the response
			if (AJAX.responseXML) AJAXParseXML(AJAX.responseXML);
			else AJAXParseText(AJAX.responseText);
   		}
   }

	// Perform AJAX Operations (TEXT)
	function AJAXParseText(text){
		// Something Probably went wrong, disply text response alert.
		//if (text != '') alert(text);
	}

	// Perform AJAX Operations (XML)
	function AJAXParseXML(xml){
		window.status = 'Performing operations...';
		xml = xml.documentElement;
		for (i=0;i<xml.childNodes.length;i++){
			// Display Alert Message
			if (xml.childNodes[i].nodeName.toLowerCase() == 'alert'){
				if (xml.childNodes[i].firstChild) alert(xml.childNodes[i].firstChild.nodeValue);
			}
			// Evaluate JavaScript
			if (xml.childNodes[i].nodeName.toLowerCase() == 'script'){
				if (xml.childNodes[i].firstChild) eval(xml.childNodes[i].firstChild.nodeValue);
			}
			// Update Page Element
			if (xml.childNodes[i].nodeName.toLowerCase() == 'update'){
				var action = '';
				var element = '';
				var attribute = '';
				var data = '';
				// Set Update vars
				var node = xml.childNodes[i];
				for (j=0;j<node.childNodes.length;j++){
					if (node.childNodes[j].nodeName.toLowerCase() == 'action') action = node.childNodes[j].firstChild.nodeValue.toLowerCase();
					if (node.childNodes[j].nodeName.toLowerCase() == 'element') element = node.childNodes[j].firstChild.nodeValue;
					if (node.childNodes[j].nodeName.toLowerCase() == 'attribute') attribute = node.childNodes[j].firstChild.nodeValue;
					if (node.childNodes[j].nodeName.toLowerCase() == 'data') data = node.childNodes[j].firstChild.nodeValue;
				}
				// Replace Element Attribute data with new data
				if (action == 'replace') eval("document.getElementById('"+element+"')."+attribute+" = data;");
				// Append data to Element Attribute
				if (action == 'append') eval("document.getElementById('"+element+"')."+attribute+" += data;");
				// Prepend data to Element Attribute
				if (action == 'prepend') eval("document.getElementById('"+element+"')."+attribute+" = data + document.getElementById('"+element+"')." + attribute);
				// Clear Element Attribute
				if (action == 'clear') eval("document.getElementById('"+element+"')."+attribute+" = '';");
			}
		}
	}