    $(document).ready(function() {



        if ($(".score").length > 0 ) {
            animateResults();
        }

        function animateResults(){
        $(".score span").each(function(){
            var width = $(this).width();
            animateWidth(this,width,"slow");
            });
        }

        //---------------------------------------------------------------------
        function animateWidth(obj,width,speed){
            $(obj).css({width: "0%"}).animate({ width: width}, speed);
        }

        //---------------------------------------------------------------------


        //hide everything marked .closed
        $('.closed').next().hide();


        //just .top defaults to closed
        $(".top:not(.open,closed)").next().hide();


        $(".top").click(function() {
            var next = $(this).next();
            $(next).slideToggle('slow');
            $(this).removeClass("closed").toggleClass('open');

            //if revealed container has score bars they need animating
            if ( $(next).find(".score").length > 0 ) {//--
                var score_obj = $(next).find(".score span");
                
                $(score_obj).each(function(){
                    var width = $(this).width();
                    
//                    $(this).toggle(function() {
//                        var width = $(this).width();
//                        $(this).css({width: "0%"}).animate({ width: width}, 'slow');
//                    });
                });
            }//--

            //we need to close other open siblings
            var others = $(this).parents('div').siblings('div').children('.open');
            var other_others = $(this).siblings('.open').next();
            
            $(others).next().slideToggle('slow');
            $(other_others).slideToggle('slow');
      
            $(others).removeClass("open");
            $(this).siblings('.open').removeClass("open");

        });
        //---------------------------------------------------------------------
        // Reset Font Size
            var originalFontSize = $('html').css('font-size');
            
            $(".resetFont").click(function(){
                $('html').css('font-size', originalFontSize);
            });
        // Increase Font Size
          $(".increaseFont").click(function(){
                var currentFontSize = $('html').css('font-size');
                var currentFontSizeNum = parseFloat(currentFontSize, 10);
                var newFontSize = currentFontSizeNum*1.2;
                $('html').css('font-size', newFontSize);
                return false;
          });
        // Decrease Font Size
          $(".decreaseFont").click(function(){
            var currentFontSize = $('html').css('font-size');
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var newFontSize = currentFontSizeNum*0.8;
            $('html').css('font-size', newFontSize);
            return false;
          });

        //we want to load the values in dd.hover-box into #js-load-dest
        $('.js-load').hover(function(){
            var contents = $(this).find('dd.hover-box').html();
            $(this).parents('div').siblings('.js-load-dest').html(contents)
            $(this).find('dd.hover-box').hide();
            return false;
        });
    });
