/**
 * This file is generic enough to use on all
 * action forms which require contact with
 * AJAX invokations
 *
 *
 * N.B. This script below just asures that the active
 *      window browser is listening for end use events
 *      and it will prepare a HTTP POST to the desired
 *      AJAX event.
 *      i.e. A "Contact Us" input form, sends off its
 *           input fields to a validation and processing
 *           AJAX script.
 *
 * N.B. This script is expecting to have a return xml tag
 *      named "status"
 *
 * Author: Community Open Source.
 * Date: 2007-11-16
*/


var pos; // variable for posting information


function loadXMLPosDoc(url,posData) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        pos = new XMLHttpRequest();
        pos.onreadystatechange = processPosChange;
        pos.open("POST", url, false);
		pos.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        pos.send(posData);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        pos = new ActiveXObject("Microsoft.XMLHTTP");
        if (pos) {
            pos.onreadystatechange = processPosChange;
            pos.open("POST", url, false);
			pos.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            pos.send(posData);
        }
    }
}


function grabPosXML (tagName) {
	return pos.responseXML.documentElement.getElementsByTagName(tagName)[0].childNodes[0].nodeValue;
}


function processPosChange() {
    // page loaded "complete"
    if (pos.readyState == 4) {
        // page is "OK"
        if (pos.status == 200) {
			if ( grabPosXML("status") == 'NOTOK' ) { 
			    /* Here we do nothing because we handle the presentation of errors to the user in html format not javascript. */
				//alert('There were problems Sending Email. Please check back in a couple minutes');
			}
		}
	}
}
