Site.Portfolio = function () {

  var _box,
      _image,
      _description,
      _status,
      _items,
      _currentItem;

  function _init(items) {
    _items = items;
    _box = $('div.image-slideshow');
    _image = _box.children('img.block');
    _description = _box.children('div.description');
    _status = _box.children('div.controls').children('p.status');
    _currentItem = 0;
    $.each(items, function() {
      Site.toolkit.cacheImage(this[0]);
    });
  }

  function _next() {
    _currentItem += 1;
    _update();
  }

  function _previous() {
    _currentItem -= 1;
    _update();
  }

  function _update() {
    if (_currentItem < 0) {
      _currentItem += _items.length;
    } else if(_currentItem >= _items.length) {
      _currentItem -= _items.length;
    }
    _image.attr('src', _items[_currentItem][0]);
    _description.html(_items[_currentItem][1]);
    _status.html('' + (_currentItem + 1) + ' of ' + _items.length);
  }

  return { init: _init, next: _next, previous: _previous };

}();
