function Fenster (Dateiname,Hoehe)
{
 win = window.open(Dateiname, "Zweitfenster", 'width=600, height='+Hoehe+', top=50, resizable=1, scrollbars=auto');
 win.focus();
}

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       = "Bitte einen Firmennamen eingeben!";
iStrasse     = "Bitte eine Straße eingeben!";
iPLZ         = "Bitte eine Postleitzahl eingeben!";
iOrt         = "Bitte einen Ort eingeben!";
iRegion      = "Bitte ein Land auswählen";
iTelefon     = "Bitte eine Telefonnummer eingeben!";
iMail        = "E-Mail addresse fehlt oder fehlerhaft!";
iGJahr       = "Bitte Gründungsjahr angeben";
iZahlenOnly  = "Bitte nur Ziffern eingeben";
iMitarbeiter = "Bitte Zahl der Mitarbeiter angeben";
iBusinessTyp = "Bitte den Unternehmenstyp angeben";
iAnrede      = "Bitte Anrede Herr/Frau angeben";
iVorname     = "Bitte einen Vornamen angeben!";
iNachname    = "Bitte einen Nachnamen angeben!";
iFunktion    = "Bitte Ihre Position/Funktion angeben!";
iSprache     = "Welche Sprachen sprechen Sie?";
iBranche     = "Bitte eine Branche auswählen";
iPasswort    = "Bitte ein Passwort angeben (min. 4 Zeichen)!";
iKooperation = "Für welche Arten von Kooperation interessieren Sie sich?";
iProfilTitel = "Titel - Über was wollen Sie mit wem reden fehlt.";
iText1       = "Angaben zum Produkt, Service, Know-how fehlen";
iText2       = "Angaben zu Kooperationswunsch fehlen.";
iText3       = "Kurze Firmenbeschreibung fehlt";
iFrage1      = "Frage1";
iFrage2      = "Frage2";
iFrage3      = "Frage3";
iFrage4      = "Frage4";
iFrage5      = "Frage5";
*/

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!";
iGJahr       = "Year of foundation missing (please enter digits only)";
iZahlenOnly  = "Please, enter digits only";
iMitarbeiter = "Number of employees missing (please enter digits only)";
iMitarbeiterRTD = "Number of employees working in RTD missing (please enter digits only)";
iMitarbeiter2= "Number of employees in RTD must be lower than total number of employees";
iExport      = "Export activities missing";
iBusinessTyp = "Organisation Type missing";
iAnrede      = "Gender (Mr/Ms) missing";
iVorname     = "First Name missing!";
iNachname    = "Last Name missing!";
iFunktion    = "Position / Function missing!";
iSprache     = "Which language do you speak?";
iPrimeClass  = "Primary classification missing!";
iBranche     = "Thematic areas (branches) missing!";
iActivities  = "Core competences missing!";
iPasswort    = "Passwort missing or to short (min. 4 characters)!";
iRetypePasswort = "Password verification failed";
iProfilTitel = "Your company in 2 sentences";
iProfilTitelDE = "Your company in 2 sentences (in German)";
iText1       = "Short description about Research & Development activities missing";
iText2       = "Short description about product, technology, service, know-how missing";
iText3       = "Short description about international activities missing";
iText4       = "Short description about company/organisation missing";
iTextzulang  = "Please, enter a maximum of 2500 characters only";

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; }

if (document.Formular.region.selectedIndex < 1)
{ alert(iRegion);
  document.Formular.region.focus();
  return false; }


if(document.Formular.telefon.value.length < 4)
 { alert(iTelefon);
   document.Formular.telefon.focus();
   return false; }

if(document.Formular.fax.value == "")
 { alert("Bitte eine Faxnunmer eingeben!");
   document.Formular.fax.focus();
   return false; }
*/

if(chk_mail(document.Formular.kundenmail.value) == false)
 { alert(iMail);
   document.Formular.kundenmail.focus();
   return false; }

