$(function()
{

$('form').submit
(
    function()
    {
        var error = false;

        var pflichtfelder = ['name', 'vorname', 'mail', 'mitteilung'];

        for (var i=0; i<pflichtfelder.length; i++)
        {
            if (!$('#' + pflichtfelder[i]).val().length)
            {
                error = true;
            }
        }


        if (document.getElementById('anrede').options.selectedIndex == 0)
        {
            error = true;
        }

        if (error)
        {
            var select = $('#not-all-fields');

            select.dialog(dialog);
            select.dialog('option', 'title', 'Da stimmt was nicht ...');
            select.dialog('option', 'width', 260);
            select.dialog('open');

            return false;
        }
        else
        {
            return true;
        }
    }
);

});
