$(function() {
  $('#studio .images div').hover(
    function() { $('.overlay', this).show(); },
    function() { $('.overlay', this).hide(); });
  
  $('a[rel=popup]').fancybox({
    padding: 0,
    scrolling: 'no',
    overlayOpacity: 0.8,
    overlayColor: '#9ccb3d',
    titleShow: false
  });
  
  if (typeof window.orientation !== 'undefined') {
    $('#studio .images div')
      .bind('touchstart', function() { $('.overlay', this).show(); })
      .bind('touchend', function() { $('.overlay', this).hide(); });
  }
  
  if (typeof window.orientation !== 'undefined' && navigator.platform == "iPad") {
    $('#header-wrapper').css('left', '25px');
    
    function setHeight() {
    	document.getElementById('page').style.height = window.innerHeight + 'px';
    }
    
    setHeight();
    $(window).bind('orientationchange', setHeight);
    
    var scroller = new iScroll('content');
    
    $('a').click(function(e) {
      var href = $(this).attr('href');
      
      if (href[0] == '#') {
        scroller.scrollToElement(href);
        return false;
      }
    });
  } else {
    $.localScroll({
      hash: true,
      easing: 'easeOutExpo',
      filter: ':not(a[rel=popup])'
    });
  }
});

