function CheckBoxesOnOff(FieldName) {
  var checks    = document.getElementsByName(FieldName);
  var boxLength = checks.length;

  if ( checks[0].checked == true )
    for ( i=0; i < boxLength; i++ ) checks[i].checked = false;
  else
    for ( i=0; i < boxLength; i++ ) checks[i].checked = true;
}


function checkAllMail()
{ count = document.MailFormular.elements.length;
  for (i=0; i < count; i++)
  document.MailFormular.elements[i].checked = 1;
}

function uncheckAllMail()
{ count = document.MailFormular.elements.length;
  for (i=0; i < count; i++)
  document.MailFormular.elements[i].checked = 0;
}



function chkformular()
{
iFirma       = "Organisation name missing!";
iOrt         = "City missing!";
iRegion      = "Region/Country missing";
iMail        = "E-Mail address missing or wrong!";
iBusinessTyp = "Organisation Type missing";
iAnrede      = "Gender (Mr/Ms) missing";
iVorname     = "First Name missing!";
iNachname    = "Last Name missing!";
iPosition    = "Your Position is missing";
iStatus      = "Who signs? A private person or an organisation?";
iAntispam    = "Antispam Code missing or wrong";

if(document.Formular.firma.value == "")
 { alert(iFirma);
   document.Formular.firma.focus();
   return false; }

if(document.Formular.ort.value == "")
 { alert(iOrt);
   document.Formular.ort.focus();
   return false; }

/* Unterschiedliche Abfrage bei select / radio */

if (document.Formular.region.selectedIndex < 1)
{ alert(iRegion);
  document.Formular.region.focus();
  return false; }

if(document.Formular.orgtype)
{
if (document.Formular.orgtype.selectedIndex < 1)
{ alert(iBusinessTyp);
  document.Formular.orgtype.focus();
  return false; }

}


if(document.Formular.anrede[0].checked == false &&
   document.Formular.anrede[1].checked == false )
 { alert(iAnrede);
   document.Formular.anrede[0].focus();
   return false; }

if(document.Formular.vorname.value == "")
 { alert(iVorname);
   document.Formular.vorname.focus();
   return false; }

if(document.Formular.nachname.value == "")
 { alert(iNachname);
   document.Formular.nachname.focus();
   return false; }

if(document.Formular.position.value == "")
 { alert(iPosition);
   document.Formular.position.focus();
   return false; }

if(chk_mail(document.Formular.kundenmail.value) == false)
 { alert(iMail);
   document.Formular.kundenmail.focus();
   return false; }

if(document.Formular.status[0].checked == false &&
   document.Formular.status[1].checked == false )
 { alert(iStatus);
   document.Formular.status[0].focus();
   return false; }


if(! document.Formular.update && document.Formular.antispam && document.Formular.antispam.value != document.Formular.antispam2.value)
 { alert(iAntispam);
   document.Formular.antispam.focus();
   return false; }


} // ###############  Ende Check Formular  #############################



function isInt(wert) {
  if (wert == "") return false;
  for (i=0; i<4;i++) {
    if (wert.charAt(i) < "0") { return false; }
    if (wert.charAt(i) > "9") { return false; }
  }
}

function chk_mail(s)
{
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}