
$(document).ready(function(){

  // resize thumbnails
 /*jQuery.fn.resizeImgByArea = function(avgDimension){
        var oldW = $(this).width();
      var oldH = $(this).height();
      var RatiO = new Number(oldW/oldH);
      var newH = new Number(Math.round(Math.sqrt(avgDimension/RatiO)));
      var newW = new Number (Math.round(newH * RatiO));
      $(this).css({
          width: newW + 'px',
          height: newH + 'px'
          });
  }*/

  //$("#photos img").imagesLoaded(function(images) { images.each(function() { $(this).resizeImgByArea(20000)}) })
  
  // jquery masonry
  var $container = $('#thumb-container');
  $container.imagesLoaded(function(){
    $container.masonry({
      itemSelector : '.thumb',
      columnWidth : 200
    });
  });

  //press release accordion
  $('#press').accordion({
    oneOpenedItem: true,
    speed: 600
  });

  //append tooltip arrow
  $('.tooltip').append('<span class="arrow"></span>');
  //tooltips
  $('.thumb a img').tooltip({
    relative: true,
    position: 'top center', 
    offset: [-6, 0], 
    delay: 200, 
    effect: 'slide'
  }).dynamic({ bottom: { direction: 'down' } });
 
 
  //$("#eyes").click(function(){
    //$("#audio-player")[0].play();
    //$("#message").text("Music started");
  //})

  //play music
  $("#eyes").toggle(function(){
    $("#audio-player")[0].play();
  }, function () {
    $("#audio-player")[0].pause();
  });

  //list and grid view
  $("#list-view").click(function(){
    if($('#client-list').hasClass('list')) {
    }
    else {
     $('#client-list').addClass('list'); 
    }
  });

  $("#grid-view").click(function(){
    if($('#client-list').hasClass('list')) {
       $('#client-list').removeClass('list'); 
    }
    else {
    }
  });

  //Hide (Collapse) the contact list on load
  $('#contact-toggle').toggle(function(){
      $('#contact-list').animate({right: "0"}, 220);
      $('#contact-list').addClass("on");
   },
   function(){
      $('#contact-list').animate({right: "-265px"}, 220);
      $('#contact-list').removeClass("on");
   });
   
   $("#contact-toggle").click(function () {
    $(this).text($(this).text() == 'Contact' ? 'Hide' : 'Contact');
    return false; 
   });
   
     $("#contact-toggle").toggle(function(){
    $(this).addClass("active");
    }, function () {
    $(this).removeClass("active");
  });

   //expand bio
   $('#bio').expander({
    slicePoint: 1200,
   userCollapse: false,
    expandText: '[expand]',
    expandPrefix: '... ',
    preserveWords: true
  });


  //hide images on small displays
  function checkWindowSize() {  
    if ( $(window).width() < 590) { 
        $('#client-list').addClass('list');  
    }
  }
  checkWindowSize()

});









