/* 
 * @author: wm
 */

// Deklaracja klasy
function Validation() {
}

Validation.prototype.updateTips = function(t) {
	var tips = $( ".validateTips" );
	tips
		.text( t )
		.addClass( "ui-state-highlight" );
	setTimeout(function() {
		tips.removeClass( "ui-state-highlight", 1500 );
	}, 500 );
}

Validation.prototype.checkLength = function( o, n, min, max ) {
	if ( o.val().length > max || o.val().length < min ) {
		o.addClass( "ui-state-error" );
		this.updateTips( "Pole " + n + " nie może być puste." );
		return false;
	} else {
		return true;
	}
}

Validation.prototype.checkRegexp = function( o, regexp, n ) {
	if ( !( regexp.test( o.val() ) ) ) {
		o.addClass( "ui-state-error" );
		this.updateTips( n );
		return false;
	} else {
		return true;
	}
}

var validation = new Validation();

