<!--

//global variables declaration
var selOption = new Array();

function rollOver(imgName,imgFile) {
	img = new Image();
	img.src = imgFile;
	
	document.images[imgName].src = img.src;
}

function smplsWindow(someURL) {
	newWindow = window.open("","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=450");
	newWindow.location = someURL;
}

function browserCheck() {
	if (navigator.appName == "Netscape") {
		if (parseFloat(navigator.appVersion)>=4.0) {
			window.location="signok.html";
		}
		else {
			window.location="signwarn.html";
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer") {
		if (parseFloat(navigator.appVersion)>=4.0) {
			window.location="signok.html";
		}
		else {
			window.location="signwarn.html";
		}
	}
}

function blankFieldCheck() {
	for (var i = 0; i < arguments.length; i += 2) {
		if (!arguments[i]) {
			alert("Please enter " + arguments[i+1] + "!");
			return false;
		}
	}
	return true;
}

function validateSignForm() {
	var isFilled = blankFieldCheck(document.signForm.name.value, "your Name", 
					document.signForm.email.value, "your E-mail",
					document.signForm.company.value, "your Company Name",
					document.signForm.address1.value, "your Company Address",
					document.signForm.city.value, "your Company City",
					document.signForm.state.value, "your Company State",
					document.signForm.zip.value, "your Company Zip");
	if (isFilled) {
		if (document.signForm.course.selectedIndex==0) {
			alert("Please select a Course!");
			return false;
		}
	}	
	if (!isFilled) {
		return false;
	}
}

function validateResumeForm() {
	var isFilled = blankFieldCheck(document.resumeForm.userid.value, "your Login", 
					document.resumeForm.password.value, "your Password");
	if (!isFilled) {
		return false;
	}
}

function validateContactForm() {
	var isFilled = blankFieldCheck(document.contactForm.name.value, "your Name", 
					document.contactForm.email.value, "your E-mail", 
					document.contactForm.message.value, "your Message");
	if (isFilled) {
		var subject1 = document.contactForm.custom.checked;
		var subject2 = document.contactForm.standard.checked;
		var subject3 = document.contactForm.faaRegs.checked;
		var subject4 = document.contactForm.consult.checked;
		var subject5 = document.contactForm.probRes.checked;
		var subject6 = document.contactForm.m5Info.checked;
		var subject7 = document.contactForm.other.checked;
		if (!subject1 && !subject2 && !subject3 && !subject4 && !subject5 && !subject6 && !subject7) {
			alert("Please select a Subject!");
			return false;
		}
	}	
	if (!isFilled) {
		return false;
	}
}

function validateSelfAssessForm() {
	selOption.length = 0;	//initialize the array 
	var total = 15;
	for(a=0;a<total;a++){
		var yes = eval("document.selfAssessForm.q"+(a+1)+"[0].checked");
		var no = eval("document.selfAssessForm.q"+(a+1)+"[1].checked");
		//alert("option yes for "+(a+1)+" : "+yes+"\noption no for "+(a+1)+" : "+no);
		if(yes) { 
			selOption[a] = "Yes"; 
		} else if(no) {
			selOption[a] = "No";
		} else {
			selOption[a] = " ";
		}
		if(!yes && !no){
			alert("Please complete answering all the Questions!");
			return false;
		}
	}
	return true;
}

function paintResults() {
	var e = 0;
	var total = 15;
	var trapError = new Array();
	var answers = new Array("Yes","Yes","Yes","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes");
	//alert("Total Questions : "+total+"\nCorrect Answers :\n"+eval(answers)+"\nSelected Answers :\n"+eval(selOption));
	for(a=0;a<total;a++){
		if(selOption[a] != answers[a]){
			trapError[e] = "question "+(a+1)+" "+ selOption[a];
			e++;
		}
	}
	if(trapError.length>0){
		alert("Since you have answered \n"+trapError.join(",\n")+", \nyou are not FAA Inspection Ready!\nIf you think you need help, check out our consulting services.");
		return false;
	} else {
		alert("You have answered all questions correctly. Good Job!\n If you are still not completely confident of your readiness for a FAA inspection, check out our consulting services.");
		return true;
	}
}

