function addDays(myDate,days) {
	return new Date(myDate.getTime() + days*24*60*60*1000);
}
function checkLength( o, n, min, max ) {
	if ( o.val().length > max || o.val().length < min ) {
		o.addClass( "ui-state-error" );
		updateTips( "Valore " + n + " non valido." );
		return false;
	} else {
		return true;
	}
}
function checkInterval(fromField, toField, from, to,  message) {
	if (from > to) {
		fromField.addClass( "ui-state-error" );
		updateTips( message );
		return false;
	}
	return true;
}
function updateTips( t ) {
	$("validateTips")
		.text( t )
		.addClass( "ui-state-highlight" );
	setTimeout(function() {
		$("validateTips").removeClass( "ui-state-highlight", 1500 );
	}, 500 );
}

function parseIsoDate(isoDate) {
	var queryDate = isoDate,
		dateParts = queryDate.match(/(\d+)/g);
	return new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);  
}
