/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */

(function($) {
 $.fn.equalHeights = function(minHeight, maxHeight) {
 tallest = (minHeight) ? minHeight : 0;
 this.each(function() {
 if($(this).height() > tallest) {
 tallest = $(this).height();
 }
 });
 if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
 return this.each(function() {
 $(this).height(tallest); //.css("overflow","auto");
 });
 }
})(jQuery);

jQuery(function($){
 dls = $(".block-footer-nav dl");
 
 (function (dls,h) {
 if (dls.length > 7) {
 dls.eq(0).parent().parent().append('<div class="filter-cont"><dl class="secondary"></dl></div>');
 
 dls.slice(20).each(function(i){
 (function (el, w) {
 (function(d, el, v){
 el.find("dt").appendTo(w).click(function(){
 d.height("auto")
 $(this).hasClass('expanded') ? v.hide() : v.show();
 $(this).toggleClass('expanded');
 d.equalHeights(h);
 });
 v.appendTo(w).hide();
 })($(".block-footer-nav dl"), el, el.find("dd"));
 
 el.parent().remove();
 })($(this), $(".block-footer-nav dl.secondary"));
 });
 }
 
 dls.each(function(i){
 c = $(this).find("li");
 if (c.length > 8) {
 c.slice(7).addClass('extra');
 (function(el, set) {
 el.find("ol").append('<li class="more"><a href="#">+</a></li><li class="less"><a href="#">-</a></li>');
 el.find(".more a, .less a").click(function(){
 $(".block-footer-nav dl").height('auto');
 el.toggleClass("expanded");
 $(".block-footer-nav dl").equalHeights(h);
 return false;
 });
 })($(this));
 }
 });
 
 $(".block-footer-nav dl").equalHeights(h);
 })(dls,parseInt(dls.css('min-height')));
});



