
function openDesc(testNum) {
	window.open("/desc_popup.php?tn=" + testNum,"desc","toolbar=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=no, width=420, height=500")
}

function openTrainingWindow(testNum) {
	window.open("/tr_read_printable.php?tn=" + testNum,"desc","toolbar=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, width=960, height=650")
}

function openTestWindow(testNum) {
	window.open("/tr_post_printable.php?tn=" + testNum,"desc","toolbar=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, width=960, height=650")
}

function openPopupPrivacy() {
	window.open("/popup_privacy.php?", "info","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=420, height=300")
}

function openInfo(item) { // IF USER IS FROM MICHIGAN ON SIGN UP IT POPS WINDOW / IF USER LOGS IN IT POPS WINDOW - UNLESS COOKIE HAS BEEN SET BECAUSE WINDOW ALREADY POPPED
	micook = get_cookie('micookie');
	if(item.value == "MI" && micook != "1") {
		window.open("/popup_info.php?", "info","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=260");
		document.cookie = 'micookie=1; expires="" ; path=/'
	}
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}



function checkSignInForm() {
	if (document.form1.first_f.value == '') {
		alert("You must enter your first name.");
		document.form1.first_f.focus();
		return false;
	}
	if (document.form1.last_f.value == '') {
			alert("You must enter your last name.");
			document.form1.last_f.focus();
			return false;
	}
	if (document.form1.address_f.value == '') {
		alert("You must enter your address.");
		document.form1.address_f.focus();
		return false;
	}
	if (document.form1.city_f.value == '')	{
		alert("You must enter your city.");
		document.form1.city_f.focus();
		return false;
	}
	if (document.form1.state_f.value == '') {
		alert("You must enter your state.");
		document.form1.state_f.focus();
		return false;
	}			
	if (document.form1.zip_f.value == '') {
		alert("You must enter your zip.");
		document.form1.zip_f.focus();
		return false;
	}
	if (document.form1.email_f.value == '') {
		alert("You must enter your email.");
		document.form1.email_f.focus();
		return false;
	}
	if (document.form1.phone_1_f.value == '' || document.form1.phone_2_f.value == '' || document.form1.phone_3_f.value == '') {
		alert("You must enter your phone number.");
		document.form1.phone_1_f.focus();
		return false;
	}
	if (document.form1.howHear_f.value == '') {
		alert("Please let us know how you heard about us.");
		document.form1.howHear_f.focus();
		return false;
	}	
	if ((document.form1.licNum_f.value == '')) {
		alert("You may leave your license number blank but it will not show up on your certificate.");
		document.form1.licPrefix_f.focus();
	}
//	if (document.form1.exp_month.value == '' || document.form1.exp_year.value == '') {
//		alert("Please let us know when you license expires.");
//		document.form1.exp_month.focus();
//		return false;
//	}
	if (document.form1.pass_f.value == '' || document.form1.pass_verify_f.value == '') {
		alert("You must enter your password.");
		document.form1.pass_f.focus();
		return false;
	}		
	return true;
}

function checkEditForm() {
	if (document.form1.address_f.value == '') {
		alert("You must enter your address.");
		document.form1.address_f.focus();
		return false;
	}
	if (document.form1.city_f.value == '')	{
		alert("You must enter your city.");
		document.form1.city_f.focus();
		return false;
	}
	if (document.form1.state_f.value == '') {
		alert("You must enter your state.");
		document.form1.state_f.focus();
		return false;
	}			
	if (document.form1.zip_f.value == '') {
		alert("You must enter your zip.");
		document.form1.zip_f.focus();
		return false;
	}
	if (document.form1.email_f.value == '' && document.form1.old_email.value == '') {
		alert("You must enter your email.");
		document.form1.email_f.focus();
		return false;
	}
	if (document.form1.phone_1_f.value == '' || document.form1.phone_2_f.value == '' || document.form1.phone_3_f.value == '') {
		alert("You must enter your phone number.");
		document.form1.phone_1_f.focus();
		return false;
	}
	if ((document.form1.licPrefix_f.value == '') || (document.form1.licNum_f.value == '')) {
		alert("You must enter your full license number.");
		document.form1.licPrefix_f.focus();
		return false;
	}
	if (document.form1.exp_month_f.value == '' || document.form1.exp_year_f.value == '') {
		alert("Please let us know when you license expires.");
		document.form1.exp_month_f.focus();
		return false;
	}
	if (document.form1.old_pass.value != '' && (document.form1.new_pass.value == '' || document.form1.new_pass_verify.value == '')) {
		alert("You must enter your new passwords.");
		document.form1.new_pass.focus();
		return false;
	}		
	return true;
}

function ccCheck() {
	if ((document.form3.cardType[0].checked == false) && (document.form3.cardType[1].checked == false) && (document.form3.cardType[2].checked == false)) {
		alert("You must select your credit card type.");
		return false;
	}
	input = document.form3.cardNum.value;
	if (input == '') {
		alert("You must enter your credit card number.");
		document.form3.cardNum.focus();
		return false;
	}
  	for(var i=0; i<input.length; i++) {
		if (isNaN(input.charAt(i))) {
			alert("The credit card you entered appears to be invalid");
			return false;
		}
	}

	if (document.form3.expMonth.value == '') {
		alert("You must enter your expiration month.");
		document.form3.expMonth.focus();
		return false;
	}
	if (document.form3.expYear.value == '') {
		alert("You must enter your expiration year.");
		document.form3.expYear.focus();
		return false;
	}
	return true;
}

function checkEdit() {
	if (document.form5.first_f.value == '') {
		alert("You must enter your first name.");
		document.form5.first_f.focus();
		return false;
	}
	if (document.form5.last_f.value == '') {
			alert("You must enter your last name.");
			document.form5.last_f.focus();
			return false;
	}
	if (document.form5.address_f.value == '') {
		alert("You must enter your address.");
		document.form5.address_f.focus();
		return false;
	}
	if (document.form5.city_f.value == '')	{
		alert("You must enter your city.");
		document.form5.city_f.focus();
		return false;
	}
	if (document.form5.state_f.value == '') {
		alert("You must enter your state.");
		document.form5.state_f.focus();
		return false;
	}			
	if (document.form5.zip_f.value == '') {
		alert("You must enter your zip.");
		document.form5.zip_f.focus();
		return false;
	}
	return true;
}