<!-- //
var SetBgColor = true;
var crlf = "\x0d";
var IsFocusSet = false;
var msg = '';
var theForm;
var TxtSubmit, TxtNichtLeer, TxtAuswahlTreffen, TxtWertAusListe, TxtFeldWaehlen
var TxtKeineEMail, TxtZuKurz, TxtKeinAt, TxtKeinPkt, TxtUnGueltZeichen
function ChkInit() {
	TxtNichtLeer = "Bitte füllen Sie dieses Feld aus."
	TxtAuswahlTreffen = "Bitte Auswahl treffen."
	TxtWertAusListe = "Bitte Wert aus Liste wählen."
	TxtFeldWaehlen = "Dieses Feld muss gewählt sein."
	TxtKeineEMail = "Keine gueltige E-Mail-Adresse"
	TxtZuKurz = "zuwenig Zeichen"
	TxtKeinAt = "kein @-Zeichen"
	TxtKeinPkt = "kein Punkt vorhanden"
	TxtUnGueltZeichen = "ungueltiges Zeichen"
	TxtNurZiffern = "Bitte nur Ziffern eingeben."
	TxtZuLang = "Eingabe zu lang"
	TxtKeinDatum = "Kein gueltiges Datum [tt.mm.jjjj]"
	TxtFalschesFormat = "Falsches Format."
	TxtKeineZeit = "Keine gueltige Uhrzeit"
	TxtFalscheExt = "Falscher Dateityp."
	if (!document.layers && SetBgColor) {
		for (i=0; i < theForm.length; i++){
			theForm[i].style.backgroundColor = "";
		}
	}
}

function ChkInpText(FldName, FriendlyName) {
	if (theForm[FldName].value.length < 2) {
		if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
		if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
		msg += FriendlyName + ":  " + TxtNichtLeer + crlf;
	}
	return "";
}

function ChkInpNumber(FldName, FriendlyName) {
	reason = "";
	ValidChar = "0123456789"
	theValue = theForm[FldName].value;
	if (theForm[FldName].value.length > 0) {
		for (i=0; i < theValue.length; i++) {
			if (ValidChar.indexOf(theValue.charAt(i)) < 0) {
				reason = " " + TxtNurZiffern;
				break;			
			}		
		}	
		if (reason.length) {
			if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
			if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
			msg += FriendlyName + ":  " + reason + crlf;
		}
	}
	return "";
}

function ChkInpCheckbox(FldName, FriendlyName) {
	if (!theForm[FldName].checked) {
		if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
		if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
		msg += FriendlyName + ":  " + TxtFeldWaehlen + crlf;
	}
	return "";
}

function ChkInpRadio(FldName, FriendlyName) {
	theFld = theForm[FldName];
	var i = 0;
	var CheckNr = -1;
	for (i=0; i<theFld.length; i++) {
		if (theFld[i].checked) { CheckNr = i; }
	}
	if (CheckNr < 0) {
		if (!document.layers && SetBgColor) {
			for (i=0; i<theFld.length; i++) {
				theFld[i].style.backgroundColor = ErrBgColor;
			}
		}
		if (!IsFocusSet) { theFld[0].focus(); IsFocusSet = true; }
		msg += FriendlyName + ":  " + TxtAuswahlTreffen + crlf;
	}
	return "";
}

function ChkSelect(FldName, FriendlyName) {
	if (!theForm[FldName].selectedIndex) {
		if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
		if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
		msg += FriendlyName + ":  " + TxtWertAusListe + crlf;
	}
	return "";
}

function ChkInpEMail(FldName, FriendlyName) {
	reason = "";
	ValidChar = "@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"
	theValue = theForm[FldName].value;
	if (theValue.length) {
		if (theValue.length < 7) { reason = " " + TxtZuKurz; };
		if (theValue.indexOf("@") < 0) { reason = " " + TxtKeinAt; };
		if (theValue.indexOf(".") < 0) { reason = " " + TxtKeinPkt; };
		for (i=0; i < theValue.length; i++) {
			if (ValidChar.indexOf(theValue.charAt(i)) < 0) {
				reason = " " + TxtUnGueltZeichen;
				break;			
			}		
		}	
		if (reason.length) {
			if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
			if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
			msg += FriendlyName + ": " + TxtKeineEMail + " (" + reason + ")" + crlf;
		}
		else {
			return "";
		}
	}
	return "";
}

