// Extensiones
$.extend({
	stop: function(e){
        if (e.preventDefault) e.preventDefault();
        if (e.stopPropagation) e.stopPropagation();
    }
});

    $(window).load(function() {
      $('.on_off :checkbox').iphoneStyle();      
    });
    //$('#loginlink').tipsy({fallback: "Where's my tooltip yo'?" });
    //$('#loginlink').tipsy("show");

$(document).ready(function(){
	
    $('#accesologin').click(function(){
        $('#accesologinbox').toggle("blind");
        return false;
    });

	//Ocurrencias BORRAR
	$("#capita").click(function(event){
    	event.preventDefault();
    	$(".CapaEditarEvento").delay(500).show("blind");
    	$(".capanuevoEvento").hide("blind");
    });
    $("#cerrarcapita").click(function(event){
    	event.preventDefault();
    	$(".CapaEditarEvento").hide("blind");
    	$(".capanuevoEvento").delay(500).show("blind");
    });
	
	//Validacion en perfil

	$(".validable").bind("submit", function(e){
			
		if (typeof filters == 'undefined') return;
		$(this).find("input, textarea, select").each(function(x,el){ 
			if ($(el).attr("className") != 'undefined') { 
		$(el).removeClass("errorform");
			$.each(new String($(el).attr("className")).split(" "), function(x, klass){
				if ($.isFunction(filters[klass]))
					if (!filters[klass](el))  $(el).addClass("errorform");
			});
			}
		});
		if ($(this).find(".errorform").size() > 0) {
			mostrar(error);
			$.stop(e || window.event);
			return false;
		}
		return true;
	});
	
	
	//Ocultar mensajes
	
	//$(".success").delay(3000).hide("blind");
  
   $("#ocultar").click(function(event){
    event.preventDefault();
    $(".success").hide("slow");
   });

   $("#mostrar").click(function(event){
    event.preventDefault();
    $(".success").show(3000);
   });
   
   //Validacion en eventos
   
   $(".eventFormA").bind("submit", function(e){
		//$("#successData").show();
		if (typeof filters == 'undefined') return;
		$(this).find("input, textarea, select").each(function(x,el){ 
			if ($(el).attr("className") != 'undefined') { 
		$(el).removeClass("eventerrorform");
			$.each(new String($(el).attr("className")).split(" "), function(x, klass){
				if ($.isFunction(filters[klass]))
					if (!filters[klass](el))  $(el).addClass("eventerrorform");
			});
			}
		});
		if ($(this).find(".eventerrorform").size() > 0) {
			mostrar(error);
			$("#errorvalid").show("blind");
			$("#errorvalid").delay(3000).hide("blind");
			$.stop(e || window.event);
			
			return false;
		}
		
		//return true;
		ActualizarDatos();
		return false;
	});
	
	$(".eventFormNew").bind("submit", function(e){
		//$("#successData").show();
		if (typeof filters == 'undefined') return;
		$(this).find("input, textarea, select").each(function(x,el){ 
			if ($(el).attr("className") != 'undefined') { 
		$(el).removeClass("eventerrorform");
			$.each(new String($(el).attr("className")).split(" "), function(x, klass){
				if ($.isFunction(filters[klass]))
					if (!filters[klass](el))  $(el).addClass("eventerrorform");
			});
			}
		});
		if ($(this).find(".eventerrorform").size() > 0) {
			mostrar(error);
			$("#errorvalid").show("blind");
			$("#errorvalid").delay(3000).hide("blind");
			$.stop(e || window.event);
			
			return false;
		}
		
		//return true;
		GrabarDatos();
		return false;
	});
	
	
});

