﻿
//function
function validateForm(){
        if ($('#nachnameErr').is(':visible') ){
            $('#nachname').addClass("redBorder");
        }
        if ($('#vornameErr').is(':visible') ){
            $('#vorname').addClass("redBorder");
        }
        if ($('#unternehmenErr').is(':visible')){
            $('#unternehmen').addClass("redBorder");
        }
        if ($('#emailErr').is(':visible')) {
            $('#email').addClass("redBorder");
        }
        if ($('#str_nrErr').is(':visible') ){
            $('#str_nr').addClass("redBorder");
        }
        if ($('#plzErr').is(':visible') ){
            if($('#plz').val() < 1){
                $('#plz').addClass("redBorder");
            }
            if($('#ort').val() < 1){
                $('#ort').addClass("redBorder");
            }
        }
        if ($('#ortErr').is(':visible')){
            $('#ort').addClass("redBorder");
        }
        if ($('#messageErr').is(':visible') ){
            $('#message').addClass("redBorder");
        }
        if($('#tageErr').is(':visible') ){
            $('#tageErr').addClass("redBorder");
        }
}
function checkInput(element){
    if ($(element).val().length > 0){
        $(element).removeClass("redBorder");
        if(($(element).attr("id")=='plz') && $('#ort').val().length < 1){
            return;
        }
        if(($(element).attr("id")=='ort') && $('#plz').val().length < 1){
            return;
        }
        if(($(element).attr("id")=='ort')){
            $('#plzErr').fadeOut("slow");
        }else{
            $('#'+$(element).attr("id")+'Err').fadeOut("slow");
        }
    }else{
        $(element).addClass("redBorder");
        if(($(element).attr("id")=='ort')){
            $('#plzErr').fadeIn("slow");
        }else{
            $('#'+$(element).attr("id")+'Err').fadeIn("slow");
        }
    }
}
$(document).ready(function(){
 validateForm();
 if($('#thema').val()=="11" ||$('#thema').val()=="12"){
  $('#anzahl_tage_wrapper').show();
 }
  $('#thema').change(function(){
  if($(this).val() == "11" || $(this).val() == "12"){
   $('#anzahl_tage_wrapper').show("slow");
  }else{
   $('#anzahl_tage_wrapper').hide("slow");
  }
 });
});
