function set_ok(elname) {
	$('#' + elname).text('OK');
	$('#' + elname).removeClass();
	$('#' + elname).addClass('green');
}

function set_nok(elname) {
	$('#' + elname).text('NOK');
	$('#' + elname).removeClass();
	$('#' + elname).addClass('red');
}

function check_name(el) {
	if ($(el).val().length > 0) {
		set_ok('name_feedback');
	} else {
		set_nok('name_feedback');
	}
}

function check_email(el) {
	var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (re.test($(el).val())) {
		set_ok('email_feedback');
	} else {
		set_nok('email_feedback');
	}
}    		

function check_password(el) {
	if ($(el).val().length > 7) {
		set_ok('password_feedback');
	} else {
		set_nok('password_feedback');
	}
}

function check_password_repetition(el) {
	if ($(el).val() == $('#password').val()) {
		set_ok('password_repetition_feedback');
	} else {
		set_nok('password_repetition_feedback');
	}
}

function check_all() {
	if ($('#password_repetition_feedback').text() == 'OK' &&
		$('#password_feedback').text() == 'OK' &&
		$('#email_feedback').text() == 'OK' &&
		$('#name_feedback').text() == 'OK' &&
		$('[name="gender"]').is(':checked')
		) {
			if ($("[name='gender']:checked").val() == 'female') {
				alert('Paní ' + $('#name').val() + ' zaregistrována.');
			} else {
				alert('Pan ' + $('#name').val() + ' zaregistrován.');
			}
	} else {
		alert('Údaje nebyly vyplněny korektně.');
	}
}