function checkcodewoord() {
    var codewoord = $('#codewoord').val();
    codewoord = jQuery.trim(codewoord);
    if (codewoord.toUpperCase() == 'SISIISNOGFRIZZR') {
        $('#registreer').show();   
        $('#melding').hide();   
        $('#codeform').hide();   
    } else {
        $('#registreer').hide();   
        $('#codeform').show();   
        $('#melding').show();   
    }
}

function checkform() {
    var checked = 0;
    $('.verplicht').each(function() {
        $(this).checkvalue();
    });
    checked = $('.error').size();
    if ($('#voorwaarden')[0].checked == false) {
        checked = checked + 1;
    }
    var strawberry = 1;
    var tropical = 1;
    $("input:radio[@name='strawberry']").each(function() {
        if ($(this).attr("checked") == true) {
            strawberry = 0;
        }
    });
    $("input:radio[@name='tropical']").each(function() {
        if ($(this).attr("checked") == true) {
            tropical = 0;
        }
    });
    if (strawberry == 1) {
        $('#strawberry').addClass('error');
    }
    if (tropical == 1) {
        $('#tropical').addClass('error');
    }
    checked = checked + strawberry;
    checked = checked + tropical;
    if (checked == 0) {
        $('#registreer').submit();
    }
	return false;
}

$(document).ready(function() {
    jQuery.fn.extend({
        checkvalue: function() {
            var o = this[0];
            if (o.name == 'email') {
                var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
                if (o.value.match(email) == null) {
                    $(o).addClass('error');
                } else {
                    $(o).removeClass('error');
                }
            } else {
                if ($(o).val() == "") {
                    $(o).addClass('error');
                } else {
                    $(o).removeClass('error');
                }
            }
        }
    });
    $('.verplicht').blur(function() {
        $(this).checkvalue();
    });
    $('#verzenden').click(function() {
        checkform();
    });
    $("input:radio[@name='tropical']").each(function() {
        $(this).click(function() {
            $('#tropical').removeClass('error');
        });
    });
    $("input:radio[@name='strawberry']").each(function() {
        $(this).click(function() {
            $('#strawberry').removeClass('error');
        });
    });
});



