/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* (Version 1.5.4.1 (2007-01-05) - original version)
* Version 1.5.4.1unic3
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/

/*
 * @changelog 1.5.4.1unic1/AlR	Added support for error messages in label element.
 * @changelog 1.5.4.1unic2/AlR	Bugfix: Error messages in label are now properly removed if validated.
 * @changelog 1.5.4.1unic3/NEA	Bugfix: onFormVAlidate & onElementValidate callbacks properly pass on return value (groups dot google dot com thread b8b139e340ea6fb/e0b4964d39f35cdd)
 */
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) { return result; },
			onElementValidate : function(result, elm) { return result; }
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				if (input.type == "checkbox" || input.type == "radio") {
					Event.observe(input, 'click', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				}
				else if (input.type.indexOf("select") > -1) {
					Event.observe(input, 'change', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				}
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			try{
				Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
			}catch(e){}
		}
		result = this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					var p = elm.parentNode;
					if(p) {
						new Insertion.Bottom(p, advice);
					} else {
						new Insertion.After(elm, advice);
					}
					advice = Validation.getAdvice(name, elm);
					
					/* validation advice into label*/
					var labels = document.getElementsByTagName('label');
					var idOrName = (elm? elm.getAttribute('id') : name);
					
					for (var i = 0; i < labels.length; ++i){
						var currentNode = labels[i];
						if (currentNode.getAttributeNode('for').nodeValue == idOrName){
							var errorMessageLabel = '<span class="validation-advice-hidden">' + errorMsg + '</span>';
							currentNode.innerHTML += errorMessageLabel;
							break;
						}
					}
					
					
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			
			/* remove validation advice from label */
			var labels = document.getElementsByTagName('label');
			var idOrName = (elm? elm.getAttribute('id') : name);
			
			for (var i = 0; i < labels.length; ++i){
				var currentNode = labels[i];
				if (currentNode.getAttributeNode('for').nodeValue == idOrName){
					var childNodes = currentNode.childNodes;
					if (childNodes){
						for (var j = 0; j < childNodes.length; ++j){
							//alert(childNodes[j].nodeName);
							if (childNodes[j].nodeName.toLowerCase() == 'span'){
								currentNode.removeChild(childNodes[j]);
								break;
							}
						}
					}
					//alert(currentNode.innerHTML);
					break;
				}
			}
			
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});



