loader.jQuery({
  version  : '1.6.4',
  callback : function ($) {

    // Highlight current menu item (we do it immediately, and then again when the page loads - this means the items will be highlighted as soon as possible)
    var url = window.location.pathname;
    $('a[href$="' + url + '"]').each(function() { 
      $(this).parent('li').addClass('active');
    });
    $(function () {
      var url = window.location.pathname;
      $('a[href$="' + url + '"]').each(function() {
        $(this).parent('li').addClass('active');
      });
    });

    // Mini-cart updates
    $.plugin('snippets', function () {
      $(function () {
        $.snippets('', {
          after : function (data) {
            var total = data['snippets']['.cartTotalItems'] || 0;
            var cost  = data['snippets']['.cartTotalCost'] || '0.00';
            var currency = data['snippets']['.cartCurrency'] || '$';
            $('.myCartLink').attr('title', total + ' Items @ ' + currency + cost);
          }
        });
      });
    });

    // Dropdown menu controls (Superfish)
    $.plugin('superfish', function() {
      $(function(){
        $('ul.sf-menu').superfish({onInit:function(){$(this).show();}, autoArrows: false});
      });
    });
  }
});


$(document).ready(function(){ 

	$("#miniCart").tooltip({ effect: 'slide', position: 'bottom left', offset: [8, 40] });
		$('#hideCart').click(function() {
			$("div.tooltip").hide('fade');
			return false;
		});

	$("#pageCartLoad").load("/app/shop/shopfront/cart_view?minicart=1&random=" + Math.random()*99999);

});

