var InkPortfolio = {
  show: function(button) {
    current_image = $$('.portfolio.current')[0]
    current_image.hide();
    current_image.className = current_image.className.split(" ").without("current").join(" ");

    new_image = $(button.id.match(/(.*)_link/)[1]);
    new_image.show();

    new_image_classes = new_image.className.split(" ");
    new_image_classes.push("current");
    new_image.className = new_image_classes.join(" ");
    
    $$('.image.button').each(function(other){
      if (other.down().src = "images/full_circle.gif") {
        other.down().src = "images/empty_circle.gif";
      }
    });
    button.down().src = "images/full_circle.gif";
  },

  next: function(button) {
    current = $$('.image.button').find(function(b){
      return b.down().src.match("full");
    });
    if (current && current.previous() && current.previous().className.split(" ").include("image")) {
      InkPortfolio.show(current.previous());
    } else {
      if (button.down().alt) {
        location.href=button.down().alt;
      }
    }
  },

  previous: function(button) {
    current = $$('.image.button').find(function(b){
      return b.down().src.match("full");
    });
    if (current && current.next() && current.next().className.split(" ").include("image")) {
      InkPortfolio.show(current.next());
    } else {
      if (button.down().alt) {
        location.href=button.down().alt;
      }
    }
  }
}
