function ZeichenZaehlen() {
 max = 2500;
 anz = document.Formular3.OrgBackground.value.length+1;
 document.Formular3.AnzahlZeichen.value = anz;
 }

function ZeichenZaehlen2() {
 max = 2500;
 anz = document.Formular4.RTDBackground.value.length+1;
 document.Formular4.AnzahlZeichen.value = anz;
 }


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 chkformular2()
{
 /*
 iBranche = "Please select at least one RTD sectors!";

 var chks = document.Formular2.elements['branche[]'];
 var count = 0;
 for (var i=0;i<chks.length;i++)
    if (chks[i].checked) count +=1;
 if(count == 0) { alert(iBranche);
    chks[0].focus();
    return false;
 }
 */
}

function chkformular3()
{
 /*
 iOrginfoTitel   = "Central RTD focus of your organization is missing";
 iRTD_activity   = "RTD activity is missing";
 iRTD_experience = "RTD experience is missing";

 if(document.Formular3.orginfo_titel.value == "")
  { alert(iOrginfoTitel);
    document.Formular3.orginfo_titel.focus();
    return false; }

 if(document.Formular3.rtd_experience.value == "")
  { alert(iRTD_experience);
    document.Formular3.rtd_experience.focus();
    return false; }
 */
}


function chkformular()
{
iFirma       = "Organisation name missing!";
iStrasse     = "Street missing!";
iPLZ         = "Postal Code missing!";
iOrt         = "City missing!";
iRegion      = "Region/Country missing";
iTelefon     = "Phone missing!";
iMail        = "E-Mail address missing or wrong!";
iWWW         = "Website address missing";
iGJahr       = "Year of foundation missing";
iMitarbeiter = "Number of employees missing";
iBusinessTyp = "Organisation Type missing";
iAnrede      = "Gender (Mr/Ms) missing";
iVorname     = "First Name missing!";
iNachname    = "Last Name missing!";
iPosition    = "Your Position is missing";
iSprache     = "Which language do you speak?";
iPasswort1   = "Passwort missing or to short (min. 4 characters)!";
iApproval    = "Please accept that your data can be used for the CENTRIS project";
iAntispam    = "Antispam Code missing or wrong";

if(document.Formular.firma.value == "")
 { alert(iFirma);
   document.Formular.firma.focus();
   return false; }

if(document.Formular.strasse.value == "")
 { alert(iStrasse);
   document.Formular.strasse.focus();
   return false; }

if(document.Formular.plz.value == "")
 { alert(iPLZ);
   document.Formular.plz.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 < 2)
{ alert(iRegion);
  document.Formular.region.focus();
  return false; }


if(document.Formular.telefon.value == "")
 { alert(iTelefon);
   document.Formular.telefon.focus();
   return false; }

if(chk_mail(document.Formular.kundenmail.value) == false)
 { alert(iMail);
   document.Formular.kundenmail.focus();
   return false; }

if(document.Formular.www.value == "")
 { alert(iWWW);
   document.Formular.www.focus();
   return false; }

if(document.Formular.orgtype)
{
if (document.Formular.orgtype.selectedIndex < 2)
{ alert(iBusinessTyp);
  document.Formular.orgtype.focus();
  return false; }

}

if(document.Formular.anzahl)
{
 var anzahl_ok = false;
 for (var i=0; i<document.Formular.anzahl.length; i++)
    if (document.Formular.anzahl[i].checked) anzahl_ok = true;
 if (!anzahl_ok) { alert(iMitarbeiter);
                   document.Formular.anzahl[0].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; }

var chks = document.Formular.elements['sprache[]'];
if(chks)
{ var count = 0;
  for (var i=0;i<chks.length;i++)
    if (chks[i].checked) count +=1;
  if (count == 0) { alert(iSprache);
                    chks[0].focus();
                    return false;
                  }
}

if(document.Formular.passkunde.value.length < 4)
 { alert(iPasswort1);
   document.Formular.passkunde.focus();
   return false; }

if(document.Formular.approval.value != "1")
 { alert(iApproval);
   document.Formular.approval.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);
}
