function tp_formValidate(theForm) {
 
var strPflichtfeld = "Eines der Formular-Pflichtfelder wurde nicht vollständig ausgefüllt: \n"
var strNurZiffern = " (Nur Ziffern)"
var strUnzulZeich = "Unzulaessige Zeichen in: "

// Pflichtfelder: VORNAME, NAME, ADRESSE1, PLZ, ORT, TEL, email.

// ACHTUNG: Alle formularspezifischen Felder müssen GROSS geschrieben werden, alle Steuerungs- und oder Hiddenfelder (email, receipient etc.) klein.

with (theForm) {

// VORNAME, NAME

if (hasElement(theForm,"VORNAME") && (is_empty_alert(VORNAME, strPflichtfeld+"Vorname"))) return false;
if (hasElement(theForm,"NAME") && (is_empty_alert(NAME, strPflichtfeld+"Name"))) return false;

// ADDRESS1

if (hasElement(theForm,"ADRESSE1") && (is_empty_alert(ADRESSE1, strPflichtfeld+"Adresse (Straße bzw. Postfach)"))) return false;

if (hasElement(theForm,"PLZ") && (is_empty_number(PLZ, strPflichtfeld+"PLZ", strUnzulZeich+"PLZ"+strNurZiffern))) return false;

if (hasElement(theForm,"ORT") && (is_empty_alert(ORT, strPflichtfeld+"Ort"))) return false;

// TEl  

  if (hasElement(theForm,"TEL") && (is_empty_alert(TEL, strPflichtfeld+"Tel"))) return false;
    
// EMAIL 

if (hasElement(theForm,"email")) 
  with (document.forms[0].elements["email"]) {
    if (!checkEmail(value)) {
       alert("Bitte geben Sie eine korrekte Email-Adresse an!\nFormat: xxx@xxx.xx");
       focus();
       return false;
    } // if 
  } // with Email
 } // with theForm
 
 
} // function tp_formvalidate


function hasElement(frm, eName) {
  var laenge=document.forms[0].elements.length;
  for(i=0; i< laenge; i++) {
    if ((document.forms[0].elements[i].type=="text") &&
        (document.forms[0].elements[i].name == eName)) return true;
  }
  // alert("Feld [",eName,"] existiert nicht!");
  return false;
};


function checkEmail(address) {
  with (address)
    if ((this == "") || (indexOf ('@') == -1) || (indexOf ('.') == -1))
      return false
   else return true;
}

function checkURL(address) {
  if ((address == "")
    || (address.indexOf ('http://') == -1)
    || (address.indexOf ('.') == -1))
      return false
  else return true;
}

function is_empty(text) {return (text.length == 0);}

function is_empty_alert(Feld, strAlert) {
  with (Feld) 
    if (is_empty(value)) {
      alert(strAlert);
      focus();
      return true;
    } 
    else return false
}

function is_empty_number(Feld, strIsEmpty, strNoNumber) {
  var localNoNumberFlg = 0
  with  ( Feld ) {
    if (is_empty_alert(Feld, strIsEmpty)) return true;
    for(i=0; i < value.length; i++)
      if(value.charAt(i) < "0" || value.charAt(i) > "9")
        localNoNumberFlg = 1;
    if(localNoNumberFlg == 1) {
      alert(strNoNumber);
      focus();
      return true;
    } // if
  }  // with 
  return false;
} // is_number


