$(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(300, function() {
                
                // Fade in new list on callback
                $("#"+listID).fadeIn();
                
                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap").animate({
                    height: newHeight
                });
            
            });
            
        }        
        
        // Don't behave like a regular link
        return false;
    });

    $("#explore-nav2 li a").click(function() {

        // Figure out current list via CSS class
        var curList = $("#explore-nav2 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-wrap2").height();
        $("#all-list-wrap2").height(curListHeight);

        // Remove highlighting - Add to just-clicked tab
        $("#explore-nav2 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(300, function() {

                // Fade in new list on callback
                $("#"+listID).fadeIn();

                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap2").animate({
                    height: newHeight
                });

            });

        }

        // Don't behave like a regular link
        return false;
    });

    $("#explore-nav3 li a").click(function() {

        // Figure out current list via CSS class
        var curList = $("#explore-nav3 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-wrap3").height();
        $("#all-list-wrap3").height(curListHeight);

        // Remove highlighting - Add to just-clicked tab
        $("#explore-nav3 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(300, function() {

                // Fade in new list on callback
                $("#"+listID).fadeIn();

                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap3").animate({
                    height: newHeight
                });

            });

        }

        // Don't behave like a regular link
        return false;
    });

    $("#explore-nav4 li a").click(function() {

        // Figure out current list via CSS class
        var curList = $("#explore-nav4 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-wrap4").height();
        $("#all-list-wrap4").height(curListHeight);

        // Remove highlighting - Add to just-clicked tab
        $("#explore-nav4 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(300, function() {

                // Fade in new list on callback
                $("#"+listID).fadeIn();

                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap4").animate({
                    height: newHeight
                });

            });

        }

        // Don't behave like a regular link
        return false;
    });

    $("#explore-nav5 li a").click(function() {

        // Figure out current list via CSS class
        var curList = $("#explore-nav5 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-wrap5").height();
        $("#all-list-wrap5").height(curListHeight);

        // Remove highlighting - Add to just-clicked tab
        $("#explore-nav5 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(300, function() {

                // Fade in new list on callback
                $("#"+listID).fadeIn();

                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#"+listID).height();
                $("#all-list-wrap5").animate({
                    height: newHeight
                });

            });

        }

        // Don't behave like a regular link
        return false;
    });



});

