// JavaScript Document

// [BEGIN] alerts the index of the selected option within form ***************************************************************************************
function checkSearchBy() {
	var whichOne = document.searchForm.searchBy.selectedIndex;
	if (whichOne != 0) {
		document.getElementById("exactDiv").style.visibility = "visible";
	} else {
		document.getElementById("exactDiv").style.visibility = "hidden";
	}
}
function changeListAll() {
		document.searchForm.listAll.value = "yes";
}
// popup for email
function emailPopup(url) {
	window.open(url, "Email", "status = 1, height = 500, width = 600, resizable = 1" );
}
// [END]alerts the index of the selected option within form ************

// [BEGIN] validation for form ***************************************************************************************
function validate(form, img, ans_1, email) {
	// is checking for which img was displayed
	switch (img) {
		case 0:
			ans_2 = 2;
			break;
		case 1:
			ans_2 = 4;
			break;
		case 2:
			ans_2 = 4;
			break;
		case 3:
			ans_2 = "red";
			break;
		case 4:
			ans_2 = 6;
			break;
		case 5:
			ans_2 = "yellow";
			break;
		case 6:
			ans_2 = 8;
			break;
		case 7:
			ans_2 = "blue";
			break;
		case 8:
			ans_2 = 10;
			break;
		case 9:
			ans_2 = "brown";
			break;
	}
	// checks for valid email address and then if question was answered correctly
	if ((email.indexOf(".") > 2) && (email.indexOf("@") > 0)) {
		if (ans_2 == ans_1) {
			document.getElementById(form).verify.value = 'yes';
			document.getElementById(form).submit();
		} else {
			alert('The human verification question is incorrect! Make sure you do not use any capital letters.  Please try again.');
		}
	} else {
		alert('Your email seems to be incorrect or missing.  Please try typing it again.');
	}
}
// [END] validation for form ***********

