// JavaScript Document

// ---------------------------------------------------------------------------------------------------------------------------------------------
// Cycles through the browsers to figure out what it's going to use
function readyAJAX() {
	try {
		return new XMLHttpRequest();
	} catch(e) {
		try {
			return new ActiveXObject('Msxm12.XMLHTTP');
		} catch(e) {
			try {
				return new ActiveXObject('Microsoft.XMLHTTP');
			} catch(e) {
				return "A newer browser is needed.";
			}
		}
	}
}

// ---------------------------------------------------------------------------------------------------------------------------------------------
// This function grabs the info asynchronously
function enterDealerFormInfo() {
	// Grabs the value of the readyAJAX() function
	var requestObj = readyAJAX();
	param = document.financingFormAdvatange10.reel_id.value;
	// Creates the url that it's going to send to the processPage.php
	var url = "processForm.php?reelid=" + param;
	
	requestObj.open("GET",url,true);
	requestObj.send();
	requestObj.onreadystatechange = function() {
		if (requestObj.readyState == 4) {
			if (requestObj.status == 200) {
				// Grabs the result from the processPage.php
				var textFromPHP = requestObj.responseText;
				// Writes it in the middleColumn div
				window.document.getElementById('formChange').innerHTML = textFromPHP;
				// = textFromPHP;
				//document.financingFormAdvatange10.dealer_contact.value = textFromPHP;
				
			}
		}
	}
}
