function formValidatorClass(form, options){	this.form		= form;	this.options	= options;	this.errors		= {		'checked'	: 'Laukam jābūt atzīmētam',		'selected'	: 'Vērtībai jābūt izvēlētai',		'length'	: 'Input more then % symbols',		'equal'		: 'Lauka vērtībai jāsakrīt ar "%"',		'typeInt'	: 'Jāierakstā skaitli',		'date'		: 'Datumu jāierakstā formātā: 31.12.1999',		'email'		: 'Email isn`t valid'	}		this.init = function()	{		var owner = this;		this.form.submit(function(event){			var result = owner.validate();			if(result) 			{				return this.submit();			}			else			{				event.preventDefault();			}		});	}	this.clearErrors = function()	{		jQuery('input,select,textarea', this.form).not('.point').css({			background : '#FFF'		});		jQuery('.validatorHint').remove();	}	this.validate = function() 	{		this.clearErrors();		var error = false;				for(x in this.options)		{			var item = jQuery('[name="' + x + '"]', this.form);			var v = item.val();			var o =this.options[x].split('=');						switch(o[0])			{				case 'length':					if(!this.validateLength(v, o[1])){						this.showError(item, this.errors.length.replace('%',o[1]));						if(!error)						{							error = true;							item.focus();						}					}				break;				case 'checked':					if(!item.attr('checked')) {						this.showError(item, this.errors.checked);						if(!error)						{							error = true;							item.focus();						}					}				break;				case 'selected':					v = jQuery('[name="' + x + '"] option:selected', this.form).val();					if(!v) {						this.showError(item, this.errors.selected);						if(!error)						{							error = true;							item.focus();						}					}				break;								case 'type':					switch(o[1])					{						case 'formated_date':							if(v.length!=10)							{								this.showError(item, this.errors.date);								if(!error)								{									error = true;									item.focus();								}							}						break;												case 'integer':							if(!(parseInt(v)==v && /^-?\d+$/.test(v+'')))							{								this.showError(item, this.errors.typeInt.replace('%'));								if(!error)								{									error = true;									item.focus();								}							}						break;												case 'decimal':							if(!(parseFloat(v)==v))							{								this.showError(item, this.errors.typeInt.replace('%'));								if(!error)								{									error = true;									item.focus();								}							}						break;						case 'email':							var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;							if(!v || !pattern.test(v))							{								this.showError(item, this.errors.email);								if(!error)								{									error = true;									item.focus();								}							}						break;					}				break;								case 'equal':					var compareWith = jQuery('[name=' + o[1] + ']', this.form);					if(v=='' || v!=compareWith.val()){						this.showError(item, this.errors.equal.replace('%', jQuery(compareWith).parent().find('label').html()));						if(!error)						{							error = true;							item.focus();						}					}				break;							}		}		jQuery('input.errors', this.form).blur(function(){			jQuery('.validatorHint[rel="' + this.name + '"]').remove();		});				if(!error)		{			return true;		}		return false;	}		this.showError = function(item, err)	{		if(!item) return;		if(!item.position()) return;		var l = item.offset().left + item.outerWidth(true);		var hint = jQuery('<div></div>')			.css({				cursor : 'pointer',				opacity : 0,				left : parseInt(l + 200) + 'px',				top : item.offset().top + 'px'			})			.text(err)			.addClass('validatorHint')			.click(function(){ jQuery(this).remove(); })			.attr({				'rel' : item.attr('name')			});		jQuery('body').prepend(hint);		hint.animate({			left : parseInt(l-10) + 'px',			opacity : 1		}, 300, function(){			jQuery(this).animate({				left : parseInt(l+5) + 'px'			}, 200)		});				item			.addClass('errors')			.css({				background : '#ECB'			});				}		this.validateLength = function(val, len)	{		if(val){			if(val.length>=len) return true;		}		return false;	}		this.init();	}
