var cycling =
{
  items: null,
  init: function()
  {
    var self = this;

    // Initialise the cycle
    cycling.items = $('#spotlight ul')
      .cycle({
        next: $('#spotlight .next'),
        prev: $('#spotlight .prev'),
        fit: 1,
        fx: 'scrollHorz',
        pause: 0,
        speed: 1000,
        timeout: 7000,
        fastOnEvent: 0,
        pauseOnPagerHover: 1,
        activePagerClass: 'active',
        pager: $('#spotlight .pager'),
        cleartype: 0,
        onPrevNextEvent: function()
        {
          cycling.pauseVideo();
        },
        onPagerEvent: function()
        {
          cycling.pauseVideo();
        },
        before: function(curr, next, opts)
        {
          cycling.pauseVideo();
          $('#spotlight li').removeClass('current');
          $(next).addClass('current');
        },
        after: function()
        {
          $('#spotlight .video-controls .play-pause')
            .removeClass('playing')
            .addClass('paused');
        }
      });

    $('#spotlight .next, #spotlight .prev, #spotlight .pager a').bind('click', function()
    {
      cycling.items.cycle('resume');
    });

  },
  pauseVideo: function()
  {
    if($.browser.msie)
    {
      if($('#spotlight .video-controls .play-pause').hasClass('playing'))
      {
        $('#spotlight li.current object')
          .trigger('pause');
      }
    }
  }
}

var ytplayer =
{
  init: function()
  {
    $('.video-link').ytchromeless({
      videoWidth: '547',
      videoHeight: '307'
    });
  }
}


$(function()
{
  $('body').addClass('js');
  $('a[rel*=external]').attr('target', '_blank');

  ytplayer.init();
  cycling.init();
  $('.highlight-list, #company-list, .list')
    .not('.fhhNoHover')
    .find('li')
    .fhHover();
});
