jQuery(document).ready(function($) {
  
  var $my_background_color;
  
  $('#slider').nivoSlider({effect:'fade',controlNav:true,directionNavHide:true,animSpeed:1000});
    
  $('#menu-item-884 a').click(function(e) {
    $('.range').slideToggle();
    $(this).toggleClass("minus");
    e.preventDefault();
  });	
  
  
  $('.store-selector').change(function() {
    document.location.href=$(this).val();
  });
  
  $("#menu-item-884 a").hover(
    function () {
      $(this).addClass("hover");
    },
    function () {
      if ( !$('#menu-item-884 a').hasClass('minus') ) {
        $(this).removeClass("hover");
      }
    }
  );
  
  $(".page-id-12 .entry-content a img").hover(
    function () {
      $(this).stop().animate({
       opacity: 0.8
      }, 300 );
    },
    function () {
      $(this).stop().animate({
       opacity: 1
      }, 300 );
    }
  );
  
  $(".product").not('.the_category').hover(
    function () {
      $my_background_color = $(this).css('backgroundColor');
      $(this).stop().animate({ backgroundColor: "#ffffff" }, 500 );
    },
    function () {
      $(this).stop().animate({ backgroundColor: $my_background_color }, 500 );
    }
  );
  
  $(".the_anchor a").hover(
    function () {
      $(this).stop().animate({ borderColor: "#72a9c7" }, 500 );
    },
    function () {
      $(this).stop().animate({ borderColor: "#f1eee9" }, 500 );
    }
  );
  
  $("#footer .range .brand_logo_small_container a").hover(
    function () {
      $(this).stop().animate({ borderColor: "#72a9c7", backgroundColor: "#ffffff" }, 500 );
    },
    function () {
      $(this).stop().animate({ borderColor: "#ffffff", backgroundColor: "#f1eee9" }, 500 );
    }
  );  
  
  
  
  // loop through ul and hide them if cookie is set to true
  $('.categories ul').each(function(index) {
    my_class = $(this).attr('class');
    
    if ( $.getCookie(my_class) == true ) {
      $('ul.'+my_class).hide();
      $('h4#'+my_class).removeClass('expanded');
    }
 
  });

  $('.categories h4').click(function(e) {
    $(this).toggleClass("expanded");
    var my_class = $(this).attr('id');
    $('ul.'+my_class).slideToggle();
    
    if ( $.getCookie(my_class) == true ) {
      $.setCookie(my_class, false);
    }
    else {
      $.setCookie(my_class, true);
    }
        
    e.preventDefault();
  });	

});

