$(function() {

    $("#explore-nav li a").click(function() {
        
        // Figure out current list via CSS class
        var curList = $("#explore-nav li a.current").attr("rel");
        
        // List moving to
        var $newList = $(this);
        
        // Set outer wrapper height to height of current inner list
        var curListHeight = $("#all-list-wrap").height();
        $("#all-list-wrap").height(curListHeight);
        
        // Remove highlighting - Add to just-clicked tab
        $("#explore-nav li a").removeClass("current");
        $newList.addClass("current");
        
        // Figure out ID of new list
        var listID = $newList.attr("rel");
        
        if (listID != curList) {
            
            // Fade out current list
            $("#"+curList).fadeOut(100, function() {
                
                // Fade in new list on callback
                $("#"+listID).fadeIn("fast");
				
					//funcion igualamos el alto de las columnas START
					$(function() {
						var lef = $('#lside');
						var lefHeight = $('#lside').height();
						var cen = $('#cside');
						var cenHeight = $('#cside').height();
						var rig = $('#rside');
						var rigHeight = $('#rside').height();
						
						if (lef.height() < cenHeight) {
							lef.height(cenHeight);
						}else{
							cen.height(lefHeight);
						}
						if (cen.height() < rigHeight) {
							cen.height(rigHeight);
						}else{
							rig.height(cenHeight);
						}
			
					});
					//funcion igualamos el alto de las columnas END
                
                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap").height(newHeight);
            
            });
            
        }        
        
        // Don't behave like a regular link
        return false;
    });

});