/*
var chks = document.Formular.elements['business[]'];
var count = 0;
for (var i=0;i<chks.length;i++)
 if (chks[i].checked) count +=1;
   //alert(chks[i].value);
if (count == 0) { alert(iBusinessTyp);
                  chks[0].focus();
                  return false;
                }

var chks = document.Formular.elements['primclass[]'];
var count = 0;
for (var i=0;i<chks.length;i++)
   if (chks[i].checked) count +=1;
if (count == 0) { alert(iPrimeClass);
                  chks[0].focus();
                  return false;
                }

var chks = document.Formular.elements['activities[]'];
var count = 0;
for (var i=0;i<chks.length;i++)
   if (chks[i].checked) count +=1;
if (count == 0) { alert(iActivities);
                  chks[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(iFunktion);
   document.Formular.position.focus();
   return false; }

var chks = document.Formular.elements['sprache[]'];
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.gjahr.value == "" || isInt(document.Formular.gjahr.value)== false ||
   Number(document.Formular.gjahr.value) < 1800 || Number(document.Formular.gjahr.value) > 2020)
 { alert(iGJahr);
   document.Formular.gjahr.focus();
   return false;
 }

if(document.Formular.gjahr.value != "")
 {
  ist_zahl=true;
  eingabe = document.Formular.gjahr;
  for(n=0;n<eingabe.length;n++)
   { if(eingabe.charAt(n)<"0"||eingabe.charAt(n)>"9")
       ist_zahl=false;
   }

  if(ist_zahl == false)
    {
      alert(iZahlenOnly);
      document.Formular.gjahr.focus();
      return false;
    }
 }


if(document.Formular.anzahl.value == "" || isInt(document.Formular.anzahl.value)==false)
 { alert(iMitarbeiter);
   document.Formular.anzahl.focus();
   return false; }

if(document.Formular.anzahlrtd.value == ""  || isInt(document.Formular.anzahlrtd.value)==false)
 { alert(iMitarbeiterRTD);
   document.Formular.anzahlrtd.focus();
   return false; }

if( Number(document.Formular.anzahlrtd.value) > Number(document.Formular.anzahl.value) )
 { alert(iMitarbeiter2);
   document.Formular.anzahlrtd.focus();
   return false;
 }

var expo = document.Formular.elements['export'];
if(expo[0].checked == false &&
   expo[1].checked == false )
  { alert(iExport);
    expo[0].focus();
    return false; }

var chks = document.Formular.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;
                }

if(document.Formular.profiltitel.value == "")
 { alert(iProfilTitel);
   document.Formular.profiltitel.focus();
   return false; }


if(document.Formular.text4.value == "" || document.Formular.text4.value.length > 2500)
 {
   if(document.Formular.text4.value == "") alert(iText4);
   else                                    alert(iTextzulang + "\nActual length: " + document.Formular.text4.value.length);
   document.Formular.text4.focus();
   return false; }

if(document.Formular.text1.value == "" || document.Formular.text1.value.length > 2500)
 {
   if(document.Formular.text1.value == "") alert(iText1);
   else                                    alert(iTextzulang + "\nActual length: " + document.Formular.text1.value.length);
   document.Formular.text1.focus();
   return false; }

if(document.Formular.text2.value == "" || document.Formular.text2.value.length > 2500)
 {
   if(document.Formular.text2.value == "") alert(iText2);
   else                                    alert(iTextzulang + "\nActual length: " + document.Formular.text2.value.length);
   document.Formular.text2.focus();
   return false; }

if(document.Formular.text3.value == "" || document.Formular.text3.value.length > 2500)
 {
   if(document.Formular.text3.value == "") alert(iText3);
   else                                    alert(iTextzulang + "\nActual length: " + document.Formular.text3.value.length);
   document.Formular.text3.focus();
   return false; }
*/

if(document.Formular.passkunde.value.length < 4)
 { alert(iPasswort);
   document.Formular.passkunde.focus();
   return false; }

if( typeof(document.Formular.passkunde2) != 'undefined' && (document.Formular.passkunde.value != document.Formular.passkunde2.value) )
 { alert(iRetypePasswort);
   document.Formular.passkunde2.focus();
   return false; }


} // ###############  Ende Check Formular  #############################
  // ###################################################################


function isInt(wert) {
  if (wert == "") return false;
  for (i=0; i<wert.length;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);
}

function chk_talk_anzahl(maxtalks)
{
var chks = document.ListTalkFormular.elements['selected_host_talks[]'];
var count = 0;
for (var i=0;i<chks.length;i++)
 if (chks[i].checked) count +=1;
   //alert(chks[i].value);
if (count > maxtalks)
{ alert("You can book a maximum of " + maxtalks + " talks, only.");
  return false;
}
return true;
}



// Funktionen für das Layoutieren
// <a style="font-weight:normal;" href="javascript:insert('<li>','</li>');" titel="Einzelner Textblock einrücken">Liste A</a>&nbsp; |&nbsp;

function storeFocus(obj) {
  stored = obj.name;
}

function insert(aTag, eTag) {
  var input = document.forms['Formular'].elements[stored];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}