/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);;
function testMediaQuery(str) {
  var style = document.createElement('style');
  var div = document.createElement('div');
  var id = '';
  do {
    id = ('x'+Math.random()).replace(/\./,'');
  } while ( document.getElementById(id) );
  div.id = id;
  style.innerText = '@media ' + str + ' { #'+id+' { display:none !important; } }';
  document.documentElement.appendChild(style);
  document.documentElement.appendChild(div);
  var ret = getComputedStyle(div,null).getPropertyValue('display') == 'none';
  style.parentNode.removeChild(style);
  div.parentNode.removeChild(div);
  return ret;
}

(function($) {

var main_theme_basket_popout_timer = null;

Drupal.behaviors.main_theme = {
  attach: function() {
    if (typeof(_gaq) != 'undefined') {
      $('#block-views-rich-banners-block-1 .views-field-field-target-url a').once('rich-banner-analytics', function() {
        $(this).click(function(event) {
          _gaq.push(['_trackEvent', 'Banners', 'Click', $(this).attr('title')]);
        });
      });

      $('#block-megamenu-products-mega-menu .block-views-taxonomy-blocks .field-content a').once('customer-favourites-analytics', function() {
        $(this).click(function(event) {
          _gaq.push(['_trackEvent', 'CustomerFavourites', 'Click', $(this).attr('title')]);
        });
      });
    }

    $('#block-block-6').once('basket-popup', function() {
      $(this).find('.shopping-basket').click(function(event) {
        event.preventDefault();

        if (!$(this).hasClass('shopping-basket-visible') && typeof(_gaq) != 'undefined') {
          _gaq.push(['_trackEvent', 'ShoppingBasketDropdown', 'Click']);
        }

        $(this).toggleClass('shopping-basket-visible');
        $('#block-commerce-cart-cart').slideToggle();
      })
    });

    $('#block-block-6, #block-commerce-cart-cart').hover(function() {
      if (main_theme_basket_popout_timer != null) {
        clearTimeout(main_theme_basket_popout_timer);
        main_theme_basket_popout_timer = null;
      }
    }, function() {
      main_theme_basket_popout_timer = setTimeout(function() {
        $('#block-block-6 .shopping-basket').removeClass('shopping-basket-visible');
        $('#block-commerce-cart-cart').slideUp();
        main_theme_basket_popout_timer = null;
      }, 7000);
    });

    $('#block-webform-client-block-413 :input[name="submitted[email]"]').once(function() {
      $(this).focus(function() {
        if ($(this).val() == 'enter your email address') {
          $(this).val('');
        }
      }).blur(function() {
        if ($(this).val() == '') {
          $(this).val('enter your email address');
        }
      }).trigger('blur');
    });
  }
}

})(jQuery);;
(function($) {

Drupal.behaviors.product_hover = {
  attach: function() {
    product_hover_i = 1;
    $('.product-listing-wrapper').once('product-hover', function() {
      // Force the height of the parent <div>
      var $parent = $(this).parent();

      // Hover effect - this only triggers when the cursor stops...
      $(this).hoverIntent(function(event) {
        //event.preventDefault();

        // Fade in the elements that have the product-hover class
        $(this).find('.product-hover, .quick-view').fadeIn(150);

        // Add the class to set the wrapper as being hovered
        $(this).addClass('product-hover-wrapper-active');
        $parent.css('zIndex', 100);
      }, function(event) {
        //event.preventDefault();

        // Fade out the elements that have the product-hover class
        $(this).find('.product-hover, .quick-view').hide();

        // Add the class to set the wrapper as being hovered
        $(this).removeClass('product-hover-wrapper-active');
        $parent.css('zIndex', 0);
      });

      // Add the 'quick view' button in
      var url = $(this).find('.views-field-title a').attr('href');
      var text = $(this).find('.views-field-title a').text();
      var get_q = Drupal.settings.q;

      /*
      if ($(this).find('.cpl-postcode-required').size() == 0) {
        var $quickview = $('<a rel="shadowbox[width=900;height=540;product' + (product_hover_i++) + ']" class="quick-view" href="' + url + '?viewmode=quickview&original_page=' + get_q + '" title="' + text + '"><img src="' + Drupal.settings.basePath + Drupal.settings.themePath + '/images/quick-view.png" alt="Quick View" /></a>');
        $(this).append($quickview);
      }
      */
    });
  }
}

})(jQuery);
;

