var campingTour = {
  initialize: function() {
    var start = arguments[0] || 1;
    this.counter    = start;
    this.counterMax = 7;
    this.killed     = false;
    this.camps      = [
      'annafriso','orisant','vierbannen','demule','pluimpot','linda','zonenzee'
    ];
    $$('.campingTrigger').each(function(el) {
      Event.observe(el, "mouseover",this.stop.bindAsEventListener(this));
      Event.observe(el, "mouseout",this.kontinue.bindAsEventListener(this));
    }.bind(this));
    
    this.run();
    this.loop();
  },
  
  loop: function () {
    this.tour = new PeriodicalExecuter(function() {
      this.run();
    }.bind(this),6);
  },
  
  run: function () {
    var el;
    if (el = $('detailvlak_' + this.counter)) {
      // detail vlak
      $$('.detailvlak').invoke('hide'); 
      el.show();
      
      // Pointer
      $$('.dot').each(function(el) {
        el.src = '/images/i_parel_rood.png';
      });
      $('dot_' + this.counter).src = '/images/i_parel_groen.png';
      
      // Link
       $$('.link').each(function(el,index) {
        el.src = '/images/b_' + el.title + '_u.jpg';
      }.bind(this));
      $('camping_' + this.counter).src = '/images/b_' + this.camps[this.counter-1] + '_d.jpg';
    }
    
    this.counterForward();
  },
  
  stop: function () {
    try {
      this.tour.stop();
      this.reset();
      
    }catch(error) {
    }
  },
  
  pause: function () {
    try {
      this.tour.stop();
      
    }catch(error) {
    }
  },
  
  kontinue: function () {
    if (this.killed) return;
    this.run();
    this.loop();
  },
  
  reset: function () {
    counter = 1;
  },
  
  counterBack: function () {
    this.ounter--;
    if (this.counter < 1) {
      this.counter = this.counterMax;
    }
  },
  
  counterForward: function () {
    this.counter++;
    
    if (this.counter > this.counterMax) {
      this.counter = 1;
    }
  },
  
  reset_elements: function () {
    // detail vlak
    $$('.detailvlak').invoke('hide'); 
    
    // Pointer
    $$('.dot').each(function(el) {
      el.src = '/images/i_parel_rood.png';
    });
    
    // Link
    $$('.link').each(function(el,index) {
      el.src = '/images/b_' + el.title + '_u.jpg';
    }.bind(this));
  },
  
  shutdown: function() {
    this.killed = true;
    this.reset_elements();
    this.stop();
  },
  
  nop: function() {
  
  }
}