var sRequired = "Bitte f&#252;llen Sie dieses Pflichtfeld aus.";
var sValidateNumber = "Bitten geben Sie eine g&#252;ltige Zahl ein.";
var sValidateNumbers = "Bitten geben Sie g&#252;ltige Zahlen ein.";
var sValidateDigits = "Bitte geben Sie g&#252;ltige Zahlen ohne Leerschl&#228;ge Kommas oder Punkte ein.";
var sValidateAlpha = "Verwenden Sie bitte nur Buchstaben (a-z) in diesem Feld.";
var sValidateAlphanum = "Verwenden Sie bitte nur Buchstaben (a-z) oder Nummern (0-9) in diesem Feld.";
var sValidateDate = "Bitte geben Sie ein g&#252;ltiges Datum ein (Format: tt.mm.jjjj).";
var sValidateDatePast = "Bitte geben Sie ein Datum in der Vergangenheit ein (Format tt.mm.jjjj).";
var sValidateDateAfter = "Bitte geben Sie ein Datum in der Zukunft ein (Format tt.mm.jjjj).";
var sValidateTime = "Please enter a valid time.";
var sValidatePhone = "Bitte geben Sie eine g&#252;ltige Telefonnummer ein. Beispiel: +41 45 121 12 12";
var sValidateFax = "Bitte geben Sie eine g&#252;ltige Faxnummer ein. Beispiel: +41 45 121 12 12";
var sValidateMobile = "Bitte geben Sie eine g&#252;ltige Handynummer ein. Beispiel: +41 45 121 12 12";
var sValidateEmail = "Bitte geben Sie eine g&#252;ltige E-Mail Adresse ein. Beispiel: name@mail.com";
var sValidateUrl = "Bitte geben Sie eine g&#252;ltige URL ein.";
var sValidateDateAu = "Verwenden Sie bitte dieses Datumsformat: dd/mm/yyyy. Beispiel 17/03/2006 f&#252;r den 17. M&#228;rz 2006";
var sValidateCurrencyDollar = "Bitte geben Sie einen g&#252;ltigen Betrag in $ ein. Beispiel $100.00.";
var sValidateSelection = "Bitte w&#228;hlen Sie ein Element aus.";
var sValidateOneRequired = "Bitte geben Sie oben eine Auswahl an.";
var sValidateKUDINachforschungAuslandSender = "Ein Nachforschungsbegehren kann nur vom Absender ausgel&#246;st werden. Als Empf&#228;nger nehmen Sie bitte mit dem Absender Kontakt auf damit dieser eine Nachforschung bei der ausl&#228;ndischen Postgesellschaft starten kann.";
var sValidateKUDILaufzeit = "Eine Nachforschung bitte erst nach &#220;berschreitung der Bef&#246;rderungszeit einleiten. Die Bef&#246;rderungszeit ist die durchschnittliche Zeitdauer die Ihre Sendung ben&#246;tigt um beim Empf&#228;nger anzukommen. Die publizierte Bef&#246;rderungszeiten werden in Werktagen (Montag bis Freitag) angegeben; Aufgabetag nicht inbegriffen.";
var sValidateKUDIAttachment = "Dieses Format ist ung&#252;ltig. Verwenden Sie einen der folgenden Dateitypen: bmp doc docx eml htm html jpeg jpg pdf tif tiff txt.";
var sValidateCardDate = "Verwenden Sie bitte dieses Datumsformat: mm/yyyy. Beispiel 03/2006";
var sValidateMaxLength6 = "Bitte geben Sie maximal 6 Zeichen ein.";
var sValidateMaxLength8 = "Bitte geben Sie maximal 8 Zeichen ein.";
var sValidateMaxLength10 = "Bitte geben Sie maximal 10 Zeichen ein.";
var sValidateMaxLength40 = "Bitte geben Sie maximal 40 Zeichen ein.";
var sValidateMaxLength255 = "Bitte geben Sie maximal 255 Zeichen ein.";
var sValidateMaxLength2000 = "Bitte geben Sie maximal 2000 Zeichen ein.";
var sValidateLength4 = "Bitte geben Sie 4 Zeichen ein.";
var sValidateLength6 = "Bitte geben Sie 6 Zeichen ein.";
var sValidateLength7 = "Bitte geben Sie 7 Zeichen ein.";
var sValidateLength8 = "Bitte geben Sie 8 Zeichen ein.";
var sValidateLength9 = "Bitte geben Sie 9 Zeichen ein.";
var sValidateLength10 = "Bitte geben Sie 10 Zeichen ein.";
var sValidateMinValue100 = "Es muss mindestens 100 eingetragen werden.";
var sValidateMinValue1000 = "Es muss mindestens 1000 eingetragen werden.";
var sValidateMaxValue3 = "Es kann maximal 3 eingetragen werden.";
var sValidateMaxValue200 = "Es kann maximal 200 eingetragen werden.";
var sValidateRRN = "Bitte geben Sie eine g&#252;ltige Rechnungsreferenznummer ein (Format: 512345678).";
var sValidateZAZ = "Bitte geben Sie eine g&#252;ltige ZAZ-Kontonummer ein (Format: 1234-5).";
var sValidateVAT = "Bitte geben Sie eine g&#252;ltige Zollkonto-MWSt ein (Format: 1234-5).";
var sValidateImageFlash = "Bitte eine Bild (JPG GIF PNG) oder Flash (SWF)-Datei hochladen.";
var sValidateImage = "Bitte eine Bild (JPG GIF PNG) hochladen.";
var sValidateFileCSV = "Bitte eine Microsoft Excel-Datei (CSV) hochladen.";
var sValidateWebcodesPAG = "Ein oder mehrere der angegebenen WebCodes werden bereits verwendet.";
var sValidateUrlCharacters = "Bitte ausschliesslich alpha-numerische Zeichen sowie Punkte Trennstriche und Underscores eingeben.";
var sValidateUrlPAG = "URL-Tag bereits vorhanden oder beginnt mit &quot;pag-&quot;.";
var sValidateNamePAG = "Dieser Name ist bereits vorhanden.";
var sValidateTillPAG = "Enddatum ist vor Startdatum.";
var sValidatePointsPAG = "Bitte definieren Sie mindestens einen Haupt-POI.";
var sValidateFile5MB = "Die Datei darf nicht gr&#246;sser sein als 5MB.";
var sValidateTrackTraceValidNumber = "Bitte geben Sie eine g&#252;ltige Sendungsnummer an.";
var sValidateTrackTraceInternational = "Diese Sendung wurde im Ausland aufgegeben. Bitte wenden Sie sich f&#252;r eine Sendungsnachforschung an die Aufgabestelle.";
var sValidateTrackTraceInland = "Die eingegebene Sendungsnummer ist keine Nummer einer Inlandsendung.";
var sValidateTrackTraceAusland = "Die eingegebene Sendungsnummer ist keine Nummer einer Auslandsendung.";
var sValidateAttributesPAG = "Bitte w&#228;hlen Sie von jeder Kategorie mind. ein Attribut.";
var sValidateGeneralTerms = "Bitte akzeptieren Sie die Nutzungsbedingungen.";
var sValidateUseradminUsername = "Der Benutzername existiert bereits fuer das ausgewaehlte Projekt.";
var sValidateEventCodeAdmin = "Geben Sie einen Code ein der noch nicht mit diesem Event verwendet wird oder lassen Sie das Feld leer um einen neuen Code zu generieren.";
var sValidateEventCode = "Bitte geben Sie einen g&#252;ltigen Code ein.";
var sValidateEventTerm = "Das Datum der Anmeldefrist muss vor dem Veranstaltungsdatum liegen.";
var sValidateGlobalPoi = "Ein Globaler Punkt kann keine angeh&#228;ngten Angebote haben.";

