function Fenster (Dateiname,Hoehe)
{
 win = window.open(Dateiname, "Zweitfenster", 'width=600, height='+Hoehe+', top=50, resizable=1, scrollbars=auto');
 win.focus();
}


function chkProjectformular()
{
 return 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       = "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?";
iProjekt     = "Bitte ein Projekt 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.";
iStatus      = "Bitte den Status (Aktiv, Inaktiv) angeben";
iInsertedBy  = "Wer hat diesen Datensatz erfasst?"
*/

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";
iZahlenOnly  = "Please, enter digits only";
iMitarbeiter = "Number of employees missing";
iMitarbeiterRTD = "Number of employees working in RTD missing";
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!";
iProjekt     = "Project missing!";
iActivities  = "Core competences missing!";
iPasswort    = "Passwort missing or to short (min. 4 characters)!";
iProfilTitel = "Your company in 2 sentences";
iText1       = "Short description about Research & Development activities missing";
iText2       = "Short description about product, technology, service, know-how missing";
iStatus      = "Staus of the record (active, inactive) missing!"
iInsertedBy  = "Person, who is inserting this record is missing?"


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; }


/* SELECT ABFRAGE */
if (document.Formular.business.selectedIndex < 1)
{ alert(iBusinessTyp);
  document.Formular.business.focus();
  return false; }

/* RADIO ABFRAGE */
/*
var chks = document.Formular.business;
var count = 0;
for (var i=0;i<chks.length;i++)
 if (chks[i].checked) count +=1;
if (count == 0) { alert(iBusinessTyp);
                  chks[0].focus();
                  return false;
                }

if(document.Formular.anzahl.value == "")
 { alert(iMitarbeiter);
   document.Formular.anzahl.focus();
   return false; }

if(document.Formular.fax.value == "")
 { alert("Bitte eine Faxnunmer eingeben!");
   document.Formular.fax.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.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; }

/*
var chks = document.Formular.elements['projekt[]'];
var count = 0;
for (var i=0;i<chks.length;i++)
   if (chks[i].checked) count +=1;
if (count == 0) { alert(iProjekt);
                  chks[0].focus();
                  return false;
                }
if(document.Formular.profiltitel.value == "")
 { alert(iProfilTitel);
   document.Formular.profiltitel.focus();
   return false; }

if(document.Formular.text1.value == "")
 { alert(iText1);
   document.Formular.text1.focus();
   return false; }

if(document.Formular.text2.value == "")
 { alert(iText2);
   document.Formular.text2.focus();
   return false; }
*/


/* Unterschiedliche Abfrage bei select / radio */
if (document.Formular.status.selectedIndex < 1)
{ alert(iStatus);
  document.Formular.status.focus();
  return false; }

/*
if (document.Formular.inserted.selectedIndex < 1)
{ alert(iInsertedBy);
  document.Formular.inserted.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);
}

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);
  }
}
