$(function () {

  $('#slogan').fadeIn('slow');
  
  $('#navbar span').hover(
      function() { $(this).addClass('hover') },
      function() { $(this).removeClass('hover') }
  );

  $('#nav_home').addClass('active');

  $('#navbar span').add('div.thumb').click( function() {
    Navigation.go(this);
  });


  var Navigation = {
    pages: {
      home: $('#aboutme'),
      bio: $('#bio'),
      projects: $('#projects'),
      blog: 'http://blog.demetriusnunes.com/',
      photo: 'http://flickr.com/photos/26726938@N00/'
    },

    go: function(target) {
      var id = target.id.split("_")[1];
      var targetobj = Navigation.pages[id];
      if (typeof targetobj == "string") {
        window.location = targetobj;
      }
      else {
        $('#navbar span').removeClass('active');
        $('#nav_' + id).addClass('active');
        $($('#content div')[0]).remove().hide();
        targetobj.hide().appendTo('#content').fadeIn();
      }
    }  
  }

  var Identity = {
    "I graduated": [ 'puc-rio.jpg', 'www.puc-rio.br' ],
    "I work": [ 'tecgraf.jpg', 'www.tecgraf.puc-rio.br' ],
    "I am": [ 'scrum_master.jpg', 'www.scrumalliance.org' ],

    "I do": [ 'gray_ruby.jpg', 'www.ruby-lang.org' ],
    "I use": [ 'product-15in.jpg', 'www.apple.com/macbookpro' ],
    "I drive": [ 'off_800_06.jpg', 'www.peugeot.com/produits/modeles/206/en/default.htm' ],

    "I play": [ 'istockphoto_3659327_close_up_tennis_ball.jpg', 'en.wikipedia.org/wiki/Tennis' ],
    "I am from": [ 'istockphoto_3516626_brazilian_flag.jpg', 'en.wikipedia.org/wiki/Brazil' ],
    "I live": [ 'istockphoto_1932847_christ_redeemer_in_rio_de_janeiro.jpg', 'en.wikipedia.org/wiki/Rio_De_Janeiro' ]
  };
  
  var i = 0;
  $.each(Identity, function(item, params) {
    i++;
    $('#identity').append(
      "<div class='thumb'>" +
        "<p>" + item + "</p>" +
        "<a href='http://" + params[1] + "' target='_blank'>" +
          "<img src='images/" + params[0] + "' />" +
        "</a>" +
      "</div>" + (i % 3 == 0 ? '<div style="clear:both;"/>' : '')
      );
  });

  $('div.thumb').hover(
    function() { $(this).fadeTo('slow', 0.5) },
    function() { $(this).fadeTo('slow', 1) }
  );
  
});
