
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
/*function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.Section.value)){
return (true)
}
alert("Please enter your email.")
return (false)
}
*/

$(document).ready(function(){
    $('td.mandatory').append("<span class='mandatory-indicator'>*</span>");
    $('#BlitzChampionship').bind('change', changeCountry);
    $("#DateOfBirth").datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: '1920:2009'
	});
    changeCountry();
});

function validate_form ()
{
	clearPreviousErrors();
	var valid = true;
	$('.mandatory-value').each(function(){
		if (this.value == "") {
			$(this).addClass("invalid");
			valid = false;
           }
	});
	if (!valid) {
		$('#error-message').text('Not all required fields were completed');
	}
	return valid;
}

function makeMandatory(mandatoryClass, nonMandatoryClass) {
	$('.' + mandatoryClass).addClass('mandatory-value');
	$('.' + nonMandatoryClass).removeClass('mandatory-value');
}

function clearPreviousErrors() {
	$('*').removeClass('invalid');
	$('#error-message').empty();
}

function changeCountry() {
	clearPreviousErrors();
	if ($('#BlitzChampionship').val() == 'ZA') {
		makeMandatory('chessa', 'fide');
	}else{
		makeMandatory('fide', 'chessa');
	}
}


//  End -->
