$(function(){
  Cufon.replace('#slogan, #banner, h1, h2, h3, h4, .gallery-item-name, .item-details', {fontFamily: 'Arial'});
  Cufon.replace('#featured-product h2', {fontFamily: 'Impact'});

  $("a.product-image").colorbox();
  $("a.project-image").colorbox();

  $("a[rel=project-images]").colorbox();

  $('#nav-products').hover(
    function(){
      var pos = $(this).offset();
      var height = $(this).height();
      $(this).addClass('hover');
      $('#nav-product-categories').css({left: pos.left, top: pos.top + height});
    },
    function(){
      $(this).removeClass('hover')
    }
  );

  $('#nav-product-categories li').hover(
    function(){
      $(this).css("background", "#2d4970");
      $(this).children('a').css("color", "#fff");
      //Cufon.replace('#nav-product-categories', {fontFamily: 'Arial'});
    },
    function(){
      $(this).css("background", "none");
      $(this).children('a').css("color", "#3a77b0");
    }
  );

  $('.gallery-item-image').hover(
    function(){
      $('.gallery-item-name[rel=' + $(this).attr('rel') + ']').addClass('hover');
    },
    function(){
      $('.gallery-item-name[rel=' + $(this).attr('rel') + ']').removeClass('hover');
    }
  );

  $('.gallery-item-name').hover(
    function(){
      $(this).addClass('hover');
    },
    function(){
      $(this).removeClass('hover');
    }
  );

  $('.gallery-item-name').click(function(){
    window.location.href = $(this).children('a').eq(0).attr('href');
  });

  $('.gallery-item-name a').hover(
    function(){
      $(this).parent().addClass('hover');
    },
    function(){
      $(this).parent().removeClass('hover');
    }
  );

  // Custom Safe Mail routine for handling email links with custom text.
  $("a.safemail").each(function(){
    $(this).attr('href', 'mailto:' + $(this).attr('href').replace(/ at /,"@").replace(/ dot /g,"."));
  });
});

