function validate_form() {
  validity = true;
  
  if(document.getElementById("terminauswahl")){
    if (document.getElementById("terminauswahl").selectedIndex == "0") {
      validity = false; alert('Bitte wählen Sie einen Kurstermin.'); 
    }
    else{
    
      if (!text_in(document.form.vorname.value) || !text_in(document.form.nachname.value)) {
        validity = false; alert('Bitte geben Sie Vor- und Nachnamen an!'); 
      } 
      else {
        if (!text_in(document.form.strasse.value) || !text_in(document.form.plz.value)  || !text_in(document.form.ort.value)) {
          validity = false; alert('Bitte prüfen Sie Ihre Adressangaben bzw. vervollständigen Sie diese!'); 
        } 
        else {
          if (!text_in(document.form.telefon.value)) {
            validity = false; alert('Bitte geben Sie Ihre Telefonnummer an!'); 
          } 
          else {
            if (!text_in(document.form.email.value)) {
              validity = false; alert('Bitte geben Sie Ihre Emailadresse an.'); 
            }
            else{
              if (!check_email(document.form.email.value)) {
                validity = false; alert('Bitte überprüfen Sie Ihre E-Mail-Adresse.');
              }
            }
          }
        }
      }
    }
  }
  return validity;
}

function text_in(text) {
  return (text.length > 0);
}

function check_email(address) {
  if ((address == "")
    || (address.indexOf ('@') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}

function check_url(address) {
  if ((address == "")
    || (address.indexOf ('http://') == -1)
    || (address.indexOf ('.') == -1))
      return false;
  return true;
}
