function Wizzy(width, height, count, container, front, left, right)
{
  var self = this;

  this.width = width;
  this.height = height;
  this.count = count;

  this.container = document.getElementById(container);
  this.front = front;

  this.current = 0;
  this.forward = true;

  this.container.style.width = width;
  this.container.style.height = height;
  this.container.onmouseover = this.suspendTimer;
  this.container.onmouseout = this.startTimer;

  document.getElementById(front).style.width = width * count;
  document.getElementById(left).onclick = this.switchPrev;
  document.getElementById(right).onclick = this.switchNext;

  window.wizzy = this;

  self.startTimer();
}

Wizzy.prototype.switchTo = function(nextID)
{
  new Effect.Morph(this.front, { style: 'margin-left: '+(nextID*-this.width) + 'px', duration: 1.7 });
  this.current = nextID;
}

Wizzy.prototype.autoSwitch = function()
{
  var self = window.wizzy;

  if (self.current == 0)
  {
    self.forward = true;
  }
  if (self.current == (self.count - 1))
  {
    self.forward = false;
  }
  if (self.forward)
  {
    self.switchNext();
  }
  else
  {
    self.switchPrev();
  }
}

Wizzy.prototype.switchNext = function ()
{
  var self = window.wizzy;

  var nextWizzyID = self.current + 1;
  if (nextWizzyID > (self.count - 1))
  {
    nextWizzyID = self.count - 1;
  }
  self.switchTo(nextWizzyID);
}

Wizzy.prototype.switchPrev = function ()
{
  var self = window.wizzy;

  var nextWizzyID = self.current - 1;
  if (nextWizzyID < 0)
  {
    nextWizzyID = 0;
  }
  self.switchTo(nextWizzyID);
}

Wizzy.prototype.startTimer = function ()
{
  var self = window.wizzy;

  self.timer = setInterval(this.autoSwitch, 7000);
}

Wizzy.prototype.suspendTimer = function ()
{
  var self = window.wizzy;

  clearInterval(self.timer);
}

