// JavaScript Document

var validate, required, captcha, nocaptcha, first;

function check_contact_form() {
    validate = false;
    required = false;
    captcha = false;
    nocaptcha = false;
    first = null;
    var pattern = /.*\@.*\..*/;

    if ((pattern.test(document.contact_form.email.value)) == false) {
        validate = true;
        if (!first)
            first = 'email';
    }

    if (document.contact_form.email.value == "") {
        document.contact_form.email.className = 'contact_input_selected';
        if (!first)
            first = 'email';
        required = true;
    }
    else
        document.contact_form.email.className = 'contact_input';

    check_result_contact_form(document.contact_form.self.value);
}

function check_result_contact_form(self) {
    var error_array = new Array();
    if (validate)
        error_array.push('Bitte geben Sie eine g&uuml;ltige E-Mail-Adresse ein.');
    if (required)
        error_array.push('Bitte f&uuml;llen Sie alle Pflichtfelder aus.');
    if (captcha)
        error_array.push('Der Sicherheitscode ist falsch.');
    if (nocaptcha)
        error_array.push('Bitte f&uuml;llen Sie den Sicherheitscode aus, dieser dient als Schutz vor Missbrauch.');

    if (error_array.length) {
        document.getElementById('contact_form_error').innerHTML = error_array.join("<br />") + '<br />&nbsp;';
        if (first) {
            eval('document.contact_form.' + first + '.focus();');
            eval('document.contact_form.' + first + '.select();');
        }
    } else {
        document.contact_form.method = "POST";
        document.contact_form.action = self;
        document.contact_form.submit();
        return true;
    }
}
