$(function() {
	$('form').bind('submit', validateFtaFormAccessible)
});

function validateFtaForm() {
	$('#errorMsg').remove();
	var errMsg = '';
	
	//LicenseID
	if (!$('#licenseid').val() || !/^\d{8}$/i.test($('#licenseid').val()))
		errMsg = errMsg + '<li>Drivers License # must be exactly 8 digits</li>';
	
	//Birth Month
	if ($('#birthmonth option:selected').val() == 0)
		errMsg = errMsg + "<li>You must select your birth month</li>";
	
	//Birth Day
	if ($('#birthday option:selected').val() == 0)
		errMsg = errMsg + "<li>You must select your birth day</li>";
	
	//Birth Year
	if (!$('#birthyear').val() || !/^\d{4}$/i.test($('#birthyear').val()))
		errMsg = errMsg + "<li>Please enter a valid birth year</li>";
	
	if (errMsg.length > 0) {
		errMsg = '<div id="errorMsg"><h3>There were problems processing your form</h3><ul>' + errMsg + '</ul></div>';
		$('form legend').after(errMsg);
		return false;
	}
	else
		return true;
}

function validateFtaFormAccessible() {
	//LicenseID
	if (!$('#licenseid').val() || !/^\d{8}$/i.test($('#licenseid').val())) {
		alert('Drivers License # must be exactly 8 digits');
		return false;
	}
	
	//Birth Month
	if ($('#birthmonth option:selected').val() == 0) {
		alert('You must select your birth month');
		return false;
	}
	
	//Birth Day
	if ($('#birthday option:selected').val() == 0) {
		alert('You must select your birth day');
		return false;
	}
	
	//Birth Year
	if (!$('#birthyear').val() || !/^\d{4}$/i.test($('#birthyear').val())) {
		alert('Please enter a valid birth year');
		return false;
	}
	
	return true;
}
