// Font replacement on banner area
Cufon.replace('#bannerArea h2');


$(function() {
  
  $('a[rel=external]').click(function () {
    window.open($(this).attr('href'));
    return false;
  });
  
  // Gallery thumbnail clicks
  $('#gallery li a').click(function() {
    
    var $source = $(this);
    
    $('div#main-gallery-image-container').empty();
    $('#main-gallery-image span').text($(this).attr('title'));
    
    var img = new Image();
    $(img).load(function () {
      $(this).hide();
      $('div#main-gallery-image-container')
        .empty()
        .append($(this))
        .css('cursor','pointer')
        .unbind('click')
        .click(function() {
          var $next = $source.parent().next('li');
          if($next.length > 0) {
            $next.find('a').click();
          } else {
            $('ul#gallery li:first a').click();
          }
        });
      $(this).fadeIn();
      $('html, body').animate({scrollTop: $(this).offset().top-100},500);
    }).attr('src', $(this).attr('href'));
    
    return false;
  });
  
  $('#gallery li a:first').click();
  
});

