$.extend({
		/* PARAMOS LA EJECUCIÓN*/
	stop: function(e){
		if (e.preventDefault) e.preventDefault();
		if (e.stopPropagation) e.stopPropagation();
	}, 
	/* PERSONALIZAMOS LA SALIDA POR PANTALLA */
	alert: function(str) {
		alert(str);	
	}
});
$(document).ready(function(){
	$("form.validable").bind("submit", function(e){
		if (typeof filters == 'undefined') return;
		$(this).find("input, textarea, select, input[name=referencia]:checked").each(function(x,el){ 
			if ($(el).attr("className") != 'undefined') { 
		$(el).removeClass("error");
			$.each(new String($(el).attr("className")).split(" "), function(x, klass){
				if ($.isFunction(filters[klass]))
					if (!filters[klass](el))  $(el).addClass("error");
			});
			}
		});
		if ($(this).find(".error").size() > 0) {
			$.stop(e || window.event);
			return false;
		}
		if(typeof $("input[name=referencia]:checked").val() == 'undefined'){
			$.alert("seleccione una referencia");
			return false;
		}else{
			return true;
		}
		//return true;
	});
	
	$("form.validableBuscar").bind("submit", function(e){
		if (typeof filters == 'undefined') return;
		$(this).find("input, textarea, select, input[name=referencia]:checked").each(function(x,el){ 
			if ($(el).attr("className") != 'undefined') { 
		$(el).removeClass("error");
			$.each(new String($(el).attr("className")).split(" "), function(x, klass){
				if ($.isFunction(filters[klass]))
					if (!filters[klass](el))  $(el).addClass("error");
			});
			}
		});
		if ($(this).find(".error").size() > 0) {
			$.stop(e || window.event);
			return false;
		}
		return true;
		//return true;
	});
	
	
});
	