var slideObjects = function() {
  this.Img = $(".ix_objects .img img")[0];
  this.Link = $(".ix_objects .preface .goto")[0];
  this.Title = $(".ix_objects .preface .title")[0];
  this.Desc = $(".ix_objects .preface dd")[0];
  this.timeout = null;
  this.interval = 5000;
  this.goNext = function() {
    Objs.push(Objs.shift());
    this.setValues();
    return this;
  };
  this.goBack = function() {
    Objs.unshift(Objs.pop());
    this.setValues();
    return this;
  };
  this.Play = function() {
    var Self = this;
    this.timeout = setTimeout(function() {
      Self.goNext(); 
      Self.Play()
    }, Self.interval);
    return this;
  };
  this.setValues = function() {
    this.Img.src = Objs[0][0];
    this.Title.innerHTML = Objs[0][1];
    this.Link.href = Objs[0][2];
    this.Desc.innerHTML = Objs[0][3];
  }
  this.Pause = function() {
    clearTimeout(this.timeout);
    this.timeout = null;
    return this;
  }
}

$(document).ready(
  function() {
    var SO = new slideObjects();
    SO.Play();
    $($(".buttons .back")[0]).click(function() {
      SO.Pause().goBack();
      return false;
    });
    $($(".buttons .next")[0]).click(function() {
      SO.Pause().goNext();
      return false;
    });
    $($(".buttons .play")[0]).click(function() {
      if (!this.paused) {
        SO.Pause();
        $(this).removeClass("play").addClass("pause");
        this.paused = 1;
      }
      else {
        SO.Play();
        $(this).removeClass("pause").addClass("play");
        this.paused = 0;
      }
      return false;
    });
  }
);

