function validateFields(obj) {

//DISABLE THE SEND BUTTON
	var sendContactBtn = document.getElementById("sendContactEmail");
	sendContactBtn.setAttribute("disabled","true");
/*
//RUN QUESTION FOR SPAMMERS	
	var secur = document.getElementById('posSec');
	var securVal = secur.value;
	if(securVal=="" || securVal == "78"){
	null;
	}
	else{
	alert("And Error was made enter the \"fill in\" field. Please re-enter or leave blank");
	sendContactBtn.removeAttribute("disabled");
	return;
	}
*/
//RUN HONEY POT TEST FOR SPAMMERS	
	var secur = document.getElementById('posSec');
	var securVal = secur.value;
	if(securVal=="" || securVal == "78"){
	null;
	}
	else{
	alert("And Error was made enter the \"fill in\" field. Please re-enter or leave blank");
	sendContactBtn.removeAttribute("disabled");
	return;
	}
	
//START GETTING THE ELEMENTS
	var formElmIds = ["posName","posCompany","posEmail","posPhone","posMessage"];
	var formHasError = false;
for(var i = 0;i<formElmIds.length;i++){
	var	elmId = formElmIds[i];
	var elm = document.getElementById(elmId);
//alert("a"+formElmIds[i] +" value:"+elm.value);
	var val = elm.value || "";
//alert("z"+formElmIds[i] +":"+val);
		// convert (&, +, =) to string equivs. Needed so URL 
		// encoded POST won't choke.
		val = val.replace(/&/g,"**am**");
		val = val.replace(/=/g,"**eq**");
		val = val.replace(/\+/g,"**pl**");
		formElmIds[i] = elmId + "=" + val;
	}


	if (formHasError) {
		alert("You're trying to send an Empty Message. Please type something and then get on your way.");
		sendContactBtn.removeAttribute("disabled");
return;
	}
	else {
	//begin the load Message
	var posLoadMessage = document.getElementById("posLoadMessage");
		posLoadMessage.className = "posLoadMessage posLoadMessageRun";
		posLoadMessage.innerHTML = "<strong>Sending your request. Please wait a sec&#8230;</strong>";
	//begin the load bar
	var posLoadBar = document.getElementById('posLoadBar');
		posLoadBar.className = "posLoadBar posLoadBarRun";
		
	var page = "/stacksite/j/ajaxContactRequest.php?contact=true&xml=true";
	//alert(formElmIds.join("&"));
	var posData = formElmIds.join("&");
	loadXMLPosDoc(page,posData);
	}
}


var pos;
// code to create and make AJAX request
function loadXMLPosDoc(url,posData) {
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
        pos=new XMLHttpRequest();
    } else if (window.ActiveXObject) { //IE 
        pos=new ActiveXObject('Microsoft.XMLHTTP');
    }

    // if we have created the xmlhttp object we can send the request
    if (typeof(pos)=='object') {
        pos.onreadystatechange = processPosChange;
        pos.open("POST", url, false);
		pos.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        window.setTimeout("pos.send('"+posData+"')",3000);
    // otherwise display an error message
    } else {
        alert('Your browser is to old, or not enabled to send a message.');
		//ENABLE THE SEND BUTTON
		sendContactBtn.removeAttribute("disabled");
		return;
    }
}


function processPosChange() {
	//load Message Element
	var posLoadMessage = document.getElementById('posLoadMessage');
	//load Bar Element
	var posLoadBar = document.getElementById('posLoadBar');

    // page loaded "complete"
    if (pos.readyState == 4) {//#1
        // page is "OK"
        if (pos.status == 200) {//#2
			//turn off Load Bar
			posLoadBar.className = "posLoadBar";
			//load Message Fail To MAIL
			if ( grabPosXML("status") == 'NOTOK' ) {//#3
				posLoadMessage.className = "posLoadMessage posLoadMessageFailed";
				posLoadMessage.innerHTML = "<strong style='color:red;'>"+grabPosXML("confirmation")+"</strong>";
				//NOTE: this could have a confirm asking if they would like to retry
				alert('There were problems Sending Email. Please check back in a couple minutes');
				reSetForm();
			}//#3
			//load Message Successfully was sent.
			else{//#4
				posLoadMessage.className = "posLoadMessage posLoadMessageFailed";
				posLoadMessage.innerHTML = "<strong style='color:green;'>"+ grabPosXML("confirmation")+"</strong>";
				reSetForm();
			}//#4
		}//#2
	}//#1
}

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

function reSetForm(){
//NOTE: Maybe I should use frmEl.reset();
// I know the reset button is being removed from the HTML5 specs
// the reset() needs research and testing, before I start using it. 
// Maybe posName.focus(); should be used here too.
	var sendContactBtn = document.getElementById("sendContactEmail");
	var fieldArea = document.getElementById('contactFormArea');
	var inputs = fieldArea.getElementsByTagName('input');
	var inputsLen = inputs.length;
	var tAreas = fieldArea.getElementsByTagName('textarea');
	var tAreasLen = tAreas.length;
	// Now reSet Elements to blank
	for ( i=0;i<inputsLen;i++ ) {
		if ( inputs[i].getAttribute('type') == 'text' ) {
			inputs[i].value = '';
		}
	}
	for ( j=0;j<tAreasLen;j++ ) {
		tAreas[j].value = '';
	}
	//ENABLE THE SEND BUTTON
	sendContactBtn.removeAttribute("disabled");

}