// ################################################################################################
// Browserunterscheidung und Allgemeines
// ################################################################################################

var ie;

if (navigator.appName.indexOf("Netscape") != -1) {
	ie = false;
}
if (navigator.appName.indexOf("Explorer") != -1) {
	ie = true;
}


var tabKeyPressed;

function setTabKeyPressed(e) {

  tabKeyPressed = false;
	if (!ie) {
		if (e.which == 9) { tabKeyPressed = true; }
	} else {
		if (window.event.keyCode == 9) { tabKeyPressed = true; }
	}
}

// kein Paste erlaubt (nicht IE)
function disablePaste(e)
{
  if (e) {
    if (e.ctrlKey && e.which == 118) { return false; }
  }
}

// kein Paste erlaubt (nur IE)
function disablePasteIE(e) {
  return false;
}

// kein Submit durch Return
function disableEnter(e)
{
	if (!ie) {
		if (e.which == 13) { return false; }
	} else {
		if (window.event.keyCode == 13) { return false; }
	}
}

document.onkeydown = disableEnter;


// ################################################################################################
// Style-Modifikationen
// ################################################################################################

function element_show (id) {
  // document.getElementById(id).style.visibility = 'visible';
  document.getElementById(id).style.display = 'block';
  document.getElementsByName(id + 'Style')[0].value = 'display:block;';
}

function element_show_inline (id) {
  // document.getElementById(id).style.visibility = 'visible';
  document.getElementById(id).style.display = 'inline';
  document.getElementsByName(id + 'Style')[0].value = 'display:inline;';
}

function element_hide (id) {
  // document.getElementById(id).style.visibility = 'hidden';
  document.getElementById(id).style.display = 'none';
  document.getElementsByName(id + 'Style')[0].value = 'display:none;';
}

function div_set_error_class (id) {
  var className = document.getElementById(id).className;
  if (className.match(/\berror\b/)) {
      // error-Klasse ist bereits enthalten
      return;
  }
  document.getElementById(id).className = className + ' error';
}

function div_reset_error_class (id) {
  var className = document.getElementById(id).className;
  var entferneClassName = 'error';
  if (className.match(/\berror\b/)) {
      // error-Klasse ist enthalten, muss entfernt werden
      if (className.match(/\b error\b/)) {
          // error-Klasse ist enthalten, führendes Blank sollte mit entfernt werden
          entferneClassName = ' ' + entferneClassName;
      }
      document.getElementById(id).className = className.replace(entferneClassName, '');
  }
}

function disableField (field) {
	field.disabled = true;
	field.style.backgroundColor = "#D4D0C8";
	field.value	= "";
}

function enableField(field) {
	field.disabled = false;
	field.style.backgroundColor = "#FFFFFF";
}


// ################################################################################################
// Eingabeformatierungen
// ################################################################################################

function setCurrency(value){
	var tmpValue = value;
	var newValue = "";
	var counter = 0;

	for (var i = tmpValue.length -1; i >= 0; i--, counter++){
		if ((counter % 3) == 0 && counter > 3 && tmpValue.substr(i, 1) != "-"){
            newValue = '.' + newValue;
        }
        if (counter == 2) {
            newValue = ',' + newValue;
        } else {
        	newValue = tmpValue.substr(i, 1) + newValue;
        }
	}
	return newValue;
}

// setzt oder verschiebt den Tausenderpunkt
// wird mit Tausenderpunkt maxLength (max. Eingabefeldlänge) überschritten, so werden Zeichen vorne abgeschnitten
function setThousandSepChar(theElement, maxLength) {

  var tmpValue = theElement.value;
  var newValue = "";
  var counter = 0;

  var ergebnis = tmpValue.match(/^[0-9]{1,3}\.[0-9]{3,3}$/);
  if (!ergebnis) {
    ergebnis = tmpValue.match(/^[0-9]{0,3}$/);
    if (!ergebnis) {
      tmpValue = tmpValue.replace(/\./g, "");
      if (tmpValue.length == maxLength) {
        // kein Punkt eingegeben und max. Länge erreicht
        // -> führendes Zeichen wird abgeschnitten
        tmpValue = tmpValue.substr(1, maxLength -1);
      }

      for (var i = tmpValue.length -1; i >= 0; i--, counter++) {
        if ((counter % 3) == 0 && counter > 0) {
            newValue = '.' + newValue;
        }
        newValue = tmpValue.substr(i, 1) + newValue;
      }
      theElement.value = newValue;
    }
  }
  return true;
}


