$(document).ready(function() {

  // I'm on the outside
  hostname = window.location.hostname
  $("a[href^=http]")
    .not("a[href*='" + hostname + "']")
    .addClass('link external')
    .attr('target', '_blank');
    
  //Image preloading
  var screenshot_1 = $('<img />').attr('src', '/images/screenshot_1.jpg');
  var screenshot_2 = $('<img />').attr('src', '/images/screenshot_2.jpg');
  var screenshot_3 = $('<img />').attr('src', '/images/screenshot_3.jpg');
    
  // Image previews
  $('ul#thumbnails li#first').mouseenter(function() {
    $('#demonstration').append(screenshot_1);
  });
  $('ul#thumbnails li#second').mouseenter(function() {
    $('#demonstration').append(screenshot_2);
  });
  $('ul#thumbnails li#third').mouseenter(function() {
    $('#demonstration').append(screenshot_3);
  });
  $('ul#thumbnails li').mouseleave(function() {
    $('#demonstration').empty();
  });
});
