//@REQUIRE source/js/xthumb/jquery.xthumb.js

$(function() {

  if (!window.location.hash) {
    var scrollTop = $('#pcont').position()['top'];
    $('html,body').animate({scrollTop:scrollTop}, 500);
  }
        

  var $layout = $('.layout-photos'), w = $layout.width(), pos = 0, speed = 0;
  var content_w = $('.pht-contents').width();
  
  $(window).resize(function() {
    w = $layout.width();
  });
  

  
  $layout.mousemove(function(e) {
  
    pos = (e.pageX * 100) / w;
    if (pos > 40 && pos < 60) speed = 0;
    else if (pos <= 40) speed = (40 - pos) * -1;
    else if (pos >=60) speed = 40 - (100 - pos);

  
  }).mouseleave(function() {
    speed = 0;
  });
  

  setInterval(function() {
  
    if (speed == 0) return;
    var l = parseInt($layout.scrollLeft()) + (speed*0.6);
    $layout.scrollLeft(l);
  
  }, 10);

  $('body').xthumb({
    'class':'pht-a'
  });

});
