function $(p) {
	return document.getElementById(p);
}
if ($('submit_btn'))
	$('submit_btn').onclick = do_submit;
if ($('submit_btn_2'))
	$('submit_btn_2').onclick = do_submit2;

function check_email(p) {
	return ((/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-zA-Z]{2}|com|org|net|gov|biz|info|name|aero|biz|info|jobs|museum)\b/.test(p)) ? true : false);
}

function check_empty(p) {
	try {
		return (p == null || p == '');
	} catch (ex) {
		return (true);
	}
}

function do_submit() {
	if (check_empty($('full_name').value)) {
		alert('The full name cannot be empty.  Please fill this information in and try again.');
		$('full_name').focus();
		return false;
	}
    if (!check_email($('email').value)) {
        alert('The email address that you entered does not appear to be in a valid format.  Please try again.');
        $('email').focus();
		return false;
	}
	$('forgot_first').submit();
	return true;
}

function do_submit2() {
	if (check_empty($('question').value)) {
		alert('The answer to the secret question cannot be empty.  Please fill this information in and try again.');
		$('question').focus();
		return false;
	}
	$('forgot_second').submit();
	return true;
}