		validationSet = false;
		var http = createRequestObject(); 
		
		
		$(document).ready(function (){
			
			var submissionTable = document.getElementById("submissionform"); 
			
			submissionTable.style.visibility = "visible";
			submissionTable.style.display = "inline";
			
			// This bit of code causes
			// enter to submit the form.
			var inputs = $("input");
			//$(inputs).keydown(checkForEnter);
			
			// Setup human validation
			
			document.onkeypress = function() {
				
				if(validationSet)
				{
					return;
				}
				
				validationSet = true;
				var thesession="[$SESSION_ID]";
				document.getElementById("humanvalidation").value=thesession;
				
			}
		});
		
		
		function checkForEnter(event) {
			if(event.keyCode == 13) {
				validateNSend();
			}
		}
		
		function createRequestObject() {
			var ro;
			var browser = navigator.appName;
			if(browser == "Microsoft Internet Explorer") {
				ro = new ActiveXObject("Microsoft.XMLHTTP");
			} else {
				ro = new XMLHttpRequest();
			}
			return ro;
		}
		
		
		// TODO: Remove this...
		function completeTest() {
			tb_show(null, "thankYouForInfo.html?height=300&width=300", null);
		
			// Now the the form has been successfully 
			// submitted hide all errors.
			//
			// Also reset all of the fields.
			var allErrors = $('div.error');
			var allInputs = $('input');
			
			for(var i = 0; i < allErrors.length; i++)
			{
				allErrors[i].style.visibility = "hidden";
				allErrors[i].style.display = "none";
			}
			
			for(var j = 0; j < allInputs.length; j++)
			{
				allInputs[j].readOnly = true;
				allInputs[j].disabled = true;
			}
		}
		
		function sndReq() {
			// console.info("Begin: sndReq()");
			
			
			var action = "/cgi-bin/XebraPrivate?LogProspectRegistration"; 
			var queryString = createQueryString();
			
			http.open('post', action); 
			http.onreadystatechange = function() { 
				if(http.readyState == 4) {
					var response = http.responseText;
					
					if(validationSet)
					{
						tb_show(null, "thankYouForInfo.html?height=300&width=300", null);
					
						// Now the the form has been successfully 
						// submitted hide all errors.
						//
						// Also disable all of the fields.
						var allErrors = $('div.error');
						var allInputs = $('input');
						
						for(var i = 0; i < allErrors.length; i++)
						{
							allErrors[i].style.visibility = "hidden";
							allErrors[i].style.display = "none";
						}
						
						for(var j = 0; j < allInputs.length; j++)
						{
							allInputs[j].readOnly = true;
							allInputs[j].disabled = true;
						}
						
						var textarea = $('#PRTEXT');
						textarea.readOnly = true;
						textarea.disabled = true;
						
						pageTracker._trackPageview("thankYouForInfo.html");
					
					}
					else
					{
						tb_show(null, "thankYouNotForInfo.html?height=300&width=300", null);
						pageTracker._trackPageview("thankYouNotForInfo.html");
					}
					
				}
				else if(http.readyState == 2) {
					
				}
				else if(http.readyState == 3) {
					
				}
				
			};
			http.send(queryString); 
			
			//console.info("End: sndReq()");
		}
		
		function createQueryString() {
			
			var action = "";
			action += "PRNAME=" + escape(document.getElementById("PRNAME").value) + "&";
			action += "humanvalidation=" + escape(document.getElementById("humanvalidation").value) + "&";
			action += "PRCOMPANY_NAME=" + escape(document.getElementById("PRCOMPANY_NAME").value) + "&";
			action += "PRADDRESS=" + escape(document.getElementById("PRADDRESS").value) + "&";
			action += "PRCITY=" + escape(document.getElementById("PRCITY").value) + "&";
			action += "PRSTATE=" + escape(document.getElementById("PRSTATE").value) + "&";
			action += "PRZIPCODE=" + escape(document.getElementById("PRZIPCODE").value) + "&";
			action += "PRCOUNTRY=" + escape(document.getElementById("PRCOUNTRY").value) + "&";
			action += "PRPHONENUMBER=" + escape(document.getElementById("PRPHONENUMBER").value) + "&";
			action += "PREMAIL=" + escape(document.getElementById("PREMAIL").value) + "&";
			action += "PRTEXT=" + escape(document.getElementById("PRTEXT").value);
			
			return action;
		}
		
		function validate() {
			/* Define Error Messages for various fields */
			var prNameErrMsg = "<sup>*</sup>Please enter your name before clicking submit.";
			var prCompNameErrMsg = "<sup>*</sup>Please enter your company name before clicking submit.";
			var prEmailErrMsg = "<sup>*</sup>Please enter a valid email address.";
			var prAddrErrMsg = "<sup>*</sup>Please enter a valid address.";
			var prCityErrMsg = "<sup>*</sup>Please enter a valid city.";
			var prStateErrMsg = "<sup>*</sup>Please enter a valid state.";
			var prZipErrMsg = "<sup>*</sup>Please enter a valid zip code.";
			var prCountryErrMsg = "<sup>*</sup>Please enter an at least 2 character long country code.";
			var prPhone = "<sup>*</sup>Please enter a valid phone number.";
			
			var isValid = true;
			
			var nameValidators = [new NotBlankValidator("PRNAME", prNameErrMsg), 
				   	      new NotBlankValidator("PRCOMPANY_NAME", prCompNameErrMsg)];
			
			
			
			var mailingAddrValidators = [new NotBlankValidator("PRADDRESS", prAddrErrMsg),
						     new NotBlankValidator("PRCITY", prCityErrMsg),
						     new NotBlankValidator("PRSTATE", prStateErrMsg, 2),
						     new ZipCodeValidator("PRZIPCODE", prZipErrMsg),
						     new NotBlankValidator("PRCOUNTRY", prCountryErrMsg, 2)];							     
			

			var emailValidators = [new EmailValidator("PREMAIL", prEmailErrMsg)];
			
			var phoneValidators = [new PhoneValidator("PRPHONENUMBER", prPhone)];

			// Ensures that a user enters at the very least:
			// Their name and their company name 
			// and at least one of the following:
			// - Their email address
			// - Their address
			// - Their phone
			isValid = runValidators(mailingAddrValidators) || runValidators(emailValidators) || runValidators(phoneValidators);
			
			if(isValid)
			{
				isValid = runValidators(nameValidators);
			}
			else
			{
				runValidators(nameValidators);
			}

			return isValid;
		}
		
		function validateNSend() {

			var isValid = validate();

			if(isValid)
			{
				//console.info("Request validated sending data.");
				sndReq();
				// TODO: uncomment this when it works.
				// Submit the information.
			}
			else {
				//console.warn("Form did not validate")
			}
			
			return false;
		}
		
		function runValidators(validators) {
			
			var isValid = true;
			
			for(var i = 0; i < validators.length; i++)
			{
				//console.info("validating " + validators[i].id);
				if(!validators[i].validate())
				{
					isValid = false;
				}
			}
			return isValid;
		}
