$(document).ready(function ()
{
  var ss_timeout;

  var tops = new Array(

     $('#pager li:eq(0)').position().top,
     $('#pager li:eq(1)').position().top,
     $('#pager li:eq(2)').position().top
  );

  $('#pager li').click(function ()
  {
    if ($(this).hasClass('activeSlide'))
      window.location = $(this).attr('href');
  });

  $('#slides ul').cycle(
  {
    fx: 'scrollHorz',
    timeout: 6000,
    speed: 1000,
    pauseOnPagerHover: 1,
    pause: 1,
    before: function (current, next)
    {
      var t = tops[$(next).index()];
      $('#arrow').animate({ top: t + 'px' }, 1000);
    },
    pager: '#pager ul',
    pagerAnchorBuilder: function (idx, slide)
    {
      // return selector string for existing anchor 
      return '#pager li:eq(' + idx + ')';
    }
  });

  $('#products li')
    .attr({ style: 'cursor: pointer;' })
    .click(function ()
    {
      window.location = $(this).find('a').attr('href');
    });
});
