/*
* 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.1unic2
* 
* 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.
 */
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) {},
			onElementValidate : function(result, elm) {}
		}, 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}); });
			});
		}
	},
	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) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		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>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							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;lle dieses Pflichfeld aus.";
var sRequiredFormal = "Bitte f&#252;llen Sie dieses Pflichfeld aus.";
var sValidateNumber = "Bitte gib eine g&#252;ltige Zahl 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 gib ein g&#252;ltiges Datum ein (tt.mm.jjjj).";
var sValidateDateFormal = "Bitte geben Sie ein g&#252;ltiges Datum ein.";
var sValidateTime = "Please enter a valid time.";
var sValidatePhone = "Bitte gib eine g&#252;ltige Telefonnummer ein. Zum Beispiel +41 245 121 12 12 oder 061 454 12 12";
var sValidatePhoneFormal = "Bitte geben Sie eine g&#252;ltige Telefonnummer ein. Zum Beispiel +41 245 121 12 12 oder 061 454 12 12";
var sValidateEmail = "Bitte gib eine g&#252;ltige E-Mail Adresse ein. Beispiel: name@mail.com";
var sValidateEmailFormal = "Bitte geben Sie eine g&#252;ltige E-Mail Adresse ein. Beispiel: name@mail.com";
var sValidateUrl = "Bitte gib 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 $110.00.";
var sValidateSelection = "Bitte w&#228;hlen Sie ein Element aus.";
var sValidateOneRequired = "Bitte geben Sie oben eine Auswahl an.";
var sValidatePasswordConfirm = "Ihr Best&#228;tigungspasswort stimmt nicht mit dem ersten &#252;berein.";
var sRequiredZip = "Pflicht";
var sValidateChildBirthday = "Kind &#228;lter als 1 Jahr.";
var sValidateDbEmail = "E-Mail Adresse wurde bereits eingetragen.";
var sValidateWinterpromoCode = "SMS Code ist ung&#252;ltig.";
var sTeilnahmebedingungen = "Bitte akzeptiere die Teilnamebedingungen.";
var sValidateMaxLength500 = "Bitte max. 500 Zeichen eingeben.";
var sValidateAGB = "Bitte akzeptieren Sie die Teilnahmebedingungen und Datenschutzbestimmungen.";
/*
 * 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.1unic1
 * 
 * @changelog 1.5.4.1unic1/AlR:		validate-one-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/CoR		add anti-spam validator "captcha"
 *
 * 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);
			}],
	['required-formal', sRequiredFormal, 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-formal', sValidateDateFormal, 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-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}(\d|\ |\-|\(|\)){1,}(\d|\ ){1}$/.test(v)
			}],
	['validate-phone-formal', sValidatePhoneFormal, function (v) {
				return Validation.get('IsEmpty').test(v) || /^(0|\+){1}(\d|\ |\-|\(|\)){1,}(\d|\ ){1}$/.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\-])+(\.))+([a-zA-Z]{2,4})+$/ .test(v)
			}],
	['validate-email-formal', sValidateEmailFormal, function (v) {
				return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9])(([a-zA-Z0-9])*([\._-])?([a-zA-Z0-9]))*@(([a-zA-Z0-9\-])+(\.))+([a-zA-Z]{2,4})+$/ .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-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-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);
				}
			}],
			
			
	/* 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;
			}],
			
	['validate-maxlength-500', sValidateMaxLength500, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length<=500;
			}],				
	
	['required-nomsg', sRequiredZip, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
			
	['validate-zip-ch', sRequiredZip, function(v) {
				return (!isNaN(v) && !/^\s+$/.test(v)) && v.length==4;
			}],
	['validate-zip-de', sRequiredZip, function(v) {
				return (!isNaN(v) && !/^\s+$/.test(v)) && v.length==5;
			}],
	['validate-teilnahmebedingungen', sTeilnahmebedingungen, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-agb', sValidateAGB, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	/* birthday child has to be at least on year before today */			
	['validate-child-birthday', sValidateChildBirthday, function(v) {		
				var dNow = Date.parse(new Date());
				var dDate2 = new Date(v.substr(6,4), v.substr(3,2) - 1, v.substr(0,2));
				dDate2= Date.parse(dDate2);
				return Validation.get('IsEmpty').test(v) || parseInt((dNow-dDate2)/(24*60*60*1000)) <= (46*7);
			}],			
	/* send-a-sample email check */			
	['validate-db-email', sValidateDbEmail, function(v, elm) {		
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						var sDbFormName = Properties.getProperty("Form." + oForm.sFormName + ".dbFormName");
						if (sDbFormName) {
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT count(*) FROM tbl_form_data WHERE form = '" + sDbFormName + "' AND email = " + SecurityUtil.sqlEscape(v) + " AND sprachcode = '" + language.current.virtualpath + "';";	
							var iCount = oDAO.read(sSql);
							
							if (iCount == 0) {
								bReturn = true;	
							}
						}
						else {
							bReturn = true;
							Log4O.error("forms-add validators :: validate-db-email :: No form name 'dbFormName' specified in configuration");	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-db-email :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],	
	/* caotina email check */			
	['validate-db-email-caotina', sValidateDbEmail, function(v, elm) {		
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						var sDbFormName = Properties.getProperty("Form." + oForm.sFormName + ".dbFormName");
						if (sDbFormName) {
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT count(*) FROM tbl_form_data_caotina WHERE form = '" + sDbFormName + "' AND email = " + SecurityUtil.sqlEscape(v) + " AND sprachcode = '" + language.current.virtualpath + "';";	
							var iCount = oDAO.read(sSql);
							
							if (iCount == 0) {
								bReturn = true;	
							}
						}
						else {
							bReturn = true;
							Log4O.error("forms-add validators :: validate-db-email-caotina :: No form name 'dbFormName' specified in configuration");	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-db-email-caotina :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],	
	/* winterpromo code check */			
	['validate-winterpromo-code', sValidateWinterpromoCode, function(v, elm) {		
				var bReturn = false;
				if (elm || v == "wander-test") {
					bReturn = true;
				}
				else {
					try {
						var oDAO = new DAOLayerDb("Wander_Sms");
						var sSql = "!nocache: SELECT type_id from ovo_winterpromo_codes WHERE code = " + SecurityUtil.sqlEscape(v) + ";";
						var iType = oDAO.read(sSql);
						
						if (iType == 3 || iType == 8 || iType == 9) {
							var sDbFormName = Properties.getProperty("Form." + oForm.sFormName + ".dbFormName");
							oDAO = new DAOLayerDb();
							sSql = "!nocache: SELECT count(*) FROM tbl_form_data WHERE form = '" + sDbFormName + "' AND code = " + SecurityUtil.sqlEscape(v) + ";";	
							var iCount = oDAO.read(sSql);
							
							if (iCount == 0) {
								bReturn = true;
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-winterpromo-code :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],			
	/* captcha */
	['information_4', ' ', function(v) {
				return Validation.get('IsEmpty').test(v);
			}],
	['information_5', ' ', function(v) {
				return v=='0v0m4L71N3';
			}]		
]);
