/***************************************************
 jQuery supersubs
***************************************************/
$(document).ready(function() {
  if (($("ul.sf-menu") != null) && ($("ul.sf-menu").supersubs != null))
  {
    $("ul.sf-menu").supersubs({
      minWidth: 12,   // minimum width of sub-menus in em units
      maxWidth: 27,   // maximum width of sub-menus in em units
      extraWidth: 1   // extra width can ensure lines don't sometimes turn over
                      // due to slight rounding differences and font-family
    }).superfish();   // call supersubs first, then superfish, so that subs are
                      // not display:none when measuring. Call before initialising
                      // containing tabs for same reason.
  }
});

/***************************************************
 jQuery Tools tabs
***************************************************/
function displaySingleImage(images) {
  $(function() {
    $('.' + images).children('div').css('display', 'block');
  });
}
function setupImages(images, thumbnails, transitionEffect, intervalTime, playOnPageLoad, autopauseOnHover, rotateAtEnd) {
  $(function() {
    $("." + thumbnails).tabs("." + images + " > div", {
      effect: transitionEffect,
      fadeOutSpeed: 'slow',
      rotate: rotateAtEnd
    }).slideshow({ autopause: autopauseOnHover, autoplay: playOnPageLoad, interval: intervalTime });
  });
}

/***************************************************
 jQuery Tools overlay
***************************************************/
function setupOverlay()
{
  $(function() {
    $('a[rel]').overlay({
      closeOnClick: false,
      effect: ( $.browser.mozilla ? 'default' : 'apple' ), /* hack for FF bug with 'apple' effect in tools 1.2.5 */
      mask: {
        color: '#E5E5E5',
        loadSpeed: 200,
        opacity: 0.9
      },
      onLoad: function() {
        var wrap = this.getOverlay().find('.contentWrap');
        var link = this.getTrigger().attr('href');
        if (link.indexOf('http') < 0)
        {
            wrap.load(link);
        }
        else
        {
            var iFrame = $('<iframe id="innerFrame" frameborder="0"></iframe>');
            $(iFrame).attr({ src: link, style: 'border: none; height: 562px; width: 100%;' });
            wrap.html(iFrame);
        }
      },
      onBeforeClose: function() {
        var wrap = this.getOverlay().find('.contentWrap');
        wrap.html('');
      }
    });
  });
}

/***************************************************
 SiteCatalyst-related functions
***************************************************/
function trackEvent(eventId) {
  // 20100208 FKC: Assumes that the page calling this method has SiteCatalyst embedded in it.
  if ((eventId != null) && (eventId != ''))
  {
    if (s != null) {
      if (s.events != null)
        s.events = s.events + "," + eventId;
      else
        s.events = eventId;
      s.t();
    }
  }
}

