$(document).ready(function() {
   
    $("#ctrabajos").css("display", "none");
    $("#ctrabajos").fadeIn(500);
  
    $("a.transicion").click(function(event){
        event.preventDefault();
        linkDestino = this.href;
        $("#ctrabajos").fadeOut(1000, redireccionarPag);      
    });
        
    function redireccionarPag() {
        window.location = linkDestino;
    }
    
});
/////
$(function()
{
	$("#mostrar").click(function(event) {
	event.preventDefault();
	$("#navegacion").slideToggle();
	});
	$("#navegacion a").click(function(event) {
	event.preventDefault();
	$("#navegacion").slideUp();
});
});
$(document).ready(function(){
	$('#slides').mouseenter(function(evento){
		evento.preventDefault();
		$('#toptienda').animate({top:'0px'}, 500 )
		$('#botcaso').animate({top:'635px'}, 500 )
		stop();
	    });
	
		$('#slides').mouseleave(function(evento){
		$('#toptienda').animate({top:'184px'}, 500 )
		$('#botcaso').animate({top:'510px'}, 500 )
	});
});
////TABS NOSOTROS///
$(document).ready(function()  
{  
    $(".tab_content").hide();  
    $("ul.tabs li:first").addClass("active").show();  
    $(".tab_content:first").show();  
  
    $("ul.tabs li").click(function()  
       {  
        $("ul.tabs li").removeClass("active");  
        $(this).addClass("active");  
        $(".tab_content").hide();  
  
        var activeTab = $(this).find("a").attr("href");  
        $(activeTab).fadeIn();  
        return false;  
    });  
});   
///////GALERIA
(function($) {

  $.fn.galimg = function() {

	return this.each(function() {
	  var idCapaGaleria = $(this).attr("id");
	
	  $("a", this).click(function() {
	  
		var rutaImagen = $(this).attr("href");
		var altImagen = $(this).children("img").attr("alt");
		
		$("#" + idCapaGaleria + " .imgprin img").fadeOut("normal").remove();
		
		var objImagen = new Image(); 
		
		$(objImagen).load(function() {
			$(this).hide();
			
            $("#" + idCapaGaleria + " .imgprin").append(this);
                                             
            $(this).fadeIn("slow");              
        });
		
		$(objImagen).attr("src", rutaImagen);
		
        return false;
      });
	});
  };
})(jQuery);
$(function() {

    $(".galimg").galimg();

});
///////GALERIA NOSOTROS
(function($) {

  $.fn.galimgn = function() {

	return this.each(function() {
	  var idCapaGaleria = $(this).attr("id");
	
	  $("a", this).click(function() {
	  
		var rutaImagen = $(this).attr("href");
		var altImagen = $(this).children("img").attr("alt");
		
		$("#" + idCapaGaleria + " .imgprinn img").fadeOut("normal").remove();
		
		var objImagen = new Image(); 
		
		$(objImagen).load(function() {
			$(this).hide();
			
            $("#" + idCapaGaleria + " .imgprinn").append(this);
                                             
            $(this).fadeIn("slow");              
        });
		
		$(objImagen).attr("src", rutaImagen);
		
        return false;
      });
	});
  };
})(jQuery);
$(function() {

    $(".galimgn").galimgn();

});
/////////DIRECTORES
$(document).ready(function() {
						   
	var hash = window.location.hash.substr(1);
	var href = $('#navd a').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.html #direccambios';
			$('#direccambios').load(toLoad)
		}											
	});

	$('#navd a').click(function(){
								  
		var toLoad = $(this).attr('href')+' #direccambios';
		$('#cargandot').slideDown('slow');
		$("#cargandot").css("visibility", "visible");
		$('#cargandot').animate({ height:'500px'}, 500,loadContent )
		$('#cargandot').animate({ height:'0px'}, 1000 )
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		function loadContent() {
			$('#direccambios').load(toLoad,'',showNewContent())
			
		}
		function showNewContent() {
			$('#direccambios').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#direccambios').fadeOut('normal');
		}
		return false;
		
	});

});
//TRABAJOS
$(document).ready(function() {
						   
	var hash = window.location.hash.substr(1);
	var href = $('#navt a').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.php #branding';
			$('#branding').load(toLoad)
		}											
	});

	$('#navt a').click(function(){
								  
		var toLoad = $(this).attr('href')+' #branding';
		$('#cargandot').slideDown('slow');
		$("#cargandot").css("visibility", "visible");
		$('#cargandot').animate({ height:'500px'}, 500,loadContent )
		$('#cargandot').animate({ height:'0px'}, 1000 )
		$('#txt').text("Soy un texto generado por jQuery!");
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		function loadContent() {
			$('#branding').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#branding').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#branding').fadeOut('normal');
		}
		return false;
		
	});

});
///
////TABS NOSOTROS///
$(document).ready(function()  
{  
    $(".tabs_content").hide();  
    $("ul.tabss li:first").addClass("active").show();
	$("#scomerciales").addClass("active");
    $(".tabs_content:first").show();  
  
    $("ul.tabss li").click(function()  
       {  
        $("ul.tabss li").removeClass("active");  
        $(this).addClass("active");
		$("#scomerciales").removeClass("active")
		$(this).addClass("active");
        $(".tabs_content").hide();  
  
        var activeTab = $(this).find("a").attr("href");  
        $(activeTab).fadeIn();  
        return false;  
    });  
});   
///////
//NOTICIAS
$(document).ready(function() {
						   
	var hash = window.location.hash.substr(1);
	var href = $('#navn a').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.php #branding';
			$('#branding').load(toLoad)
		}											
	});

	$('#navn a').click(function(){
								  
		var toLoad = $(this).attr('href')+' #branding';
		$('#cargandot').slideDown('slow');
		$("#cargandot").css("visibility", "visible");
		$('#cargandot').animate({ height:'500px'}, 500,loadContent )
		$('#cargandot').animate({ height:'0px'}, 1000 )
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		function loadContent() {
			$('#branding').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#branding').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#branding').fadeOut('normal');
		}
		return false;
		
	});

});
///IMAGENES HOVER
$(document).ready(function () {
  $(".fadeimagen").fadeTo(1,9.9);
  $(".fadeimagen").hover(
    function () {
      $(this).fadeTo("fast",0.8);
    },
    function () {
      $(this).fadeTo("normal", 1);
    }
  );
});
