$(document).ready(function() {
  Nav.init()
  Fancy.init()
})

var Nav = {
  init: function() {
    $('#nav li').mouseover(Nav.over)
    $('#nav li').mouseout(Nav.out)
    $('#nav li').click(Nav.click)
    $('#nav li').each(Nav.activate)
    $('#logo').click(Nav.home)
  },
  activate: function() {
    if(location.pathname == $(this).children('a').attr('href')) {
      $(this).addClass('active')
    }
  },
  click: function() {
    window.location = $(this).children('a').attr('href')
  },
  over: function() {
    $(this).addClass('active')
  },
  out: function() {
    if(location.pathname != $(this).children('a').attr('href')) {
      $(this).removeClass('active')
    }
  },
  home: function() {
    window.location = '/'
  }
}

var Fancy = {
  init: function() {
    $(".technologies a").fancybox({
      transitionIn:  'elastic',
      transitionOut: 'elastic',
      titlePosition: 'inside',
      centerOnScroll: true,
      padding:        30
    })
  }
}