// if (parent.frames.length!=2)
//	top.location="index.html";

function submitIt(ANum,PNum,RNum){
	// alert(document.dataForm.Ax.length); // number of questions in the array
	// ANum = Array Number - number within the array of the correct answer
	// PNum = Page Number - page to go to if answered correctly (minus the .html)
	// RNum = Result Number - result or validation variable to place in the form field in the hidden data frame
	var a = -1;
	for (i=0; i<document.dataForm.Ax.length; i++){
		if (document.dataForm.Ax[i].checked){
			a = i;
		}
	}
	
	if (a == -1){
		alert("You must choose an answer before proceeding");
	}
	else{
		if (a == ANum){
			// alert("That is correct!");
			document.location.href = PNum+".html";
		}
		else{
			alert("We're sorry, that's incorrect. Please try again.");
		}
	}
}


function vForm(form){
	if(document.forms[0].firstname.value == ""){
		alert('Please enter your first name.');
		document.forms[0].firstname.focus();
		return false;
	}
	if(document.forms[0].lastname.value == ""){
		alert('Please enter your last name.');
		document.forms[0].lastname.focus();
		return false;
	}
	if(document.forms[0].hotel.value == ""){
		alert('Please enter the Hotel you will be staying at.');
		document.forms[0].hotel.focus();
		return false;
	}
	/*
	if(document.forms[0].zip.value != ""){
		var inputStr = document.forms[0].zip.value;
		var z = (isNumber(inputStr)) ? 1:0
		if (z == 0){
			alert('You must enter a numeric zip code.');
			document.forms[0].zip.value = "";
			document.forms[0].zip.focus();
			return false;
		}
	}
	if(document.forms[0].zip.value.length != 5){
		alert('Please enter your 5 digit zip code.');
		document.forms[0].zip.focus();
		return false;
	}
	*/
	if (document.forms[0].email.value == ""){
		alert('You must enter an e-mail address.');
		document.forms[0].email.focus();
		return false;
	}
	if (document.forms[0].email.value.search("@") == -1 || document.forms[0].email.value.search("[.*]") == -1){ // validate email
		alert('The e-mail address that you entered is not a valid e-mail address.');
		document.forms[0].email.focus();
		return false;
	}
	if(document.forms[0].cellphone.value == ""){
		alert('Please enter your cell phone number.');
		document.forms[0].cellphone.focus();
		return false;
	}
	else{
		return true;
	}
}

function isNumber(inputStr){
	for (var i = 0; i < inputStr.length; i++){
		var oneChar = inputStr.substring(i, i + 1);
		if (oneChar <= "0" || oneChar >= "9"){
			return false;
		}
	}
	return true;
}

function inRange(inputStr, lo, hi){
	var num = parseInt(inputStr)
	if (num < lo || num > hi){
		return false
	}
	return true
}