// nur Datum erlaubt (Zahlen 0-9 und Punkte)
/*
Datums Aufbereitung und Format konvertierung (TT.MM.JJ -> TT.MM.JJJJ)
Tag, Monat und Jahr muessen mit Punkt getrennt werden, oder tag und
Monat muessen zweistellig angegeben werden
Das jahr kann 2 oder 4 Stellig angegeben werden
Bsp 01015 -> 01.01.2005   => funktioniert nicht
    1.1.5 -> 01.01.2005
    1.1204 -> 01.12.2004
    010105 -> 01.01.2005
    01011905->01.01.1905
    01012005->01.01.2005
    4115    ->04.11.2005  => funktioniert nicht
    44	    ->04.04.2005  => funktioniert nicht
    1174    ->11.07.2004  => funktioniert nicht
    4711    ->04.07.1911  => funktioniert nicht
*/
function setDateSepCharAndExpandDate(theElement) {
  var modifiedValue = "";
  var ziffern="0123456789";
  var tt=0;
  var mm=0;
  var jj=0;
  var j=0;
  var k=0;
  var t=0;
  var s="";
  var currentDate = new Date();
  var year = currentDate.getFullYear()-2000 +2;
  var test=false;
  modifiedValue=theElement.value;
  if ( modifiedValue!="0" && "+-".indexOf(modifiedValue.charAt(0))==-1 ) {
  
      if (modifiedValue.length!=10 && modifiedValue.length!=8 &&
          modifiedValue.length!=6 && modifiedValue.indexOf(".")==-1)
      {
      		theElement.value="";
      		modifiedValue.value="";
      		return false;
      }
    	for (i=0; i<modifiedValue.length; i++) {
    		var c;
    		c=modifiedValue.charAt(i);
    		if (c=="." || c=="-" || k==2 ) { j++; k=0;}
    		if (ziffern.indexOf(c)!=-1) {
    			if (test==true) {
    				if (k==1) {
    					if (j==0) { 
                if ((tt*10 + ziffern.indexOf(c))>31) {
                    j++;k=0;
                } 
              } else if (j==1) { 
                if ((mm*10 + ziffern.indexOf(c))>12) {
                    j++;k=0;
                } 
              } 
    				}
    			}
    			if (j==0 && k<2) {
            tt=tt*10+ziffern.indexOf(c);k=k+1;
          } else if (j==1 && k<2) {
            mm=mm*10+ziffern.indexOf(c);k=k+1;
          } else if (j>=2) {
            jj=jj*10+ziffern.indexOf(c);j++;k=0;
          }
    		}
    	}
    	if (j==2 || (j==1 && mm!=0)) {
          jj=currentDate.getFullYear();j=3;
      }
    	if (j<2) {
    	    if (tt>0 && test==true) {
        		currentDate.setDate(currentDate.getDate()+tt)
        		tt=currentDate.getDate();
        		mm=currentDate.getMonth()+1;
        		jj=currentDate.getFullYear();
    	    } else {
        		theElement.value="";
        		modifiedValue.value="";
        		return false;
    	    }
    	}
    	if (test==true) {
    		if (jj>=100 && (jj<1900 || jj>2100)) { 
            while (jj>=100) {
                jj=jj-100;
            }
        }
    	
    		if (tt==31 && (mm==4 || mm==6 || mm==9 || mm==11)) {
            tt=30;
        }
    		if (tt>28 && mm==2) { 
            if (jj%4==0 && (jj%100!=0 || jj%400==0)) tt=29; else tt=28;  
        }
    	}
  } else if (modifiedValue!=""){
    
    j=0;
  	for (i=0; i<modifiedValue.length; i++) {
  		if (ziffern.indexOf(modifiedValue.charAt(i))!=-1)
          j=j*10+ziffern.indexOf(modifiedValue.charAt(i));
  	}
  	if (modifiedValue.charAt(0)=='-') j=-j;
  	currentDate.setDate(currentDate.getDate()+j)
  	tt=currentDate.getDate();
  	mm=currentDate.getMonth()+1;
  	jj=currentDate.getFullYear();
  } else {
  	theElement.value="";
  	modifiedValue.value="";
  	return false;
  }
  s="00"+tt; tt=s.substring(s.length-2,s.length);
  s="00"+mm; mm=s.substring(s.length-2,s.length);
  if (jj<100) { 
      s="00"+jj; s=s.substring(s.length-2,s.length);
      if (jj>=year) theElement.value=tt+"."+mm+".19"+s;
      else theElement.value=tt+"."+mm+".20"+s;
  } else { 
      s="0000"+jj; s=s.substring(s.length-4,s.length);
      theElement.value=tt+"."+mm+"."+jj; 
  }
  return true;
}


