$(document).ready(function() {
  
  if ($('#home-slideshow').length > 0)
  {
    currHomeImg = parseInt($('#home-slideshow img').attr('src').slice(-5,-4));
    setInterval('progressSlideshow()', 8000);
  }
  
  // open links with class 'popup' in new windows
  $('a.popup').click(function() {
    window.open($(this).attr('href'));
    return false;
  });
  
  
  // some jqueryified son of suckerfish stuff
  $('#navigation').find('LI').each(function() {
    $(this).hover(function() {
      $(this).addClass('sfhover');
    }, function() {
      $(this).removeClass('sfhover');
    });
  });  
  
  // Slide down a showable div when it's show link is clicked
  $('.divshow').click(function() {
    $(this).parent().next().show();
    $(this).hide()
    return false;  
  });

  
  $('.divhide').click(function() {
    $(this).parents('.showable').hide().prev().children('a.divshow').show();
    return false;
  });  
  
});

    
function progressSlideshow()
{
  currHomeImg++;
  if (currHomeImg == 5) currHomeImg = 1;
  src = '/images/homefade/' + currHomeImg + '.gif';
  slideshowImage = new Image();
  slideshowImage.src = src;
  slideshowImage.onload = function()
  {
    $('#home-slideshow').append('<img src="' + slideshowImage.src + '" style="display: none;" />');
    $('#home-slideshow img:last-child').fadeIn(8000, function(){ $('#home-slideshow img:first-child').remove(); });
  }
}