/*
 * Really easy field validation with Prototype
 * http://tetlaw.id.au/view/javascript/really-easy-field-validation
 * Andrew Tetlaw
 * (Original Version 1.5.4.2 (2008-05-15))
 * @version 1.5.4.4unic1
 * 
 * @changelog 1.5.4.1unic1/AlR:		validate--required: added check for serverside functioning.
 *									and clientside validation by name instead of by parent element.<br/>
 *									validate-selection: added check for serverside functioning.
 * @changelog 1.5.4.2unic1/KeB		add the validator "checklast"
 * @changelog 1.5.4.3unic1/PhR		replaced the validator "validate-email" 
 * @changelog 1.5.4.4unic1/PhR		added several new validators for the reiseapplikation
 *
 * Copyright (c) 2007 Andrew Tetlaw
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 */

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', sRequired, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', sValidateNumber, function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', sValidateDigits, function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', sValidateAlpha, function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', sValidateAlphanum, function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-date', sValidateDate, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-date-past', sValidateDatePast, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
						( parseInt(RegExp.$1, 10) == d.getDate() ) && 
						( parseInt(RegExp.$3, 10) == d.getFullYear() ) &&
						( d.getTime() < (new Date()).getTime() );
			}],
	['validate-date-after', sValidateDateAfter, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				var dToday = new Date();
				var dDay = dToday.getDate();
				var dMonth = dToday.getMonth();
				var dYear = dToday.getFullYear();
				dToday = new Date(dYear, dMonth, dDay);
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
						( parseInt(RegExp.$1, 10) == d.getDate() ) && 
						( parseInt(RegExp.$3, 10) == d.getFullYear() ) &&
						( d.getTime() >= dToday.getTime() );
			}],
	['validate-date-time', sValidateDate, function(v) {
				return Validation.get('IsEmpty').test(v) || /\d{1,2}\.\d{1,2}\.\d{4}/.test(v)
			}],
	['validate-url-characters', sValidateUrlCharacters, function(v) {
				return Validation.get('IsEmpty').test(v) || /^([A-Z0-9\._-]*)$/i.test(v);
			}],
	['validate-general-terms', sValidateGeneralTerms, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-ra-url', sValidateUrlPAG, function(v, elm) {
				
				var sAddCondition = "";
				var bReturn = false;
				if (elm) {
					if (elm.value.indexOf("pag-") != 0) {
						bReturn = true;
					}
				}
				else {
					try {
						if (v) {
							if (v.indexOf("pag-") != 0) {							
								if (request.id) { 
									sAddCondition = " AND offr_id <> " + request.id;
								}
								var oDAO = new DAOLayerDb();
								var sSql = "!nocache: SELECT count(*) FROM tbl_ra_offer WHERE offr_shorturl = " + SecurityUtil.sqlEscape(v) + sAddCondition;
								var iCount = oDAO.read(sSql);
								
								if (iCount == 0) {
									bReturn = true;	
								}
							}
						}
						else {
							bReturn = true;	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-url :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],
			
	['validate-ra-webcodes', sValidateWebcodesPAG, function (v,elm) {
				var bReturn = true;
				if (!elm) {
					var bValidCode = true;
					var sCode, sNumber;
					var asItems = v.replace(/\r/gi, "").split("\n");
					var iItemCount;
					if(asItems.length > 0){
						var sCluster = Properties.getProperty("ReiseApplikation.CLUSTER");
						for (iItemCount = 0; iItemCount < asItems.length; ++iItemCount) {
							sCode = asItems[iItemCount];
							if (sCode != "") {
								bValidCode = Util.ValidWebcode(sCluster + "-" + sCode, null, request.id);
								if ((isNaN(sCode) || /^\s+$/.test(sCode)) || !bValidCode) {
									bReturn = false;
									break;
								}
							}
						}
					}
				}
				return bReturn;
			}],
			
	['validate-ra-pois', sValidatePointsPAG, function (v,elm) {
				if(Validation.get('IsEmpty').test(v)) return false;
				if (v) {
					var aPOIs = v.split(",");
					for (var iCount = 0; iCount < aPOIs.length; ++iCount) {
						if (aPOIs[iCount].split("$")[1] == "1") {
							return true;
						}
					}
				}
				return false;
			}],
			
	['validate-ra-attributes', sValidateAttributesPAG, function (v,elm) {
				if (!elm) {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							oDAO.openConnection();
							var sSql = "!nocache: SELECT COUNT(DISTINCT cat_id) FROM tbl_ra_attribute WHERE attr_id IN (" + v + ")";
							var iCount = oDAO.read(sSql);
							var iTotal = oDAO.read("!nocache: SELECT COUNT(cat_id) FROM tbl_ra_category WHERE cat_filter = 1");
							if (parseInt(iCount) != parseInt(iTotal)) {
								return false;
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-attributes :: " + oException.message);	
					}
					finally {
						if (oDAO) {
							oDAO.closeConnection();
						}
					}
				}
				return true;
			}],
			
	['validate-ra-thumbnail', sRequired, function (v,elm) {
				if (elm) {
					var oInput = $(elm.id + "_id");
					if (oInput && oInput.value != "" && oInput.value != "null") {
						return true;
					}
					else {
						if(Validation.get('IsEmpty').test(v)) return false;
					}
				}
				return true;
			}],
						
	['validate-ra-offer-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT offr_id FROM tbl_ra_offer WHERE offr_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-offer-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
			
	['validate-ra-poi-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT poi_id FROM tbl_ra_poi WHERE poi_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-poi-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
			
	['validate-ra-route-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT route_id FROM tbl_ra_route WHERE route_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-route-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
		
	['validate-ra-movie-name', sValidateNamePAG, function (v,elm) {
			var bReturn = false;
			if (elm) {
				bReturn = true;
			}
			else {
				try {
					if (v) {						
						var oDAO = new DAOLayerDb();
						var sSql = "!nocache: SELECT mov_id FROM tbl_ra_movie WHERE mov_title = " + SecurityUtil.sqlEscape(v);
						var aReturn = oDAO.read(sSql);
						
						if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
							bReturn = true;	
						}
					}
				}
				catch (oException) {
					Log4O.error("forms-add validators :: validate-ra-movie-name :: " + oException.message);	
				}
			}
			return bReturn;
		}],	
			
	['validate-ra-till', sValidateTillPAG, function (v,elm) {
				if (elm) {			
					var oFrom = $('valid_from');
					if (oFrom && oFrom.value != "") {
						if(Validation.get('IsEmpty').test(v)) return true;
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var f = new Date(oFrom.value.replace(regex, '$2/$1/$3'));
						var t = new Date(v.replace(regex, '$2/$1/$3'));
						if (t>=f) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				else {
					if (!v || (v == "")) {
						return true;
					}
					if (request.valid_from && request.valid_from != "") {
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var dFrom = new Date(request.valid_from.replace(regex, '$2/$1/$3'));
						var dTill = new Date(v.replace(regex, '$2/$1/$3'));
						if (dTill>=dFrom ) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				return false;
			}],
			
	['validate-ra-url-poi', sValidateUrlPAG, function(v, elm) {
				
				var sAddCondition = "";
				var bReturn = false;
				if (elm) {
					if (elm.value.indexOf("pag-") != 0) {
						bReturn = true;
					}
				}
				else {
					try {
						if (v) {
							if (v.indexOf("pag-") != 0) {							
								if (request.id) { 
									sAddCondition = " AND poi_id <> " + request.id;
								}
								var oDAO = new DAOLayerDb();
								var sSql = "!nocache: SELECT count(*) FROM tbl_ra_poi WHERE poi_shorturl = " + SecurityUtil.sqlEscape(v) + sAddCondition;
								var iCount = oDAO.read(sSql);
								
								if (iCount == 0) {
									bReturn = true;	
								}
							}
						}
						else {
							bReturn = true;	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-url-poi :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],
	['validate-shortcut-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT sc_id FROM tbl_shortcut WHERE sc_name = " + SecurityUtil.sqlEscape(v) + " AND sc_clusterconfig_id = " + SecurityUtil.sqlEscape(request.clusters);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-shortcut-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
	['validate-time', sValidateTime, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_double = /^(\d{2})\:(\d{2})$/;
				var regex_dot = /^(\d{2})\.(\d{2})$/;
				var regex_dash = /^(\d{2})\-(\d{2})$/;
				if(!regex_double.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf(":") > -1) {
					
					d = new Date(v.replace(regex_double, '01/01/1970 $1:$2'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '01/01/1970 $1:$2'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '01/01/1970 $1:$2'));
				}
				return ( ( parseInt(RegExp.$2, 10) == (d.getMinutes()) ) && 
							(parseInt(RegExp.$1, 10) == d.getHours()) );
			}],
	['validate-phone', sValidatePhone, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-fax', sValidateFax, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-mobile', sValidateMobile, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-email', sValidateEmail, function (v) {
				return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z0-9_.-])+([a-zA-Z0-9_.-])+/.test(v);
			}],
	['validate-url', sValidateUrl, function (v) {
				return Validation.get('IsEmpty').test(v) || /^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-shortcut-url', sValidateUrl, function (v) {
				return Validation.get('IsEmpty').test(v) || /^((http|https|ftp):\/\/)?((&[^\s]*;)?([\<\!WEM\s]*)?([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', sValidateDateAu, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-card-date', sValidateCardDate, function(v) {
				return Validation.get('IsEmpty').test(v) || /^(\d{2})\/(\d{4})$/.test(v);
			}],
	['validate-currency-dollar', sValidateCurrencyDollar, function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
			
	/* dropdownlists */
	['validate-selection', sValidateSelection, function(v,elm){
				/* clientside javascript */
				if (elm){
					return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
	
	/* checkboxes, radiobuttons */
	['validate-one-required', sValidateOneRequired, function (v,elm) {
				/* clientside javascript */
				if(elm){
					var sName = elm.getAttribute('name');
					var options = document.getElementsByName(sName);
					return $A(options).any(function(elm) {
						return $F(elm);
					});
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
			
	['validate-kudi-nachforschung-ausland-sender', sValidateKUDINachforschungAuslandSender, function (v,elm) {
				/* clientside javascript */
				if(elm){
					var sName = elm.getAttribute('name');
					var options = document.getElementsByName(sName);
					return $A(options).any(function(elm) {
						return $F(elm);
					});
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
			
	['validate-kudi-laufzeit', sValidateKUDILaufzeit, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
			
	['validate-kudi-attachment', sValidateKUDIAttachment, function(v,elm) {
				
				var sFileName = "";
				
				if (elm)
				{
					/* clienside javascript */
					sFileName = v;
				}
				else
				{
					/* serverside javascript */
					sFileName = v.name;
				}
				
				var bIsEmpty = Validation.get('IsEmpty').test(sFileName);

				if (bIsEmpty)
				{
					return true;
				}
				else
				{
					var sFileExtension = sFileName.substr(sFileName.lastIndexOf(".") + 1).toLowerCase();

					if (sFileExtension == "bmp" ||
						sFileExtension == "doc" ||
						sFileExtension == "docx" ||
						sFileExtension == "eml" ||
						sFileExtension == "htm" ||
						sFileExtension == "html" ||
						sFileExtension == "jpeg" ||
						sFileExtension == "jpg" ||
						sFileExtension == "pdf" ||
						sFileExtension == "tif" ||
						sFileExtension == "tiff" ||
						sFileExtension == "txt")
					{
						return true;
					}
					else
					{
						return false;
					}
				}
			}],
			
	['validate-number-list', sValidateNumbers, function (v,elm) {
				var asItems = v.replace(/\r/gi, "").split("\n");
				var bReturn = true;
				var iItemCount;
				if(asItems.length > 0){
					for (iItemCount = 0; iItemCount < asItems.length; ++iItemCount) {
						if (isNaN(asItems[iItemCount]) || /^\s+$/.test(asItems[iItemCount])) {
							bReturn = false;	
						}
					}
				}
				return bReturn;
			}],
			
	['validate-image-flash', sValidateImageFlash, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType;
				var asPossibleTypes = new Array(".jpg", ".gif", ".png", ".jpeg", ".swf");
				var aiPossibleMimeTypes = new Array(1, 2, 3, 4, 29, 101, 130);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.Mimetype != "application/octet-stream") {
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType) {
								bValid = true;
								break;
							}	
						}						
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-image', sValidateImage, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType;
				var asPossibleTypes = new Array(".jpg", ".gif", ".png", ".jpeg");
				var aiPossibleMimeTypes = new Array(1, 2, 3, 4, 101, 130);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.Mimetype != "application/octet-stream") {
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType) {
								bValid = true;
								break;
							}	
						}						
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-file-csv', sValidateFileCSV, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType, sExtension;
				var aiPossibleMimeTypes = new Array();
				aiPossibleMimeTypes.push(129);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.name) {
						sExtension = v.name.substr(v.name.lastIndexOf(".") + 1);
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType && Util.inArray(sExtension, oMimeType.fileExt.split(","))) {
								bValid = true;
								break;
							}
						}
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-one-required-seminar', sValidateSelection, function (v,elm) {
				return Validation.get('validate-one-required').test(v, elm);
			}],			
	
	/* captcha */
	['information_4', ' ', function(v) {
				return Validation.get('IsEmpty').test(v);
			}],
	['information_5', ' ', function(v) {
				return v=='Die Post';
			}],

	/* validate for a max length */
	['validate-maxlength-6', sValidateMaxLength6, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 6;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 6;
				}
			}],
	['validate-maxlength-8', sValidateMaxLength8, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 8;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 8;
				}
			}],
	['validate-maxlength-10', sValidateMaxLength10, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 10;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 10;
				}
			}],
	['validate-maxlength-40', sValidateMaxLength40, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 40;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 40;
				}
			}],
	['validate-maxlength-255', sValidateMaxLength255, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 255;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 255;
				}
			}],
	['validate-maxlength-2000', sValidateMaxLength2000, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 2000;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 2000;
				}
			}],
			
	/* validate for a specific length */
	['validate-length-4', sValidateLength4, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==4;
			}],
	['validate-length-6', sValidateLength6, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==6;
			}],	
	['validate-length-7', sValidateLength7, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==7;
			}],	
	['validate-length-8', sValidateLength8, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==8;
			}],	
	['validate-length-9', sValidateLength9, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==9;
			}],
	['validate-length-10', sValidateLength10, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==10;
			}],		
	
	/* validate for a min value */
	
	['validate-maxvalue-3', sValidateMaxValue3, function(v) {
				return Validation.get('IsEmpty').test(v) || v<4;
			}],
	['validate-maxvalue-200', sValidateMaxValue200, function(v) {
				return Validation.get('IsEmpty').test(v) || v<201;
			}],
	['validate-minvalue-100', sValidateMinValue100, function(v) {
				return Validation.get('IsEmpty').test(v) || v>99;
			}],
	['validate-minvalue-1000', sValidateMinValue100, function(v) {
				return Validation.get('IsEmpty').test(v) || v>999;
			}],	
						
	/* custom */
	['checkLast', '', function(v, elm) {
				if (elm) {
					var groupElements = document.getElementsByName(elm.name);
					var lastId = '';
					
					if (groupElements.length > 0) {
						lastId = groupElements[groupElements.length-1].id;
					}
					
					if (lastId.length > 0) {
						Validation.validate($(lastId));
					}
				}
				
				return true;
			}],
			
	/* specific */
	['validate-rrn', sValidateRRN, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				sValue = sValue.replace(/ /g, "");
				
				if (sValue.length == 9)
				{
					var sRRN = sValue.substring(0, sValue.length - 1);
					var sCheck = sValue.substring(sValue.length - 1, sValue.length);
			
					var Num = new String(sRRN);
					var ModTab = new Array(0,9,4,6,8,2,7,1,3,5);
					var Uebertrag = 0;
			
					for (var i = 0; i < Num.length; i++)
					{
						Uebertrag = ModTab[(Uebertrag + parseInt(Num.charAt(i))) % 10];
					}
			
					var sModulo10 = (10 - Uebertrag) % 10;
					
					if (sCheck == sModulo10)
					{
						bResult = true;
					}
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],
		
	['validate-zaz', sValidateZAZ, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /[0-9]{4}-[0-9]{1}/;
				var oResult = oRegEx.exec(sValue);
				
				if (sValue.length == 6 &&
					oResult &&
					oResult.index == 0)
				{
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],
		
	['validate-vat', sValidateVAT, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /[0-9]{4}-[0-9]{1}/;
				var oResult = oRegEx.exec(sValue);
				
				if (sValue.length == 6 &&
					oResult &&
					oResult.index == 0)
				{
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-file-5mb', sValidateFile5MB, function(v,elm){
				/* clientside javascript */
				if (elm){
					return true;
				}
				/* serverside ll script */
				else{
					var bReturn = true;
					if (v) {
						var oObject = new WebObject(WebObject.PICTURE);
						oObject.rawData = v;
						if (oObject.rawSize > 5242880) {
							bReturn = false;
						}
						oObject = null;
					}
					return bReturn;
				}
		}],

	['validate-tracktrace-international', sValidateTrackTraceInternational, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = oRegEx.test(sValue);
				
				if (bResult) {
					oRegEx = /^[^(ui)](.*)ch$/;
					bResult = oRegEx.test(sValue.toLowerCase());
				} else {
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-inland', sValidateTrackTraceInland, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = !oRegEx.test(sValue);
				
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-ausland', sValidateTrackTraceAusland, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = oRegEx.test(sValue);
				
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-validnumber', sValidateTrackTraceValidNumber, function(v,elm){
				/* clientside javascript */
				if (elm){
					return true;
				}
				/* serverside ll script */
				else{
					var bReturn = true;
					if (v && v != "") {
						var oClient = new TrackAndTraceWsClient(false);
						var sContent = oClient.ShipmentsSearch(language.current.virtualpath, v);
						if (sContent === false) {
							bReturn = false;
						} else {
							sContent.parse();
							if (!sContent || !sContent.Envelope) {
								bReturn = false;
							} else if (sContent.Envelope.Body && sContent.Envelope.Body.Fault) {
								bReturn = false;
							}
						}
					}
					return bReturn;
				}
		}],
	
	['validate-useradmin-password-required', sRequired, function (v,elm) { 
			if(elm){ 
				return (aPasswordProcessProjects[$('user_project').value] 
						|| !Validation.get('IsEmpty').test(v) 
						|| !Validation.get('IsEmpty').test($('user_password').value));
			} else { 
				return (ExternalUserUtil.projectUsesPasswordProcess(request.user_project) 
						|| !Validation.get('IsEmpty').test(v) 
						|| !Validation.get('IsEmpty').test(request.user_password)); 
			} 
		}],
	
	['validate-useradmin-username', sValidateUseradminUsername, function (v,elm) { 
			if(elm){ 
				return true;
			} else { 
				return ExternalUserUtil.checkUsername(request.id, v, request.user_project); 
			} 
		}],

	['validate-eventcode-admin', sValidateEventCodeAdmin, function(v,elm){
			/* clientside javascript */
			if (elm){
				return true;
			}
			/* serverside ll script */
			else{
				var bReturn = true;
				if (v && v != "") {
					var iGuestId = request.id;
					if (Check.ValidId(iGuestId)) {
						bReturn = !EventUtil.codeExists(v, request.evt_id, iGuestId);
					} else {
						bReturn = !EventUtil.codeExists(v, request.evt_id);
					}
				}
				return bReturn;
			}
		}],
		
	['validate-eventcode', sValidateEventCode, function(v,elm){
			/* clientside javascript */
			if (elm){
				return true;
			}
			/* serverside ll script */
			else{
				var bReturn = true;
				if (v && v != "") {
					bReturn = EventUtil.codeExists(v, request.evt_id);
				}
				return bReturn;
			}
		}],
		
	['validate-globalpoi-offer', sValidateGlobalPoi, function(v,elm){
			/* clientside javascript */
			if (elm){
				var bGlobalC = $('poi_global').checked;
				var sAngeboteC = $('angebote').value;
				if (bGlobalC && sAngeboteC && sAngeboteC.length > 0) {
					return false;
				}
				return true;
			}
			/* serverside ll script */
			else{
				var bGlobal = oForm.getValue('poi_global');
				var sAngebote = oForm.getValue('angebote');
				
				if (bGlobal && sAngebote && sAngebote.length > 0) {
					return false;
				}
				return true;
			}
		}],
	
	['validate-required-image', sRequired, function (v,elm) {
				if (elm) {
					var oInput = $(elm.id + "_id");
					if (oInput && oInput.value != "" && oInput.value != "null") {
						return true;
					}
					else {
						if(Validation.get('IsEmpty').test(v)) return false;
					}
				}
				return true;
			}],
	
		
	['validate-event-term', sValidateEventTerm, function (v,elm) {
				if (elm) {			
					var oDate = $('evt_date');
					if (oDate && oDate.value != "") {
						if(Validation.get('IsEmpty').test(v)) return true;
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var d = new Date(oDate.value.replace(regex, '$2/$1/$3'));
						var t = new Date(v.replace(regex, '$2/$1/$3'));
						if (d>t) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				else {
					if (!v || (v == "")) {
						return true;
					}
					if (request.evt_date && request.evt_date != "") {
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var dDate = new Date(request.evt_date.replace(regex, '$2/$1/$3'));
						var dTerm = new Date(v.replace(regex, '$2/$1/$3'));
						if (dDate>=dTerm ) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				return false;
			}]
])
