/* ==================================================================================================== */

$.fn.setInvalid = function() {
	this.addClass('invalid');
	return this;
}

$.fn.setValid = function() {
	this.removeClass('invalid');
	return this;
}

/* ==================================================================================================== */

$.fn.isEmpty = function() {
	if($(this).val() == '')
		return true;

	return false;
}

/* ==================================================================================================== */

$.fn.isNumeric = function() {
	if(isNaN($(this).val()) || ($(this).val().length == 0))
		return false;

	return true;
}

$.fn.parseInt = function() {
	$(this).val(parseInt($(this).val()));
	return this;
}

$.fn.parseFloat = function() {
	$(this).val(parseFloat($(this).val()));
	return this;
}

$.fn.validateNumeric = function(alt) {
	if($(this).isNumeric()) {
		$(this).setValid();
	}
	else
		if(alt == null)
			$(this).setInvalid()
		else {
			$(this).val(alt);
			$(this).validateNumeric();
		}

	return this;
}

/* ==================================================================================================== */
