Event.observe(window, 'load', function() {
    
    //make sure date of birth field has format DD/MM/YYYY
    Event.observe('user_register', 'submit', function(event) {
    	if(!correct_date_format('dob')) {
    	    Event.stop(event);
    		alert('Incorrect Date of birth. Make sure your Date of Birth is in the format DD/MM/YYYY');
    		Field.focus('dob');	
    	}
    });
    
    //if doctor is selected, show GMC registration field, specialty field and hospital field 
    Event.observe('profession', 'change', function() {
        if($F('profession') == 1) {
        	new Effect.multiple(['gmc_registration_div', 'specialty_div', 'place_of_employment_div'], Effect.Appear);
        } else {
        	new Effect.multiple(['gmc_registration_div', 'specialty_div', 'place_of_employment_div'], Effect.Fade);
        }
    });
    
});
