jQuery(document).ready(function() {
  var body_height = jQuery(document).height();
  jQuery('#nav').css('height',(body_height - 130)+'px');
});

function cycle_images(duration, limit, folder) {

  // Get the current ID
  var current_num = parseInt(jQuery('#cycle img').attr('alt'));
  next_num = ((current_num + 1) > limit) ? 1 : current_num + 1;

  // Fade the current image out
  jQuery('#cycle img').fadeOut('slow', function() {
    // Fade in the current image
    jQuery('#cycle img').attr('src', '/images/' + folder + '_cycle/image_' + next_num + '.jpg');
    jQuery('#cycle img').attr('alt', next_num);

    // Fade the current image in
    jQuery('#cycle img').fadeIn('slow', function() {
      setTimeout('cycle_images(' + duration + ',' + limit + ',"' + folder + '")', duration);
    });
  });

  // Preload the next image
  preload_num = ((next_num + 1) > limit) ? 1 : next_num + 1;
  jQuery('.preload').html('<img src="/images/' + folder + '_cycle/image_' + preload_num + '.jpg" alt="preload" height="1px" width="1px" />');

}