var options = {}
var wip = false

function moveLeft () {
  if( !wip ) {
    var ul = $('.content ul.items');
    var pxPosition = to_i(ul.css('left'));
    
    if( pxPosition / options.liWidth > -options.ulItems+1 ) {
      wip = true;
      $('.content ul.items').animate( {left: pxPosition - options.liWidth}, {complete: function() {wip=false;}} );
    }
  }
}

function moveRight () {
  if( !wip ) {
    var ul = $('.content ul.items');
    var pxPosition = to_i(ul.css('left'));
    if( pxPosition / options.liWidth < 0 ) {
      wip = true;
      $('.content ul.items').animate( {left: pxPosition + options.liWidth}, {complete: function() {wip=false;}} );
    }
  }
}

function to_i (val) {
  return parseInt(val.replace(/px/, ''));
}

$(function(){
  options = {
    liWidth: $('.content ul.items li').width() + to_i($('.content ul.items li').css('margin-right')),
    ulItems: $('.content ul.items li').size()
  }
  
  $('.scroll-buttons .previous').click( moveLeft );
  $('.scroll-buttons .next').click( moveRight );
})