/**
 * Initialize the jQuery functions
 */ 
jQuery(function($)
{
  initSuperfish();
  initLinkhandling();
  initFancybox();
});

function initSuperfish()
{
  if (! $('#mainnav > ul').length ) return;
  
  /* HEI.at Dropdown Navigation */
  $("#mainnav > ul").superfish({
    hoverClass: "opened",
    autoArrows: false,
    delay: 500
  });
}

function initLinkhandling()
{
  // target blank for external links
  $("a[href^='http']").attr("target", "_blank");
  
  // exclude search results (they always begin with http)
  // $("dl.searchresults a[href^='http']").removeAttr("target");
}

function initFancybox ()
{
  if (! $('.imageSmall a').length ) return;
  
  $('.imageSmall a').fancybox({
    zoomOpacity: true,
    zoomSpeedIn: 300,
    zoomSpeedOut: 300,
    zoomSpeedChange: 200,
    overlayShow: true,
    overlayOpacity: 0.6
  });
}
