
function TCore_FormValidatorObject() {
				
				/* Properties */
				
				this.emailRegexp = /^[a-z0-9,!#\$%&'\*\+\/\=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+\/\=\?\^_`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$/i;
				this.NIPRegexp = /^[0-9]{10}$/;
				this.PESELRegexp = /^[0-9]{11}$/;
				this.nbsp = 160;		
				this.emptyString = /^\s*$/ ;
				
				this.FieldErrorClassName = 'FormFieldError';
						
				this.tempPasswordInput;
						
				this.oFocusField;
				
				this.oValues = new Object();						
				
				/* Properties End*/
					
				/* Methods */					
 
				this.FocusCallback = function() {
  					this.oFocusField.focus();
				}
 
				this.SetFocus = function(oField) {
					this.oFocusField = oField;
					setTimeout( 'FocusCallback()', 100 );
				}
							
				this.SetError = function(sMessage) {
					alert(sMessage);
				}
				
				this.TrimSpaces = function(sValue) {
					return sValue.replace(/^\s+|\s+$/g, '');
				}
				
				this.SetDefaultStyle = function(oField) {
					oField.className = oField.className.substring(0,oField.className.length - this.FieldErrorClassName.length);
				}
				
				this.SetErrorStyle = function(oField) {
					oField.className = oField.className + ' ' + this.FieldErrorClassName;
				}
				
				this.SaveValue = function(oField) {
					if(!oField.valueIsError) {
						this.oValues[oField.id] = oField.value;
					}
				}
				
				this.Restore = function(oField) {
					if(oField.valueIsError) {
						oField.valueIsError = false;
						if(typeof this.oValues[oField.id] == 'undefined')
							this.oValues[oField.id] = '';
											
						if(oField.wasPassword) {
							// tu sie explorer wypierdala no nie wie jak zmienic typ :/
							oField.type = 'password';
							oField.value = '';
						} else {
							if(oField.type == 'textarea') oField.innerHTML = this.oValues[oField.id];
							oField.value = this.oValues[oField.id];
						}
						
						this.SetDefaultStyle(oField);
						
						oField.focus();
					} else {
						return;
					}
				}
				
				this.Erase = function(oField, sInfoId) {
					if(oField.valueIsError) {
						oField.valueIsError = false;
						
						if(typeof this.oValues[oField.id] == 'undefined')
							this.oValues[oField.id] = '';
						if(typeof sInfoId == 'undefined') {
							if(oField.type == 'textarea') oField.innerHTML = this.oValues[oField.id];
							oField.value = this.oValues[oField.id];
							this.SetDefaultStyle(oField);
						} else {
							document.getElementById(sInfoId).innerHTML = String.fromCharCode(this.nbsp);
						}
						
					} else {
						return;
					}
				}
				
				this.ShowMessage = function(oField, sMessage, sInfoId) {
					this.SaveValue(oField);
					oField.valueIsError = true;
									
					if(typeof sInfoId == 'undefined') {
						if(oField.type == 'password') { 
							oField.wasPassword = true;
						//no i tu sie tez wypierdala IE z tym typem, a mnie juz brakuje pomyslow.
							try {
								oField.type = 'text';
							} catch(err) {
								alert('Error:  '+err.description);
							}
						}
						oField.value = sMessage;
						this.SetErrorStyle(oField);
					} else {
						document.getElementById(sInfoId).innerHTML = sMessage;
					}
				}
				
				this.ValidationResultHandler = function(sMessage) {
					alert(sMessage);
				}
				
				
				/* Validation Methods */
				
				this.EmailCheck = function(oField, sMessage, sInfoId) {
					var sValue = this.TrimSpaces(oField.value);
					if (!this.emailRegexp.test(sValue)) {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					} else {
						return true;
					}
				}
				
				this.NIPCheck = function(oField, sMessage, sInfoId) {
					var sValue = this.TrimSpaces(oField.value);
					if (!this.NIPRegexp.test(sValue)) {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					} else {
						var arrSteps = new Array(6, 5, 7, 2, 3, 4, 5, 6, 7);
						var intSum =0;
						for(var i=0;i<9;i++) {
							intSum += arrSteps[i] * parseInt(sValue.charAt(i));
						}
						intSum = intSum % 11;
						var checkSum = intSum % 10;
						if(parseInt(sValue.charAt(9))==checkSum) return true;
						else {
							this.ShowMessage(oField, sMessage, sInfoId);
							return false;
						}
					}
				}
				
				this.PESELCheck = function(oField, sMessage, sInfoId) {
					var sValue = this.TrimSpaces(oField.value);
					if (!this.PESELRegexp.test(sValue)) {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					} else {
						var arrSteps = new Array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3, 1);
						var intSum =0;
						for(var i=0;i<11;i++) {
							intSum += arrSteps[i] * parseInt(sValue.charAt(i));
						}
						var checkSum = intSum % 10;
						if(checkSum==0) return true;
						else {
							this.ShowMessage(oField, sMessage, sInfoId);
							return false;
						}
					}
				}
 
				
				this.Required = function(oField, sMessage, sInfoId) {
					if (this.emptyString.test(oField.value)) {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					} else {
						return true;
					}
				}
				
				this.HasLengthBetween = function(oField, iFrom, iTo, sMessage, sInfoId) {
					var iValue = this.TrimSpaces(oField.value).length;
					if(iValue >= iFrom && iValue <= iTo) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.SameAs = function(oField, oPatternField, sMessage, sInfoId) {
					var sPattern = this.TrimSpaces(oPatternField.value);
					var sValue = this.TrimSpaces(oField.value);
					
					if(sPattern == sValue) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.MatchRegexp = function(oField, sRegExp, sMessage, sInfoId) {
					if(sRegExp.test(this.TrimSpaces(oField.value))) {
						return true;	
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsSelected = function(oField, sDefault, sMessage, sInfoId) {
					if(oField.value != sDefault) {
						return true;	
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsLessThan = function(oField, iValue, sMessage, sInfoId) {
					if(this.TrimSpaces(oField.value) < iValue) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsLessOrEqualTo = function(oField, iValue, sMessage, sInfoId) {
					if(this.TrimSpaces(oField.value) <= iValue) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsGreaterThan = function(oField, iValue, sMessage, sInfoId) {
					if(this.TrimSpaces(oField.value) > iValue) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsGreaterOrEqualTo = function(oField, iValue, sMessage, sInfoId) {
					if(this.TrimSpaces(oField.value) <= iValue) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				this.IsChecked = function(oField, sMessage, sInfoId) {
					if(oField.checked) {
						return true;
					} else {
						this.ShowMessage(oField, sMessage, sInfoId);
					    return false;
					}
				}
				
				/* Validation Methods End*/
				
				/* Methods end */
													
			} /* class end */


