$(document).ready(function() {
    $.subscribe('removeErrors', function(event, data) {
        $('.errorLabel').html('').removeClass('errorLabel');
        $('#formerrors').html('');
    });

/*
    $('#menu > ul > li').click(function(){
        $('div#menu > ul > li').removeClass('selected');
        $(this).addClass('selected');
    },function(){

    });

    $('#menu > ul > li').hover(function(){
        $(this).addClass('hover');
    },function(){
        $(this).removeClass('hover');
    });
*/
});

function customValidation(form, errors) {

    // List for errors
    var list = $('#formerrors');

    // Handle non field errors
    if (errors.errors) {
        $.each(errors.errors, function(index, value) {
            list.append('<li>' + value + '</li>\n');
        });
    }

    // Handle field errors
    if (errors.fieldErrors) {
        $.each(errors.fieldErrors, function(index, value) {
            var elem = $('#' + index + 'Error');
            if (elem) {
                elem.html(value[0]);
                elem.addClass('errorLabel');
            }
        });
    }
}

