$(document).ready( function () {

  function show_content () {
    content.slideDown('normal');
  }

  function load_content (source) {
    content.load(source, function () {
     show_content(); 
    });
  }

  function button_handler (button, source) {
    $(button).live('click', function () {
      content.slideUp('slow', function () {
        load_content(source);
      });
    return false;
    });
  }

  $("a.fancy").fancybox({
    titlePosition: 'inside'
  });

  // need to use .live() because the flash links a re on a dynamically loaded site
  $("#minesweeper_clone a").live('click', function() {
          $.fancybox({
              'padding': 0,
              'autoScale': false,
              'transitionIn': 'none',
              'transitionOut': 'none',
              'title': this.title,
              'width': 1200,
              'height': 700,
              'href': this.href,
              'type': 'swf',
              'swf': {
                  'wmode': 'opaque',
                  'allowfullscreen': 'true'
              }
          });
          return false;
      });

  $("#redcity a").live('click', function() {
          $.fancybox({
              'padding': 0,
              'autoScale': false,
              'transitionIn': 'none',
              'transitionOut': 'none',
              'title': this.title,
              'width': 640,
              'height': 480,
              'href': this.href,
              'type': 'swf',
              'swf': {
                  'wmode': 'opaque',
                  'allowfullscreen': 'true'
              }
          });
          return false;
      });

  $("#darknodemag a").live('click', function() {
          $.fancybox({
              'padding': 0,
              'autoScale': false,
              'transitionIn': 'none',
              'transitionOut': 'none',
              'title': this.title,
              'width': 553,
              'height': 650,
              'href': this.href,
              'type': 'swf',
              'swf': {
                  'wmode': 'opaque',
                  'allowfullscreen': 'true'
              }
          });
          return false;
      });

  $("#boa a").live('click', function() {
          $.fancybox({
              'padding': 0,
              'autoScale': false,
              'transitionIn': 'none',
              'transitionOut': 'none',
              'title': this.title,
              'width': 800,
              'height': 600,
              'href': this.href,
              'type': 'swf',
              'swf': {
                  'wmode': 'opaque',
                  'allowfullscreen': 'true'
              }
          });
          return false;
      });

  var content = $('#content');
  content.hide();
  content.slideDown(1000);
  $("#header img").hide();
  $("#header img").fadeIn(2000);

  button_handler('a#video_games', 'video_games.html #index');
  button_handler('a#websites', 'websites.html #index');
  button_handler('a#homepage_link', 'index.html #homepage');
  button_handler('a#wickie_link', 'video_games.html #wickie');
  button_handler('a#winnetou_link', 'video_games.html #winnetou');
  button_handler('a#bloodymines_link', 'video_games.html #bloodymines');
  button_handler('a#dominionshare_link', 'websites.html #dominionshare');
  button_handler('a#bam_link', 'websites.html #bam');
  button_handler('a#gallery_link', 'websites.html #gallery');
  button_handler('a#onerbrek_link', 'websites.html #onerbrek');
  button_handler('a#pixelart_link', 'skills.html #pixelart');
  button_handler('a#ruby_link', 'skills.html #ruby');
  button_handler('a#painting_link', 'skills.html #painting');
  button_handler('a#drawing_link', 'skills.html #drawing');
  button_handler('a#flash_link', 'skills.html #flash');
});