// ################################################################################################
// Eingabeprüfungen
// ################################################################################################

// nur Zahlen 0-9 erlaubt
function numericInputOnly(theElement) {
	var modifiedValue = "";
	var invalidChar = false;

	for (i=0; i<theElement.value.length; i++) {
		if (theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58) {
			modifiedValue = modifiedValue + theElement.value.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true) {
		theElement.value = modifiedValue;
	}
	return true;
}

function removeLeadingZero(theElement) {
	var modifiedValue = "";
	var theString = theElement.value;

	if (theElement.value.length > 1) {
		for (i=0; i < theElement.value.length -1; i++) {
			if (theElement.value.charCodeAt(i) != 48){
				break;
			}
		}
		theElement.value = theString.substr(i);
	}
}

function removeLeadingZeroFromString(inString) {

	if (inString.length > 1) {
		for (i=0; i < inString.length -1; i++) {
			if (inString.charCodeAt(i) != 48){
				break;
			}
		}
		return inString.substr(i);
	}
	return inString;
}

function trimString (theElement) {
// Erst führende, dann Abschließende Whitespaces entfernen
// und das Ergebnis dieser Operationen zurückliefern
return theElement.value.replace (/^\s+/, '').replace (/\s+$/, '');
}

// nur Zahlen 0-9 und Alphazeichen erlaubt
function alphaNumericInputOnly(theElement) {
	var modifiedValue = "";
	var invalidChar = false;

	for (i=0; i<theElement.value.length; i++) {
		if (theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58 ||
        theElement.value.charCodeAt(i) > 64 && theElement.value.charCodeAt(i) < 91 ||
        theElement.value.charCodeAt(i) > 96 && theElement.value.charCodeAt(i) < 123 ||
        theElement.value.charCodeAt(i) == 228 ||
        theElement.value.charCodeAt(i) == 252 ||
        theElement.value.charCodeAt(i) == 246 ||
        theElement.value.charCodeAt(i) == 196 ||
        theElement.value.charCodeAt(i) == 214 ||
        theElement.value.charCodeAt(i) == 220 ||
        theElement.value.charCodeAt(i) == 223) {
			modifiedValue = modifiedValue + theElement.value.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true) {
		if (theElement.type == "password") {
			alert("Das eingegebene Format ist unzulässig!\nBitte geben Sie hier nur Buchstaben und/oder Ziffern ein, keine Sonderzeichen wie z.B. -, !, &, etc. .");
			theElement.value = "";
		} else {
			theElement.value = modifiedValue;
		}
	}
	return true;
}

// nur Zahlen 0-9 und Alphazeichen erlaubt; Kleinbuchstaben werden in Großbuchstaben konvertiert
function alphaNumericInputOnlyToUpper(theElement) {
  var upperCaseValue = "";
	var modifiedValue = "";
	var invalidChar = false;

	upperCaseValue = theElement.value.toUpperCase();

	for (i=0; i<upperCaseValue.length; i++) {
		if (upperCaseValue.charCodeAt(i) > 47 && upperCaseValue.charCodeAt(i) < 58 ||
        upperCaseValue.charCodeAt(i) > 64 && upperCaseValue.charCodeAt(i) < 91 ||
        upperCaseValue.charCodeAt(i) == 196 ||
        upperCaseValue.charCodeAt(i) == 214 ||
        upperCaseValue.charCodeAt(i) == 220) {
			modifiedValue = modifiedValue + upperCaseValue.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true || theElement.value != upperCaseValue) {
		theElement.value = modifiedValue;
	}
	return true;
}

// nur Zahlen 0-9 und Punkte erlaubt
function numericAndDotInputOnly(theElement) {
	var modifiedValue = "";
	var invalidChar = false;

	for (i=0; i<theElement.value.length; i++) {
		if ((theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58) || theElement.value.charCodeAt(i) == 46) {
			modifiedValue = modifiedValue + theElement.value.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true) {
		theElement.value = modifiedValue;
	}
	return true;
}

// nur Datum erlaubt (Zahlen 0-9 und Punkte)
function dateInputOnly(theElement) {
	var modifiedValue = "";
	var invalidChar = false;

	for (i=0; i<theElement.value.length; i++) {
		if ((theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58) || theElement.value.charCodeAt(i) == 46) {
			modifiedValue = modifiedValue + theElement.value.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true) {
		theElement.value = modifiedValue;
	}
	return true;
}

// nur Alphazeichen und " ", "-", "&" und "."
function alphaInputOnly(theElement) {
var modifiedValue = "";
var invalidChar = false;
for (i=0; i<theElement.value.length; i++) {
	if ((theElement.value.charCodeAt(i) > 64 && theElement.value.charCodeAt(i) < 91)
		|| (theElement.value.charCodeAt(i) > 96 && theElement.value.charCodeAt(i) < 123)
		|| theElement.value.charCodeAt(i) == 32
		|| theElement.value.charCodeAt(i) == 38
		|| theElement.value.charCodeAt(i) == 45
		|| theElement.value.charCodeAt(i) == 46
		|| theElement.value.charCodeAt(i) == 196
		|| theElement.value.charCodeAt(i) == 214
		|| theElement.value.charCodeAt(i) == 220
		|| theElement.value.charCodeAt(i) == 223
		|| theElement.value.charCodeAt(i) == 228
		|| theElement.value.charCodeAt(i) == 246
		|| theElement.value.charCodeAt(i) == 252) {
		modifiedValue = modifiedValue + theElement.value.charAt(i);
	} else {
		invalidChar = true;
	}
}
if (invalidChar == true) {
	theElement.value = modifiedValue;
}
return true;
}

// für Firma, d.h. Zahlen und Alphazeichen sowie " ", "-", "&" und "."
function firmenInput(theElement) {
var modifiedValue = "";
var invalidChar = false;
for (i=0; i<theElement.value.length; i++) {
	if ((theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58)
    || (theElement.value.charCodeAt(i) > 64 && theElement.value.charCodeAt(i) < 91)
		|| (theElement.value.charCodeAt(i) > 96 && theElement.value.charCodeAt(i) < 123)
		|| theElement.value.charCodeAt(i) == 32
		|| theElement.value.charCodeAt(i) == 38
		|| theElement.value.charCodeAt(i) == 43
		|| theElement.value.charCodeAt(i) == 45
		|| theElement.value.charCodeAt(i) == 46
		|| theElement.value.charCodeAt(i) == 196
		|| theElement.value.charCodeAt(i) == 214
		|| theElement.value.charCodeAt(i) == 220
		|| theElement.value.charCodeAt(i) == 223
		|| theElement.value.charCodeAt(i) == 228
		|| theElement.value.charCodeAt(i) == 246
		|| theElement.value.charCodeAt(i) == 252) {
		modifiedValue = modifiedValue + theElement.value.charAt(i);
	} else {
		invalidChar = true;
	}
}
if (invalidChar == true) {
	theElement.value = modifiedValue;
}
return true;
}

// nur Zahlen und Alphazeichen und " ", "-", "&" und "."
function alphaNumericInput(theElement) {
var modifiedValue = "";
var invalidChar = false;
for (i=0; i<theElement.value.length; i++) {
	if ((theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58)
		|| (theElement.value.charCodeAt(i) > 64 && theElement.value.charCodeAt(i) < 91)
		|| (theElement.value.charCodeAt(i) > 96 && theElement.value.charCodeAt(i) < 123)
		|| theElement.value.charCodeAt(i) == 32
		|| theElement.value.charCodeAt(i) == 38
		|| theElement.value.charCodeAt(i) == 45
		|| theElement.value.charCodeAt(i) == 46
		|| theElement.value.charCodeAt(i) == 196
		|| theElement.value.charCodeAt(i) == 214
		|| theElement.value.charCodeAt(i) == 220
		|| theElement.value.charCodeAt(i) == 223
		|| theElement.value.charCodeAt(i) == 228
		|| theElement.value.charCodeAt(i) == 246
		|| theElement.value.charCodeAt(i) == 252) {
		modifiedValue = modifiedValue + theElement.value.charAt(i);
	} else {
		invalidChar = true;
	}
}
if (invalidChar == true) {
	theElement.value = modifiedValue;
}
return true;
}

//nur Zahlen und Alphazeichen und "_", "-", "@" und "."
function benutzernameInputOnly(theElement) {
var modifiedValue = "";
var invalidChar = false;
for (i=0; i<theElement.value.length; i++) {
	if ((theElement.value.charCodeAt(i) > 47 && theElement.value.charCodeAt(i) < 58)
		|| (theElement.value.charCodeAt(i) > 64 && theElement.value.charCodeAt(i) < 91)
		|| (theElement.value.charCodeAt(i) > 96 && theElement.value.charCodeAt(i) < 123)
		|| theElement.value.charCodeAt(i) == 45
		|| theElement.value.charCodeAt(i) == 46
		|| theElement.value.charCodeAt(i) == 64
		|| theElement.value.charCodeAt(i) == 95) {
		modifiedValue = modifiedValue + theElement.value.charAt(i);
	} else {
		invalidChar = true;
	}
}
if (invalidChar == true) {
	theElement.value = modifiedValue;
}
return true;
}

// nur Alphazeichen erlaubt; Kleinbuchstaben werden in Großbuchstaben konvertiert
function alphaInputOnlyToUpper(theElement) {
	var upperCaseValue = "";
	var modifiedValue = "";
	var invalidChar = false;

	upperCaseValue = theElement.value.toUpperCase();

	for (i=0; i<upperCaseValue.length; i++) {
		if (upperCaseValue.charCodeAt(i) > 64 && upperCaseValue.charCodeAt(i) < 91 ||
		    upperCaseValue.charCodeAt(i) == 196 ||
		    upperCaseValue.charCodeAt(i) == 214 ||
		    upperCaseValue.charCodeAt(i) == 220) {
		    modifiedValue = modifiedValue + upperCaseValue.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true || theElement.value != upperCaseValue) {
		theElement.value = modifiedValue;
	}
	return true;
}

// Eingabe Fahrzeug-ID
// nur Ziffern und Alphazeichen außer O und Umlaute erlaubt; 
// Kleinbuchstaben werden in Großbuchstaben konvertiert
function fahrzeugidInput(theElement) {
	var upperCaseValue = "";
	var modifiedValue = "";
	var invalidChar = false;

	upperCaseValue = theElement.value.toUpperCase();

	for (i=0; i<upperCaseValue.length; i++) {
		if (upperCaseValue.charCodeAt(i) > 64 && upperCaseValue.charCodeAt(i) < 79
			|| upperCaseValue.charCodeAt(i) > 79 && upperCaseValue.charCodeAt(i) < 91 
			|| upperCaseValue.charCodeAt(i) > 47 && upperCaseValue.charCodeAt(i) < 58) {
		    modifiedValue = modifiedValue + upperCaseValue.charAt(i);
		}
		else {
			invalidChar = true;
		}
	}
	if (invalidChar == true || theElement.value != upperCaseValue) {
		theElement.value = modifiedValue;
	}
	return true;
}

// Überprüft, ob das Datum gültig ist
//
function isValidDate( tag, monat, jahr ) {

    if (( monat == 4 || monat == 6 || monat == 9 || monat == 11 ) && tag == 31 )
        return false;

	// Schaltjahre
    if (monat == 2) {
        isleap = ( jahr % 4 == 0 && ( jahr % 100 != 0 || jahr % 400 == 0 ) );
        if ( tag > 29 || ( tag == 29 && !isleap ) )
            return false;
    }

    if ( monat >= 1 && monat <= 12 )		// gültiger Monat ?
	    if ( tag >= 1 && tag <= 31 )		// gültiger Tag ?
		    return true;  					// Datum ist gültig

    return false;
}

// überprüft, ob im Datumsfeld gültige Werte eingegeben wurden
// Parameter:
//  - fieldId: Id des zu prüfenden Datumsfeldes
//  - errId: id, die im Fehlerfall sichtbar gemacht werden soll
//  - divId: id des div-Tags, welches das zu prüfende Feld umschließt
//          (und im Error-Style erscheinen soll)
//  - strutsErrorPropertyNames: Array mit Namen der Properties, zu denen ein Struts-Fehler aktiv ist
//                              (kann auch weggelassen werden)
//
function checkDatumsformat( fieldId, errId, divId, strutsErrorPropertyNames ) {

  var datumField = document.getElementById(fieldId);
  var datumWert = datumField.value;

  if (datumWert.length > 0 && datumWert.length == 10) {

    	var tag   = datumWert.substr(0,2);
    	var monat = datumWert.substr(3,2);
    	var jahr  = datumWert.substr(6,4);

      if ( isValidDate( tag, monat, jahr ) && (datumWert.substr(2,1) == ".") && (datumWert.substr(5,1) == ".")) {
          element_hide(errId);
          div_reset_error_class(divId);
          return true;
      }
      else {
          // Hinweis ungültiges Datum
          element_show(errId);
          div_set_error_class(divId);
          // A.Claus: wird nicht mehr gewünscht
          //setTimeout("document.getElementById(\"" + fieldId + "\").focus()",1);
          return false;
      }
  }
  else {
      if (datumWert.length > 0) {
          // Hinweis ungültiges Datum
          element_show(errId);
          div_set_error_class(divId);
          // A.Claus: wird nicht mehr gewünscht
          //setTimeout("document.getElementById(\"" + fieldId + "\").focus()",1);
          return false;
      } else {
          // erforderlich wenn:
          // Struts Fehler existiert, letzte JavaScript-Eingabe ok war und die Eingabe danach gelöscht wird
          // -> Error-Style muss wiederhergestellt werden
          if (isStrutsErrorActive(datumField.name, strutsErrorPropertyNames)) {
              div_set_error_class(divId);
          }
      }
  }
  element_hide(errId);
  if (!isStrutsErrorActive(datumField.name, strutsErrorPropertyNames)) {
      div_reset_error_class(divId);
  }
  return true;
}


// ################################################################################################
// Spezial-Funktionen
// ################################################################################################

// setzt den Focus auf das erste aktive+sichtbare Eingabefeld der Form, deren Name übergeben wurde
function focusFirstFormField( formName ) {
  if (document.forms[formName]) {
    var field = document.forms[formName];
  
    for (i = 0; i < field.length; i++) {
      if(field.elements[i].type!=undefined && field.elements[i].disabled==false){
        if((field.elements[i].type == "text") || (field.elements[i].type == "textarea") ||
           (field.elements[i].type == "radio") || (field.elements[i].type == "checkbox") ||
           (field.elements[i].type == "password") || (field.elements[i].type == "select-one")) {
          var arr = new Array();
          $(document.forms[formName].elements[i]).parents().each(
            function (e) {
              arr.push(this);
            }
          );
          next = false;
          for(i2 in arr) {
            if(arr[i2].tagName.indexOf("FORM") != -1) break;
            else if (arr[i2].style.display == 'none')
            next=1;
          }
          if(next == 1) {
            continue;
          }
          if (document.forms[formName].elements[i].value != "" &&
              (document.forms[formName].elements[i].type == "text" ||
               document.forms[formName].elements[i].type == "password")) {
            document.forms[formName].elements[i].select();
          }
          document.forms[formName].elements[i].focus();
          break;
        }
      }
    }
  }
};

// prüft, ob für das übergebene Property ein Struts-Fehler aktiv ist
function isStrutsErrorActive( propertyName, strutsErrorPropertyNames ) {
  var errorActive = false;
  
  if (strutsErrorPropertyNames) {
      var strutsErrorPropertyName;
      for (var i = 0; i < strutsErrorPropertyNames.length; i++) {
          strutsErrorPropertyName = strutsErrorPropertyNames[i];
          if (strutsErrorPropertyName == propertyName) {
              errorActive = true;
              break;
          }        
      }
  }
  return errorActive;
} 


// ################################################################################################
// Hilfsfunktionen
// ################################################################################################

// getDatumHeute nicht mehr verwenden, sondern in der jeweiligen Jsp ein eigenes GetDatumHeute implementieren, dass die Systemzeit holt.
// Siehe fahrzeugdaten.jsp
//function getDatumHeute () {
//    var now = new Date();
//    return new Date(now.getFullYear(), now.getMonth(), now.getDate());
//}

// gibt ein Datum auf Basis des übergebenen Strings (Format YYYY.MM.DD) zurück
function getString2Date( datumString ) {
  return new Date(datumString.substr(6, 4),
                  datumString.substr(3, 2) -1,
                  datumString.substr(0, 2));
}


// messagebox alert
function notImplement () {
  // TODO TJ
	alert("Noch nicht implementiert!");
}
// messagebox alert Ende KFZAbschluss
function notImplementEnd () {
  // TODO TJ
	alert("Noch nicht implementiert!");
	alert("Und weil es so schoen war, wieder an den Anfang '01Fahrzeugdaten'!");
}


// Tabreiter Submit

function submitTab(formname, buttonname) {
	document.forms[formname].button.name = buttonname;
	document.forms[formname].button.value = 1;
	document.forms[formname].submit();
}

