function Fenster (Dateiname,Hoehe)
{
 win = window.open(Dateiname, "Zweitfenster", 'width=600, height='+Hoehe+', top=50, resizable=1, scrollbars=auto');
 win.focus();
}

function chkformular()
{

if(document.Formular.firma.value == "")
 { alert("Bitte Name der Firma eingeben!");
   document.Formular.firma.focus();
   return false; }

if( isInt(document.Formular.plz.value) == false)
 { alert("Bitte eine PLZ eingeben!");
   document.Formular.plz.focus();
   return false; }

if(document.Formular.ort.value == "")
 { alert("Bitte Ort eingeben!");
   document.Formular.ort.focus();
   return false; }

var region_ok = false;
for (var i=0; i<document.Formular.region.length; i++)
   if (document.Formular.region[i].checked) region_ok = true;
if (!region_ok) { alert("Bitte ein Bundesland auswählen");
                  document.Formular.region[0].focus();
                  return false; }

if(document.Formular.telefon.value == "")
 { alert("Bitte einen Telefonnummer angeben!");
   document.Formular.telefon.focus();
   return false; }

if(chk_mail(document.Formular.kundenmail.value) == false)
 { alert("E-Mail adresse fehlerhaft!");
   document.Formular.kundenmail.focus();
   return false; }

if(document.Formular.anrede[0].checked == false &&
   document.Formular.anrede[1].checked == false )
 { alert("Bitte eine Anrede (Herr/Frau) auswählen");
   document.Formular.anrede[0].focus();
   return false; }

if(document.Formular.vorname.value == "")
 { alert("Bitte einen Vorname eingeben!");
   document.Formular.vorname.focus();
   return false; }

if(document.Formular.nachname.value == "")
 { alert("Bitte einen Nachnamen eingeben!");
   document.Formular.nachname.focus();
   return false; }

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("Bitte Anzahl der Mitarbeiter auswählen");
                  document.Formular.anzahl[0].focus();
                  return false; }

if(document.Formular.kmu[0].checked == false &&
   document.Formular.kmu[1].checked == false )
  { alert("Ist Ihre Firma ein KMU (SME) Hinweis: Auf EU Definition klicken.?");
    document.Formular.kmu[0].focus();
    return false; }

var expo = document.Formular.elements['export'];
if(expo[0].checked == false &&
   expo[1].checked == false )
  { alert("Ist Ihre Firma im Export tätig?");
    expo[0].focus();
    return false; }


if (!document.Formular.a_serv.checked &&
    !document.Formular.a_rtd.checked &&
    !document.Formular.a_sale.checked &&
    !document.Formular.a_res.checked &&
    !document.Formular.a_prod.checked)
{ alert("Bitte eine Aktivität (Service, RTD, Sale, ....) auswählen");
  document.Formular.a_serv.focus();
  return false; }

if(document.Formular.text1.value == "")
 { alert("Bitte das Feld Core competences ausfüllen!");
   document.Formular.text1.focus();
   return false; }

if(document.Formular.text2.value == "")
 { alert("Bitte das Feld Application ausfüllen!");
   document.Formular.text2.focus();
   return false; }

if(document.Formular.text3.value == "")
 { alert("Bitte das Feld international activities ausfüllen!");
   document.Formular.text3.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("Bitte zumindest eine Branche auswählen!");
                  chks[0].focus();
                  return false;
                }

if(document.Formular.passkunde.value.length < 4)
 { alert("Please enter password (min 4 characters!");
   document.Formular.passkunde.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);
}


// 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);
  }
}
