/**
 * @author stefano
 */

//se IE6 fix per hover sui bottoni
$(document).ready(function(){
	if (!jQuery.support.boxModel) 
		$('input').hover(function(){$(this).addClass('onHover')},function(){$(this).removeClass('onHover')});
		
	/*preload tips*/	
	$("<img src='img/tip-dx-b-large.png' />");
	$("<img src='img/tip-sotto.png' />");
	$("<img src='img/tip-s.png' />");
	$("<img src='img/tip-s-sx.png' />");
	$("<img src='img/tip-sx-b-large.png' />");
	$("<img src='img/tip-sx-b.png' />");
});

function updateTips(t) {
	$("#validateTips").html("<div class='error'>"+t+"</div>").effect("highlight",{'color':'#DA8DAD'},1500);
}
function checkObbligatorio(o,n) {
	if ( !o.val() || parseInt(o.val())==0) {
		o.focus();
		updateTips("The field '"+ n +"' is complulsory and it can't be empty or zero");
		return false;
	} else {
		return true;
	}
}
function checkLength(o,n,min,max) {
	if ( !o.val() || o.val().length > max || o.val().length < min ) {
		o.focus();
		updateTips("The field '"+ n +"' is not right, check dimension");
		return false;
	} else {
		return true;
	}
}
function checkRegexp(o,regexp,n) {
	if ( !( regexp.test( o.val() ) ) ) {
		o.focus();
		updateTips(n);
		return false;
	} else {
		return true;
	}
}
function checkMisure(o,regexp,n) {
	var valore=o.val().split(" ")[0];
	if ( !( regexp.test( valore ) ) ) {
		o.focus();
		updateTips(n);
		return false;
	} else {
		return true;
	}
}
function checkEquals(o1,o2,n){
	if (!o1.val() || !o2.val() || o1.val()!=o2.val()) {
		o1.focus();
		updateTips(n);
		return false;
	} else {
		return true;
	}
}
function checkCheckbox(o,n){
	if (!o.size()) {
		o.focus();
		updateTips(n);
		return false;
	} else {
		return true;
	}
}
function isNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}

