// validation.jsfunction iFormValidate() {//alert("iFormValidate");var msg = '';//alert("iFormValidate");// An Hand der Pflicht-Bullets die Pflichtfelder ermitteln	PflichtFeldNamen = new Array;	Label = new Array;	Warnungen = new Array;	FeldTypen = new Array;	var idx = -1 ;	var reqColorName = "yellow" ; 			// Farbe f\u00FCr Pflichtfelder, die angemosert werden		markReqFields();// alert("iFormValidate2");	var imgcount = document.images.length ;	var ThisForm = document.forms[0];	//alert(" imgcount=" +  imgcount );for( var i = 0; i < imgcount; i++ ) {	var imgName = document.images[i].name;		//alert(imgName);	if ( imgName != "" ) {				// Hat das img einen Namen?		var imgName = document.images[i].name;			var imgFlag = strLeft(imgName,"_");				if( imgFlag == 'Pflicht'  )  { 					// Name = Pflicht_XXX ?			idx = idx + 1 ;			fldName = strRight(imgName,"Pflicht_") ;			//alert(fldName);			PflichtFeldNamen[idx] = fldName ;			Label[idx] = eval('ThisForm.t' + fldName + '.value') ;			//Label auslesen			Warnungen[idx] = eval('ThisForm.w' + fldName + '.value') ;		//Warnung auslesen			FeldTypen[idx] = eval('ThisForm.ft' + fldName + '.value') ;	//Feld-Typ auslesen						if (fldName=="ISTK"){//			alert("iFormValidate: fldName="+ fldName);			}		} 	}} //alert('1');//alert(PflichtFeldNamen);// Durch die Felder der Form loopen und Pflichtfelder \u00FCberpr\u00FCfenfor ( var i=0; i<PflichtFeldNamen.length; i++) {	//alert(PflichtFeldNamen[i]);	if ( eval('ThisForm.' + PflichtFeldNamen[i]) ) { 			// Gibt es das Feld auf der Form \u00FCberhaupt?	//alert(PflichtFeldNamen[i]);		// Pflichtfeld \u00FCberpr\u00FCfen		var fldName = PflichtFeldNamen[i] ;		var fld = eval('ThisForm.' + PflichtFeldNamen[i] ) ;		var valTyp = eval('ThisForm.v' + fldName + '.value') ;		// ValidationType auslesen TEXT, RADIO, SELECT etc		var typ = FeldTypen[i] ;		//var Warnung = Warnungen[i];		//alert(typ);				var inp = "" ;		switch(typ) {		 case "TEXT":		inp = fld.value;		if ( !inp ) inp = "" ;		 break;		 case "RADIO":			inp = ReadRadio(fld) ;			 break;		 case "SELECTTEXT":			inp = ReadSelectText(fld) ;		 break;		 case "SELECT":			inp = ReadSelect(fld) ;		 break; 		 case "CHECKBOX":		 // SingleCheckbox mit "1" als Wert		//alert("CHECKBOX");		 		 if (fld.checked) {			inp = "1" ;		 }		 else {			inp = "" ;		 		 }		 break;		 case "CHECKBOX_MULTI":			 inp = ReadCheckbox(fld)	 		//alert(inp);		 break;		 default:		 alert("Unbekannter Typ: " + typ) ;		 break;		}			// Spezialpr\u00FCfung *******************************************************************		if ( valTyp != '0' ) {											// Spezialpr\u00FCfung			var specialMsg = doSpecialVal(inp, valTyp);			if ( specialMsg != ''  ) {				if ( specialMsg == 'handled'  ) {					inp = specialMsg;				}				else {					if( Warnungen[i] == "" ) {						Warnungen[i] = specialMsg ;				// Wieder aktiviert hog - 8.2.05								} 					else {							}					inp = ""								}			}		}		// Spezialpr\u00FCfung *******************************************************************					if ( inp == "" ) { 			if ( typ == "RADIO"  || typ == "CHECKBOX" || typ == "CHECKBOX_MULTI"  ) {				var o = document.getElementById(fldName + "Div");				if (o) {					o.style.backgroundColor = reqColorName ;	 				}			}						else {				// alert(fld.id + " - " + fld.type );				fld.style.backgroundColor = reqColorName ;						}						if ( Warnungen[i] != '' ) {									// Eigene Warnung in Pflichtbullet				if ( msg == "" ) {						msg = Label[i] + ": " + Warnungen[i] ;					}				else {						msg = msg + "\n" + Label[i] + ": " + Warnungen[i] ;					}			}			else {								if ( msg == "" ) {						msg = Label[i];					}				else {						msg = msg + "\n" + Label[i];				}			}					}	}}return msg ;}/************************ iFormValidate   ENDE *****************************/function doSpecialVal(inp, valTyp) {		// Spezielle Formate pr\u00FCfenvar returnValue = "";//alert("doSpecialVal - " + valTyp + " --" + inp);//alert(inp);//alert("doSpecialVal: " + valTyp);switch(valTyp) { case "Email": //alert("Email");	if ( !ValidateEmail ( inp ) ) {		returnValue = "Bitte geben Sie eine g\u00FCltige Email-Adresse ein. Keine Sonderzeichen, keine Leerzeichen."	}	 break;	  case "Email_0": 	if ( inp != "" ) { 		if ( !ValidateEmail ( inp ) ) {			returnValue = "Bitte geben Sie eine g\u00FCltige Email-Adresse ein. Keine Sonderzeichen, keine Leerzeichen."		} 	}	else {									// Darf leer sein		returnValue = "handled";	}	 break;	  case "Email_2": //alert("Email");	if ( !ValidateEmail ( inp ) ) {		returnValue = "Ihre E-Mail ben\u00F6tigen wir f\u00FCr den elektronischen Ticketversand der CeBIT-Eintritskarte bzw. f\u00FCr den Newsletter"	}	 break;	  case "Datum":	if ( !isDate( inp ) ) {		returnValue = "Bitte geben Sie ein g\u00FCltiges Datum ein"	}	break; case "Datum_0": 	if ( inp != "" ) {		if ( !isDate( inp ) ) {			returnValue = "Bitte geben Sie ein g\u00FCltiges Datum ein"		}	}	else {									// Darf leer sein		returnValue = "handled";	}break;	 case "Zeit":	if ( !isTime( inp ) ) {		returnValue = "Bitte geben Sie eine g\u00FCltige Zeit ein"	}	break; case "Zeit_0":// alert("Zeit_0"); 	if ( inp != "" ) {		if ( !isTime( inp ) ) {		returnValue = "Bitte geben Sie eine g\u00FCltige Zeit ein"		}	}	else {									// Darf leer sein		returnValue = "handled";	}		break;	 case "Zahl":	// alert('Zahl');	if ( inp != "" ) {		if ( isNumber(inp)  == false ) {			returnValue = "Bitte geben Sie eine Zahl ein!!"		}	}	break;case "Zahl_0":	if ( inp != "" ) {		if ( isNumber(inp) == false ) {			returnValue = "Bitte geben Sie eine Zahl ein!"		}	}	else {									// Darf leer sein		returnValue = "handled";	}	break;case "GanzZahl":	if ( inp != "" ) {		if ( isInteger(inp)  == false ) {			returnValue = "Bitte geben Sie eine ganze Zahl ein!!"		}	}	break;	case "GanzZahl_0":	if ( inp != "" ) {		if ( isInteger(inp) == false ) {			returnValue = "Bitte geben Sie eine ganze Zahl ein!"		}	}	else {									// Darf leer sein		returnValue = "handled";	}	break;case "PosZahl":	if ( inp != "" ) {		if ( isNumber(inp)  == false ||  Number(inp) <=0 ) {			returnValue = "Bitte geben Sie eine positive  Zahl ein!!"		}	}	break;	case "PosZahl_0":	if ( inp != "" ) {		if ( isNumber(inp) == false ||  Number(inp) <=0 ) {			returnValue = "Bitte geben Sie eine positive Zahl ein!"		}	}	else {									// Darf leer sein		returnValue = "handled";	}	break;	case "Tel":		if ( ValidateMobilNr( inp ) != "" ) {			returnValue = "Bitte geben Sie nur Zahlen, Bindestriche, Schr\u00E4gstriche und Leerzeichen ein!";		}	break;	case "Tel_0": 	if ( inp != "" ) { 		if ( ValidateMobilNr( inp ) != "" ) {			returnValue = "Bitte geben Sie nur Zahlen, Bindestriche, Schr\u00E4gstriche und Leerzeichen ein!";		} 	} 	else { 			returnValue = "handled"; 	}	break;		default:		//alert("valTyp=" + valTyp);		var nr = strRight(valTyp,"_");		if (nr != "") {			if ( !isNaN(strRight(valTyp,"_") ) ) {				// Format z.B. TEXT_4				// Darf leer sein, muss ansonsten aber eine bestimmte L\u00E4nge haben				//alert("inp.length=" + inp.length );				if ( inp != "" ) {					// L\u00E4nge pr\u00FCfen					if ( inp.length != parseInt(strRight(valTyp,"_")) ) {							returnValue = "Eingabe muss " + strRight(valTyp,"_") + "-stellig sein";						}				}				else {									// Darf leer sein						returnValue = "handled";				}			}				}	break;	}return returnValue ;}function ValidateEmail (emailStr) {//alert("ValidateEmail:" + emailStr);/* Pattern to check if the entered e-mail address fits the user@domain format. */var emailPat=/^(.+)@(.+)$/ if (emailStr != escape(emailStr)) {//	alert("Verbotenes Sonderzeichen in Email-Adresse:\n" + emailStr );	return false;}/* Pattern to check for special characters we don't want, including ( ) < > @ , ; : \ " . [ ] */var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"/* The following string represents the range of characters allowed in a username or domainname */var validChars="\[^\\s" + specialChars + "\]"/* The following pattern applies if the "user" is a quoted string, E.g. "jiminy cricket"@disney.com */var quotedUser="(\"[^\"]*\")"/* Pattern for domains that are IP addresses, rather than symbolic names. E.g. joe@[123.124.233.4] is a legal e-mail address. NOTE: The square brackets are required. */var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$//* The following string represents an atom (basically a series of non-special characters.) */var atom=validChars + '+'/* The following string represents one word in the typical username. For example, in john.doe@themorgue.hell, john and doe are words */var word="(" + atom + "|" + quotedUser + ")"// The following pattern describes the structure of the uservar userPat=new RegExp("^" + word + "(\\." + word + ")*$")/* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")/* Finally, let's start trying to figure out if the supplied address is valid. *//* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */var matchArray=emailStr.match(emailPat)if (matchArray==null) {/* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. *///alert("Email address seems incorrect (check @ and .'s)")return false}var user=matchArray[1]var domain=matchArray[2]// See if "user" is valid if (user.match(userPat)==null) {// user is not valid// alert("The username doesn't seem to be valid.")return false}/* if the e-mail address is at an IP address make sure the IP address is valid. */var IPArray=domain.match(ipDomainPat)if (IPArray!=null) {// this is an IP addressfor (var i=1;i<=4;i++) {if (IPArray[i]>255) {// alert("Destination IP address is invalid!")return false}}return true}// Domain is symbolic namevar domainArray=domain.match(domainPat)if (domainArray==null) {// alert("The domain name doesn't seem to be valid.")return false}/* domain name seems valid, but now make sure that it ends in a four-letter word (like com, edu, gov, info, shop) or a two-letter word, representing country (uk, nl), and that there's a hostname preceding the domain or country. *//* Now we need to break up the domain to get a count of how many atoms it consists of. */var atomPat=new RegExp(atom,"g")var domArr=domain.match(atomPat)var len=domArr.lengthif (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) {// the address must end in a two letter or four letter word.// alert("The address must end in a three-letter domain, or two letter country.")return false}// Make sure there's a host name preceding the domain.if (len<2) {var errStr="This address is missing a hostname!"// alert(errStr)return false}// If we've gotten this far, everything's valid!// alert(emailStr + ' seems to be a valid address!');return true;}function isTime(dtStr){// Declaring valid time character	var dtCh= ":";	var pos1=dtStr.indexOf(dtCh)	if (pos1==-1){	return false;}		var strHour=dtStr.substring(0,pos1)	var strMin=dtStr.substring(pos1+1)		var hour = parseInt(strHour);	var min = parseInt(strMin);			if (hour<0 || hour>24){	return false;}	if (min<0 || min>59) {return false;}	// Gibt es noch mehr Trennzeichen?	if (dtStr.indexOf(dtCh,pos1+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){		return false	}		return true}function isDate(dtStr){//alert("isDate");	// Declaring valid date character, minimum year and maximum year		var dtCh= ".";	var minYear=1999;	var maxYear=2200;	var daysInMonth = DaysArray(12)	var pos1=dtStr.indexOf(dtCh)	var pos2=dtStr.indexOf(dtCh,pos1+1)	var strDay=dtStr.substring(0,pos1)	var strMonth=dtStr.substring(pos1+1,pos2)	var strYear=dtStr.substring(pos2+1)	if ( strYear.length == 2) { strYear = "20" + strYear;}		strYr=strYear	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)	for (var i = 1; i <= 3; i++) {		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)	}	month=parseInt(strMonth)	day=parseInt(strDay)	year=parseInt(strYr)	if (pos1==-1 || pos2==-1){//		alert("Bitte beachten Sie das Datumsformat: dd.mm.yyyy")		return false	}	if (month<1 || month>12){//		alert("Please enter a valid month")		return false	}	if (day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){//		alert("Please enter a valid day")		return false	}	if (strYear.length != 4 || year==0 || year<minYear){		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)		alert("Bitte geben Sie ein Datum nach dem 01.01." + minYear + " ein.\n" + "-" + dtStr + "-")		return false	}	if ( year>maxYear){		alert("Bitte geben Sie ein Datum vor dem 01.01." + maxYear + " ein.\n" + "-" + dtStr + "-")		return false	}		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){//		alert("Please enter a valid date")		return false	}return true}function isInteger(s){	var i;    for (var i = 0; i < s.length; i++){           // Check that current character is number.        var c = s.charAt(i);        if (((c < "0") || (c > "9"))) return false;    }    // All characters are numbers.    return true;}function isNumber(s){	var inp = replacestring( s,",",".");	if ( isNaN(Number(inp)) ) { return false;}	return true;}function stripCharsInBag(s, bag){	var i;    var returnString = "";    // Search through string's characters one by one.    // If character is not in bag, append to returnString.    for (var fi = 0; i < s.length; i++){           var c = s.charAt(i);        if (bag.indexOf(c) == -1) returnString += c;    }    return returnString;}function daysInFebruary (year){	// February has 29 days in any year evenly divisible by four,    // EXCEPT for centurial years which are not also divisible by 400.    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );}function DaysArray(n) {	for (var i = 1; i <= n; i++) {		this[i] = 31		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}		if (i==2) {this[i] = 29}   }    return this}function ValidateMobilNr( theString ) {// Gibt Fehlermeldung oder "" zur\u00FCck//alert("ValidateMobilNr");var cleanString = theString ;TakeoutStrings = new Array;TakeoutStrings[0] = "/";TakeoutStrings[1] = "-";TakeoutStrings[2] = " ";//TakeoutStrings[3] = "+";for (var i=0; i<TakeoutStrings.length; i++) {	//cleanString = searchAndReplace(cleanString,TakeoutStrings[i],"") ;	cleanString = replaceSubstring(cleanString,TakeoutStrings[i],"",true);}cleanString = cleanString.substring(0,160) ;if (cleanString == "") {	return 'Bitte geben Sie eine Mobilfunk-Nr. innerhalb Deutschlands ein.' ;}var checkString = cleanString ;TakeoutNrs = new Array;TakeoutNrs[0] = "0";TakeoutNrs[1] = "1";TakeoutNrs[2] = "2";TakeoutNrs[3] = "3";TakeoutNrs[4] = "4";TakeoutNrs[5] = "5";TakeoutNrs[6] = "6";TakeoutNrs[7] = "7";TakeoutNrs[8] = "8";TakeoutNrs[9] = "9";for (var i=0; i<TakeoutNrs.length; i++) {//	checkString = searchAndReplace(checkString,TakeoutNrs[i],"") ;	checkString = replaceSubstring(checkString,TakeoutNrs[i],"",true);}if (checkString != "") {	return 'Bitte geben Sie nur Zahlen als Mobilfunk-Nr. ein.' ;}//alert("ValidateMobilNr fertig");// Alles gut, leer zur\u00FCck geben	return "" ;}/*************************** markReqFields ******************************************/function markReqFields(colorName) {	// F\u00E4rbt Pflichtfelder ein	//alert("markReqFields");try {		if ( colorName ==null || colorName == '') { colorName =  "lightyellow" }	var reqColorName = "yellow" ; 			// Farbe f\u00FCr Pflichtfelder, die angemosert werden	var defColorName = "white";	var defColorName = "";	//var defColorName = "lightblue";		// Erstmal alle Felder auf Normal setzen	var fldCount = document.forms[0].elements.length;	//	alert("fldCount=" + fldCount);	for( var i = 0; i < fldCount; i++ ) {		fld = document.forms[0].elements[i];		if (fld.type != "checkbox" && fld.type != "hidden" && fld.type != "radio") {							if ( fld.style.backgroundColor == colorName || fld.style.backgroundColor == reqColorName ) {				//alert(fld.id + " - " + fld.type);				fld.style.backgroundColor = defColorName ;					}		}		else {			//alert( "fld.id=" + fld.id);			var o = document.getElementById(fld.id + "Div");			if (o) {				o.style.backgroundColor = defColorName ;	 			}		}	}	//	colorName =  "lightblue" ;					// Test	//alert("markReqFields 2");	var imgcount = document.images.length ;	var ThisForm = document.forms[0];	for( var i = 0; i < imgcount; i++ ) {		var imgName = document.images[i].name;					if ( imgName != "" ) {				// Hat das img einen Namen?			var imgName = document.images[i].name;				var imgFlag = strLeft(imgName,"_");					if( imgFlag == 'Pflicht'  )  { 					// Name = Pflicht_XXX ?				//alert(imgName);				fldName = strRight(imgName,"Pflicht_") ;				var fld = eval('ThisForm.' + fldName  ) ;						var fldType = eval('ThisForm.ft' + fldName + '.value') ;	//Feld-Typ auslesen												var valTyp = eval('ThisForm.v' + fldName + '.value') ;		// ValidationType auslesen									//				alert( isNaN(strRight(valTyp,"_") ) = false );//				if ( valTyp != "0"  && right(valTyp,1) == "0" ) {				if ( valTyp != "0"  && valTyp != "Zahl" && valTyp != "Datum" && valTyp != "Email" && valTyp != "Tel" && !isNaN(strRight(valTyp,"_") )  ) {				// Kann leer sein					//alert( valTyp + "  - -  " + strRight(valTyp,"_")  );					//alert(fldName + " - " + valTyp);				}				else {					//var fld = eval('ThisForm.' + fldName  ) ;								if (fldType != 'CHECKBOX' && fldType != 'CHECKBOX_MULTI'  && fldType != 'RADIO'  && fldType != 'CHECKBOX_MULTI' ) {						//alert("markReqFields3 fldName: " + fldName + " - fldType=" + fldType + " - colorName=" + colorName ); 						if (fld) {							//alert("fld= " + fld.name );							fld.style.backgroundColor = colorName ;												}									}					else {																// Span bzw. Div markieren						var o = document.getElementById(fldName + "Div");						if (o) {							o.style.backgroundColor = colorName ;	 						}						/***						for ( var n=0; n<fld.length; n++) {							fld[n].style.backgroundColor = colorName ;										}						***/					}				}							}		}	}}catch(e) {	alert( "ivalidation.js - markReqFields:\n" + e.message );	return;}	 //alert("markReqFields - Ende");}/*************************** markReqFields -  ENDE ******************************************//*************************** setFormProperCase **********************/function setFormProperCase(formName)  {	var fldName = "";	var fld = null;	var valu = "";	var ThisForm = document.forms[0];	if ( formName == 'GP' ) {		var flds = new Array('Name1','Name2','Name3','Strasse','Ort');				var spWords = new Array();		spWords[" Gmbh"] = " GmbH";		spWords[" Mbh"] = " mbH";		spWords[" Ag"] = " AG";		spWords[" Kg"] = " KG";		spWords[" Mit "] = " mit ";		spWords[" Und "] = " und ";		spWords[" U. " ] = " u. ";		spWords[" F. "] = " f. ";		}	else {		alert('SetFormProperCase ist f\u00FCr formName=' + formName + ' noch nicht konfiguriert');		return;	}	for (var i=0; i < flds.length; i++) {			// Durch die Felder loopen		fldName = flds[i];		fld =  document.getElementById(fldName);		valu = trim(fld.value) ;		valu = properCase(valu);		for (var spWord in spWords) {      		valu = replacestring( valu,spWord,spWords[spWord],false) 		}		fld.value = valu;	}/***********************		var words = explode(valu, " -", true ) ;						// Feld in Worte auftrennen				for (var x=0; x < words.length; x++) {			// Durch die Worte loopen			alert(words[x]);				}		//alert(properCase(fld.value));***********************/		}function explode(inputstring, separators, includeEmpties ) {	inputstring = new String(inputstring);	separators = new String(separators);	if (separators == "undefined") { separators = " -:;"; }	fixedExplode = new Array(1);	currentElement = "";	count = 0;	for(x = 0; x < inputstring.length; x++) {		chr = inputstring.charAt(x);		if (separators.indexOf(chr) != -1) {			if (((includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) {			}			else {				fixedExplode[count] = currentElement;				count++;				currentElement = ""; 			}		}		else {			currentElement += chr; 		}	}	if ((!(includeEmpties <= 0) && (includeEmpties !=false)) || (currentElement != "")) {		fixedExplode[count] = currentElement; 	}	return fixedExplode;}function properCase(inputstring) {	u = inputstring.toUpperCase();	specialChars = " ~`@#$%^&*()-+={}[]|\\:;\"'<>,.?/1234567890";	fixedProperCase = "";	twoPast = " ";	lastChar = " ";	for (var place=0; place < inputstring.length; place++) {	var chr = u.charAt(place);	if (specialChars.indexOf(lastChar) != -1) {		if ((lastChar == "\'") && (twoPast != "D")) {			chr = chr.toLowerCase();		}	}	else {		chr = chr.toLowerCase();	}	fixedProperCase += chr;	twoPast = lastChar;	lastChar = chr;}fixedProperCase = trim(fixedProperCase);return fixedProperCase;}function trim(inputstringTrim) {	var fixedTrim = "" ;	var lastCh = " ";	for ( var x = 0; x < inputstringTrim.length; x++) {		var ch = inputstringTrim.charAt(x);		if ((ch != " ") || (lastCh != " ")) { 			fixedTrim += ch;		}		lastCh = ch;	}	if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {		fixedTrim = fixedTrim.substring(0, fixedTrim.length -1);	}return fixedTrim;}