var Headerslider = new Class({
  
  current: 0,
  container: null,
  outer: null,
  arrEl: null,
  offset: 0,
  
    init: function(){
      this.outer = $$('.slideheader_outer')[0];
      this.container = $$('.slideheader_inner')[0];
      this.container.set('tween',{'duration': 500});
      this.arrEl = this.container.getElements('.slideheader_item');
      this.container.setStyle('width',this.arrEl.length * 960);
      this.container.setStyles({left: this.offset});
      new Element('div',{'class':'headerslider_left'})
        .inject(this.outer)
        .addEvent('click',this.moveLeft.bind(this));
      new Element('div',{'class':'headerslider_right'})
        .inject(this.outer)
        .addEvent('click',this.moveRight.bind(this));
      /*
      this.nav = new Element('div',{'class':'headerslider_nav'})
        .inject(this.outer)
        .setStyles({'margin-left':this.arrEl.length*10,'width':this.arrEl.length*25});
      for(i = 0; i < this.arrEl.length; i+=2)
      {
        new Element('div',{'class':'contentslider_nav_item'})
          .inject(this.nav)
          .addEvent('click',this.moveTo.bind(this,i));
      }*/
      this.moveTo(0);
      //window.addEvent('domready',this.reSize.bind(this));
//      window.addEvent('resize',this.reSize.bind(this));
      this.timer = this.moveRight.periodical(10000,this);
      this.outer.addEvent('mouseenter', function () { clearInterval(this.timer) }.bind(this));
      this.outer.addEvent('mouseleave', function () { this.timer = this.moveRight.periodical(10000,this) }.bind(this));
    },
  
  moveLeft: function () {
    if(this.current <= 0)
    {
      this.current = this.arrEl.length;
    }
    this.moveTo(this.current-1);
  },
  
  moveRight: function () {
    if(this.current >= (this.arrEl.length-1)) 
    {
      this.current = -1;
      //return;
    }
    this.moveTo(this.current+1);
  },
  moveTo: function (i) {
    var nl = i*-960;
    this.currentPos = nl;
    this.container.tween('left',nl+this.offset);
    this.current = i;
//    $$('.contentslider_nav_item_current').removeClass('contentslider_nav_item_current');
//    this.nav.getChildren('.contentslider_nav_item')[i].addClass('contentslider_nav_item_current');
  },
  reSize: function () {
      this.offset = (window.getSize().x/2)-480;
      this.container.tween('left',this.currentPos+this.offset);
  }
  
});
