// form validation
// (c) 2007 Loco (Loohuis Consulting), http://www.loohuis-consulting.nl/
// This work is licensed under a 
// Creative Commons Attribution-Share Alike 3.0 Netherlands License
// see http://www.loohuis-consulting.nl/development/cc-by-sa.php

function validate(e)
{
    var elm = Event.element(e);
    // check mandatory elements
    var inputs = $$('.mandatory');
    var incomplete = false;
    inputs.each(function(i)
    {
        if (i.value.length == 0) {
            incomplete = true;
            i.up('li').addClassName('incomplete');
        }
        else
            i.up('li').removeClassName('incomplete');
    });
    if (incomplete) {
        Element.update('validateerror', 'Vul a.u.b. alle verplichte velden in.');
        Element.show('validateerror');
        Event.stop(e);
        return false;
    }
    return true;
}

// initialise page
function init()
{
    var registerForm = $('ontmoetingsdag');
    if (registerForm) {
        Event.observe(registerForm, 'submit', validate);
    }
    if ($('formfocus'))
        $('formfocus').focus();
}

document.observe('dom:loaded', init);

