// JavaScript Document
$(document).ready(function() {
	
  $('.mainNav a')
	  .css( {backgroundPosition: "0 0"} )
	  .mouseover(function(){
		  $(this).stop().animate(
			  {backgroundPosition:"(0 -50px)"}, 
			  {duration:500})
		  })
	  .mouseout(function(){
		  $(this).stop().animate(
			  {backgroundPosition:"(0 0)"}, 
			  {duration:500})
		  })
		  
		  
	$('#photos_inner').click(function(){
	  var scrollAmount = $(this).width() - $(this).parent().width();
    var currentPos = Math.abs(parseInt($(this).css('left')));
    var remainingScroll = scrollAmount - currentPos;
  
    // Scroll half-a-screen by default
    var nextScroll = Math.floor($(this).parent().width() / 2);
  
    // But if there isn’t a FULL scroll left, do only the remaining amount.
    if(remainingScroll < nextScroll) {
      nextScroll = remainingScroll;
    }
   
    if(currentPos < scrollAmount) {
      // Scroll left
      $(this).animate({'left':'-=' + nextScroll}, 'slow');
    }
    else{
      // Scroll right
      $(this).animate({'left':'0'}, 'fast');
    }
  });
	
});
