function hidePanels() {
  $('panel_1').hide();
  $('panel_2').hide();
  $('panel_3').hide();
  $('panel_4').hide();
//  $('panel_5').hide();
}

function Slideshow() {
  var self;
  var hasClicked = false;

  this.start = function () {
    if(hasClicked == false) {
      self = this;
      i = 1;
      this.interval = setInterval(advance, 10000);
    }
  };

  this.click = function () {
    clearInterval(this.interval);
    self = undefined;
    hasClicked = true;
  }

  function advance() {
    if(i > 3/*5*/) {
      i = 0;
    }
    i++;
    hidePanels();
    id = 'panel_' + i.toString();
    $(id).show();
  }
  
  this.resume = function (pos) {
    if(hasClicked == false) {
      self = this;
      i = pos;
      this.interval = setInterval(advance, 10000);
    }
  }

  this.stop = function () {
     clearInterval(this.interval);
     self = undefined;
  };
}
