$(document).ready(init_products);
var label_show = false;

var menu_height = 21;
var filter_box_height_expanded;
var filter_box_height_collapse;
function init_products(){
  
  init_category_list_menu();
  
  /* Use this to get crazy and fancy */
  // init_category_list_menu_animated();
  
  filter_box_height_expanded = $('#filter_box').height();
  $('.label_hidden').css('display','none');
  filter_box_height_collapse = $('#filter_box').height();
  $('#filter_box').css('overflow','hidden');
}

function init_category_list_menu(){
  $('#category_list li ul').css('display','none');
  $('#category_list li.current-parent-item ul').show();
  $('#category_list li.current-page-item ul').show();
}

function init_category_list_menu_animated(){
  $('#category_list>li').css({'overflow':'hidden', height:menu_height}) ;
  $('#category_list li.current-parent-item').css({height: $('#category_list li.current-parent-item').find('ul').height() + menu_height });
  $('#category_list li.current-page-item').css({height: $('#category_list li.current-page-item').find('ul').height() + menu_height });
  
  $('#category_list>li').bind('mouseover', function(){
    var sub = $(this).find('ul');
    $(this).animate( {height: sub.height() + menu_height}, {queue:false,duration:400});
  });
  $('#category_list>li').bind('mouseout', hide_subcat);
  $('#category_list>li.current-parent-item').unbind('mouseout',hide_subcat);
  $('#category_list>li.current-page-item').unbind('mouseout',hide_subcat);
}

function hide_subcat(){
  // $(this).find('ul').hide();
    $(this).animate( {height: menu_height}, {queue:false,duration:400});
    
}


function toogle_hidden_labels(obj){
  if(label_show){
    label_show = false;
    $(obj).html('Show More Filters');
    $('#filter_box').animate({height:filter_box_height_collapse},{duration:1000});
    $('.label_hidden').hide();

    
  }else{
    label_show = true;
    $(obj).html('Show Less Filters');
    $('.label_hidden').show();
    $('#filter_box').animate({height:filter_box_height_expanded},500,'', '');
    
  }
}