// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

$(function() {
 
 $("img").lazyload();

 
  // flash
  $('#flash').fadeOut(3000);

//  $("#menu a").each(function(){
//    var href = $(this).attr("href");
//    $(this).click(function(){
//       $("#contenido .span-17").fadeOut("slow").load(href).fadeIn("slow"); //Le damos efecto
//       $(this).attr({ href: "#"});
//    });
//  });


// Efecto al pasar sobre una fila de una tabla 
 	$("table.lista tbody tr").mouseover( function() {
		if ($(this).hasClass("fila-par") || $(this).hasClass("fila-impar")) {
			$(this).addClass("fila-encima");
		}
	}).mouseout( function() {
    if($(this).hasClass("fila-par") || $(this).hasClass("fila-impar")){
			$(this).removeClass("fila-encima");
		}
  });

// Efecto al pasar sobre una celda de una tabla 
 	$("table.lista-staff tbody tr td").mouseover( function() {
			$(this).addClass("celda-encima");
	}).mouseout( function() {
			$(this).removeClass("celda-encima");
  });
// Efecto al pasar sobre un div 
 	$("div.sobresalto").mouseover( function() {
		if ($(this).hasClass("fondo-oscuro-tx")) {
			$(this).removeClass("fondo-oscuro-tx");
			$(this).addClass("fondo-medio-tx");
		}
	}).mouseout( function() {
    if($(this).hasClass("fondo-medio-tx")){
			$(this).removeClass("fondo-medio-tx");
			$(this).addClass("fondo-oscuro-tx");
		}
  });
  
// Efecto al pasar sobre un div 
 	$("div.sobresalto-inverso").mouseover( function() {
		if ($(this).hasClass("fondo-medio-tx")) {
			$(this).removeClass("fondo-medio-tx");
			$(this).addClass("fondo-oscuro-tx");
		}
	}).mouseout( function() {
    if($(this).hasClass("fondo-oscuro-tx")){
			$(this).removeClass("fondo-oscuro-tx");
			$(this).addClass("fondo-medio-tx");
		}
  });

// Efecto al pasar sobre un div 
 	$("div.efecto").mouseover( function() {
		if ($(this).hasClass("fondo-claro-tx")) {
			$(this).removeClass("fondo-claro-tx");
			$(this).addClass("fondo-destacado");
		}
	}).mouseout( function() {
    if($(this).hasClass("fondo-destacado")){
			$(this).removeClass("fondo-destacado");
			$(this).addClass("fondo-claro-tx");
		}
  });

// Efecto al coger o perder el foco los elementos de un formulario
  $("input, select, textarea").focus(function () {
		if ($(this).hasClass("text-activo"))
			$(this).removeClass("text-activo");
		else
			$(this).addClass("text-activo");
			if(this.value == this.defaultValue)
			   this.select();
  });

  $("input, select, textarea").blur(function () {
		if ($(this).hasClass("text-activo"))
			$(this).removeClass("text-activo");
  });

  // redondeo de esquinas
  Nifty("div.redondeame","tr bl tl br transparent");
  Nifty("div.redondeame-arriba","tr tl transparent");
  Nifty("div.redondeame-abajo","bl br transparent");		
  Nifty("div.redondeame-derecha","tr br transparent");
  Nifty("div.redondeame-izquierda","bl tl transparent");

  $(".informe").hover(
    function () {
      $(this).addClass("fondo-medio");
    }, 
    function () {
      $(this).removeClass("fondo-medio");
    }
  );


	
});

function jqsubmit(tlink, obj){
	txtvar = "<input id='" + tlink + "' name='" + tlink + "' type='hidden' value='" + tlink + "' />"
	$(obj).before(txtvar);
	$(obj).parents('form').submit();
}