function trim(str){
	return str.replace(/^\s+|\s+$/g,"");
}

$(function(){
	var error_mess_ricerca = {id: 'error_mess_ricerca',
            position: 'bottom',
            size: 50,
            backgroundColor: 'red',
            delay: 3000,
            speed: 500,
            fontSize: '30px'
           };
	
	$("#form-ricerca").submit(function(event){
		var validato = true;
		var categoriaVal = $("#searchpub_categoria_id option:selected").val();
		var sottocategoriaVal = $("#searchpub_sottocategoria_id option:selected").val();
		if(
				(trim($("#form-ricerca-testo").val()).length == 0) &&
				categoriaVal == "-1" &&
				sottocategoriaVal == "-1"
			)
		{
			validato = false;
			$.showMessage(__('campo_ricerca_vuoto'), error_mess_ricerca);
		}
		return validato;
	});
});
