


function Marquee(box,content,speed,dirc,coefOverSpeed){
  //ini les variables
  this.box=$(box);
  this.content=$(content);
  this.speed=speed || 1;
  this.dirc=dirc || 'top';
  this.coefDirc=1;
  this.coefOverSpeed=coefOverSpeed || 3;
  this.inverseDirc=(this.dirc=='bottom' || this.dirc=='right');
  var horizontalDirc=(this.dirc=='bottom' || this.dirc=='top');

  //on repositionne les élements + cache les scrolls
  this.box.style.overflow='hidden';
  this.box.style.position='relative';//ie7 bug
  this.content.style.position='relative';

  //calcule la dimension du conteneur  + la dimention du contenue
  var boxDim=this.box['client'+(horizontalDirc?'Height':'Width')];
  var contentDim=this.content['offset'+(horizontalDirc?'Height':'Width')];

  //on retient la moitier de la dim , pour le mouse over
  this.middleDim=boxDim/2;

  //on definit las position max et de départ
  this.maxDim=this.inverseDirc?-boxDim:-contentDim;
  this.startStep=this.inverseDirc?contentDim:boxDim;
  this.currentStep=this.startStep;

  //ajoutes les evenemnts
  this.eventOver=this.onMouseover.bindAsEventListener(this);
  Event.observe(this.box,'mouseover',this.eventOver);

  this.eventOut=this.onMouseout.bindAsEventListener(this);
  Event.observe(this.box,'mouseout',this.eventOut);

  this.interval=setInterval(this.interval.bind(this),35);

  this.eventUnload=this.unload.bindAsEventListener(this);
  Event.observe(window,'unload',this.eventUnload.bind(this));
}
Marquee.prototype={
   onMouseout : function(e){
      Event.stopObserving(this.box,'mousemove',this.eventMouseMove);
      this.coefDirc=1;
   },
   onMouseover : function(e){
       this.mouseMove(e);
       this.eventMouseMove=this.mouseMove.bindAsEventListener(this);
       Event.observe(this.box,'mousemove',this.eventMouseMove);
      this.coefDirc=0;
   },
   interval : function(){
     var acc=this.speed*this.coefDirc;
     $(this.content).style[this.dirc]=this.currentStep-acc+'px';
     this.currentStep-=acc;
     if(this.currentStep>this.startStep)
        this.currentStep=this.maxDim;
     if(this.inverseDirc){
        if(this.currentStep<this.maxDim)
           this.currentStep=this.startStep;
     }else{
        if(this.currentStep<this.maxDim)
           this.currentStep=this.startStep;
     }
   },
   mouseMove:function(e){
      ;
   },
   unload : function(){
      clearInterval(this.interval);
      Event.stopObserving(this.box,'mouseover',this.eventOver);
      Event.stopObserving(this.box,'mouseout',this.eventOut);
      Event.stopObserving(window,'unload',this.eventUnload.bind(this));
   }
}