function ChkInpDate(FldName, FriendlyName) {
	reason = "";
	ValidChar = "0123456789.-/"
	theValue = theForm[FldName].value;
	if (theValue.length) {
		if (!CheckDateFormat(theValue))
		{
			reason = " ";
		}
		if (theValue.length < 6) { reason = TxtZuKurz; };
		if (theValue.length > 10) { reason = TxtZuLang; };
		for (i=0; i < theValue.length; i++) {
			if (ValidChar.indexOf(theValue.charAt(i)) < 0) {
				reason = " " + TxtUnGueltZeichen;
				break;			
			}		
		}	
		if (reason.length) {
			if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
			if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
			msg += FriendlyName + ": " + " " + TxtKeinDatum
			if (reason != " ")
			{
				msg = msg + " (" + reason + ")";
			}
			msg = msg + crlf;
		}
		else {
			return "";
		}
	}
	return "";
}

function CheckDateFormat(aktDate)
{
   var ergebnis_punkt;
   var ergebnis_strich;
   var ergebnis_slash;
   var Trennzeichen;
   ergebnis_punkt = aktDate.search(".");
   if (ergebnis_punkt != -1)
   	{Trennzeichen = ".";}
   ergebnis_strich = aktDate.search("-");
   if(ergebnis_strich != -1)
   	{Trennzeichen = "-";}
   ergebnis_slash = aktDate.search("/");
   if (ergebnis_slash != -1)
   	{Trennzeichen = "/";}
   //alert("Trennzeichen: " + Trennzeichen);
   var datum = aktDate.split(Trennzeichen);
   var Day = datum[0];
   var Month = datum[1];
   var Year = datum[2];
   //alert(Day + "." + Month + "." + Year);  
   //if ((FldName.charAt(2)==Trennzeichen) && (FldName.charAt(5)==Trennzeichen))
   //{
       if ((Day<=31) && (Day>=1) && (Month>=1) && (Month<=12))
       {
         if((Month==1) || (Month==3) || (Month==5) || (Month==7) || (Month==8) || (Month==10) || (Month==12)) { return true; }
         else
         {
            if ((Day<=30) && (Day>=1))
            {
                if((Month==4) || (Month==6) || (Month==9) || (Month==11)) { return true; } 
                else
                {
                  if ((Day<=28) && (Day>=1)) { return true; }
                  else
                  {
                      if(Day==29)
                      {
                           if ((Year%4)==0)
                           {
                               if ((Year%100)!=0) { return true; }
                               else
                               {
                                     if ((Year%400)==0) { return true; }
                                     else { return false; }
                               }
                           }
                           else { return false; }
                      }
                      else { return false; }
                  }
                }
            }
            else { return false; }
         }
       }
       else { return false; }
}
//  else { return false; }
//}

function ChkInpTime(FldName, FriendlyName) {
	reason = "";
	ValidChar = "0123456789:"
	theValue = theForm[FldName].value;
	if (theValue.length) {
		if (theValue.length < 4) { reason = " " + TxtZuKurz; };
		if (theValue.length > 8) { reason = " " + TxtZuLang; };
		for (i=0; i < theValue.length; i++) {
			if (ValidChar.indexOf(theValue.charAt(i)) < 0) {
				reason = " " + TxtUnGueltZeichen;
				break;			
			}		
		}	
		if (reason.length) {
			if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
			if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
			msg += FriendlyName + ": " + " " + TxtKeineZeit + "(" + reason + ")" + crlf;
		}
		else {
			return "";
		}
	}
	return "";
}

function ChkInpFile(FldName, FriendlyName) {
	theValue = theForm[FldName].value.toLowerCase();
	if (theValue.length) {
		Ext = '---';
		DotPos = theValue.lastIndexOf('.');
		if (DotPos >= 0) { Ext = theValue.substr(++DotPos); }
		if (ExtAllowed.indexOf(Ext) < 0) {
			if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
			if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
			msg += FriendlyName + ": " + TxtFalscheExt + crlf;
		}
	}
	return "";
}

function ChkInpLen(FldName, FriendlyName, FldLen) {
	if (theForm[FldName].value.length < FldLen) {
		if (!document.layers && SetBgColor) { theForm[FldName].style.backgroundColor = ErrBgColor; }
		if (!IsFocusSet) { theForm[FldName].focus(); IsFocusSet = true; }
		msg += FriendlyName + ": " + TxtZuKurz + " (min. " + FldLen + ")" + crlf;
	}
	return "";
}
// -->