$.log = function(m) { window.console && window.console.log && console.log(m); }
$.jsn = function(o) { return JSON.stringify(o, false, 2); }
$(document).ready(function() { 
  var projs = $('#projects,#journal');
  projs.imagesLoaded(function() { 
    projs.masonry({ 
        itemSelector: '.box'
      , columnWidth: 73
      , gutterWidth: 20
      , isAnimated: false
    });

    $('.slide').each(function(i,el) { 
      var $el = $(el)
        , w = $el.width()
        , h = $el.height();

      (w > h) 
       ? $el.addClass('landscape')
       : $el.addClass('portrait'); 

      if(w === h) 
        $el.removeClass('portrait')
           .addClass('square');
    });
    Related();
  });

  $('.dropdown a').toggle(function(e) { 
    $('#subnav').show();   
    $('#hed').animate({height:100}, 300);
    $(this).parent().addClass('active');
  }, function(e) { 
    $('#subnav').hide();   
    $('#hed').animate({height:70}, 300);
    $(this).parent().removeClass('active');
  });

  $('.slideshow').click(function(e) {
    var ss = Slide($('.slide'),$('#slideshow-template'));
    ss.show_first();
    e.preventDefault(); 
    return false;
  });

  $('.slide').find('img').click(function(e) {
    e.preventDefault(); 
    var index = $('.slide').index($(this).parents('.slide')); 
    $.log('img: '+index);
    var ss = Slide($('.slide'),$('#slideshow-template'));
    ss.show_img(index);
    return false;
  });

});

