function set_focus(){
self.focus();
// Setzt den Cursor in das erste freie Feld von Typ 'Text', 'Checkbox' oder 'select-one'
for ( y = 0 ; y < document.forms.length; y++ )
 {
   
   for ( x = 0 ; x < document.forms[y].elements.length; x++ )
   {
     if (  (document.forms[y].elements[x].value == "") && (document.forms[y].elements[x].type == "text" || document.forms[y].elements[x].type == "checkbox" )  || document.forms[y].elements[x].type == "select-one" ) 
      {
        document.forms[y].elements[x].focus();

         x = document.forms[y].elements.length; 
      }// end if
   }// end for
 }// end for
}// end focus

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  //alert(theURL);
  neuwin = window.open(theURL,winName,features);
  neuwin.focus();
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// Funktion für das setzen des Fokus in ein Feld
function SetFokus(formname,feldname) {
  document.forms[formname].elements[feldname].focus();
}
// Funktion prüft, ob ein String nur aus Ziffern besteht
function IstZahl(str) {
  for (i = 0; i < str.length; i++) {
    a = str.substring(i,i+1);
    if ((a == 1)||(a == 2)||(a == 3)||(a == 4)||(a == 5)||(a == 6)||(a == 7)||(a == 8)||(a == 9)||(a == 0)) {;}
    else {window.alert('Bitte nur Ziffern eingeben!'); return false;}
  }
  return true;
}
// Funktion prüft das eingegebene Datumsformat im Textfeld auf: DD.MM.YYYY
// Parameter "mussfeld" ist 1 für ja und 0 für nein
function PruefeDatum(feldname,formname,mussfeld) {
  var pruefen = 0;
  str = document.forms[formname].elements[feldname].value;
  // wenn Mussfeld oder Eingabe vorhanden, dann prüfen
  if (mussfeld == 1) {pruefen = 1;} 
  else {if (str == '') {pruefen = 0;} else {pruefen = 1}}
  if (pruefen == 1) {
    // prüfen, ob Punkte eingegeben wurde
    p1 = str.indexOf('.');
    p2 = str.indexOf('.', p1+1);
    p3 = str.indexOf('.', p2+1);
    // sind beide Punkte und nur diese im Datum vorhanden?
    if ((p1 == -1)||(p2 == -1)||(p3 != -1)) {
      window.alert('Bitte Datum im Format "TT.MM.JJJJ" eingeben!'); SetFokus(formname,feldname); return;
    }
    tag = str.substring(0,p1);
    monat = str.substring(p1+1,p2);
    jahr = str.substring(p2+1);
    if ((tag.length > 2)||(tag.length < 1)||(tag > 31)) {
      window.alert('Der Tag im Datum ist falsch!'); SetFokus(formname,feldname); return;
    }
    if ((monat.length > 2)||(monat.length < 1)||(monat > 12)) {
      window.alert('Der Monat im Datum ist falsch!'); SetFokus(formname,feldname); return;
    }
    if (jahr.length != 4) {
      window.alert('Das Jahr im Datum muss vierstellig sein!'); SetFokus(formname,feldname); return;
    }
    if (true != IstZahl(tag)) {SetFokus(formname,feldname); return;}
    if (true != IstZahl(monat)) {SetFokus(formname,feldname); return;}
    if (true != IstZahl(jahr)) {SetFokus(formname,feldname); return;}
  }
}

//Dynamische Poupfenster
function windowAdd() {
popup = window.open("","newWin","location=0,menubar=0,personalbar=0,status=0");
popup.document.open();
//popup.document.write(text);
popup.document.location = "http://llbsntze0041/wgv/owa/wwwutil.meldung?P_TEXT=112";
popup.document.close();
setTimeout("windowClose()", 5000); // delay 10 seconds before closing
}

//Schliesen der Fenster
function windowClose() {
popup.close();
//top.close(); //if you want to close the top window too
}

// Füllt das ein Formular-Feld (ziel) mit einem Wert (wert), wenn Checkbox aktiviert ist und löscht das Feld bei Deaktivierung
function WertSetzen_CBox_Feld (checkbox, ziel, wert)
{
 if(checkbox.checked == true)
   ziel.value=wert;
 else 
   ziel.value='';
}
// Wählt den Wert (wert) in der Select-Liste (Ziel), wenn Checkbox aktiviert ist und löscht die Select-Liste bei Deaktivierung
function WertSetzen_CBox_Sel (checkbox, ziel, wert)
{
 if(checkbox.checked == true)
  for(i=0;i<ziel.length;++i)
  {
   if(ziel.options[i].value == wert)
   ziel.selectedIndex=i;
  }
 else 
  ziel.selectedIndex=0;
}
// Wählt den Wert (wert) in der Radio-Gruppe (Ziel), wenn Checkbox aktiviert ist und löscht die Radio-Gruppe bei Deaktivierung
function WertSetzen_CBox_Rad (checkbox, ziel, wert)
{
 if(checkbox.checked == true)
  if(isNaN(ziel.length))
   ziel.checked = true;

  else  // isNaN(ziel.length)
  {
   for(i=0;i<ziel.length;++i)
   {
    if(ziel[i].value == wert)
     ziel[i].checked = true;
   }
  }
 else  // checkbox.checked
  if(isNaN(ziel.length))
   ziel.checked = false;
  else
   for(i=0;i<ziel.length;++i)
   {
    ziel[i].checked = false;
   }
}
// Wählt den Wert (wert) in der Select-Liste (Ziel), wenn das Formularfeld (feld) mit dem übergebenen Wert (feld_wert) übereinstimmt
function WertSetzen_Feld_Sel (feld, feld_wert, ziel, wert)
{
 if(feld.value == feld_wert)
  for(i=0;i<ziel.length;++i)
  {
   if(ziel.options[i].value == wert)
   ziel.selectedIndex=i;
  }
 else 
  ziel.selectedIndex=0;
}
