var sliderV_pat = new Class({
/*
 *METHOD
 */
options : {
//divcontainer du dl
container : null ,
//dl
cible : null ,
//stock les parametres du container
cooC : null ,
//stock les parametres du dl
coo : null ,
//li
childrenli : null ,
//nb de li
nb : 0 ,
//taille des li
liSize : null ,
//position de la sourie
mousePos : null ,
//bt bas
btBottom : null ,
//bt Haut
btTop : null,
//coordonnŽ des bt
btcc : null,
//timer pour le mouv auto
timer : '6000',
//boolean pour arreter le mouveauto
setMove : true ,
//nb de click
click : 0 ,
//stock un objet interval
periode : '5000' 
},
/*
 *CONSTRUCTEUR
 */
initialize : function( o , option)
{

    this.options = $merge( this.options , option);
    
    //div avant de ul
    this.options.container = o;
    this.options.container.setStyle('overflow' , 'hidden' );
    
    //recupere le premier ul
    this.options.cible = this.options.container.getFirst('ul');
    
    //je met le ul en absolute et a 0
    this.options.cible.setStyles({
    'position' : 'absolute' ,
    'top' : '0px' ,
    'left' : '0px'
    });
    
    //coordonne du container
    this.options.cooC = this.options.container.getCoordinates();
    //coordonne du ul
    this.options.coo = this.options.cible.getCoordinates();
    
     //nb de dt
    this.options.childrenli = this.options.cible.getChildren('li');
   
    
    //recupere les tailles
    this.options.liSize = this.options.cible.getFirst('li').getCoordinates();
    
    
    //nb d'enfants
    this.options.nb = this.options.childrenli.length; 
    
    //closure
    var p = this;
    
    
    this.options.btBottom = new Element('a' , {
    'html' : '&#160;' ,
    'href' : '#' ,
    'id' : 'btBottom',
    'events' : {
    'click' : function(evt)
    {
        var t = p;
        p.down(evt);
        return false;
    }
    
    }
    });
    
    this.options.btTop = new Element('a' , {
    'html' : '&#160;' ,
    'href' : '#' ,
    'id' : 'btTop' ,
    'events' : {
    'click' : function(evt)
    {
        var t = p;
        p.up(evt);
        return false;
    }
    
    }
    });
    
    
    this.options.btBottom.inject(this.options.container);
    this.options.btTop.inject(this.options.container);
    
    
    
    //detruit le loader
    if($('loader') != null)
    {
        $('loader').fade('out');
        //$('loader').destroy().delay('1500');
    }
    
    
    //detection du mouvement de la sourie pour montrer ou cacher les bts
    this.options.container.addEvent('mousemove' , function(evt){
    
    var t = p;
    
    t.options.mousePos = evt ;
    
    t.detectMouse(t); 
    
    });
    
        
    //recup des info sur le bt
    this.options.btcc = this.options.btTop.getCoordinates();
    
    //j'appelle une premiere fois la fonction move
    this.moveBt(this.options.cooC.height/2);
    
    //je lance le mouv auto
    this.autoMove.periodical(this.options.timer , this );  
},
/*
 * Mouvement des dd et dt
 */
move : function( n )
{
   
   //si je suis au max je passe a 0
   if( this.options.click >= (this.options.nb-1) && n != '-1')
   {
       this.options.click = 0;
   }
   else
   {
       
       this.options.click += n ;
       
   }
   
   //j'effectue le mouvement seulement si je depasse pas 0 ou le max
   if( this.options.click < (this.options.nb-1) || this.options.click > 0)
   {
   //je deplace le ul  
      this.options.cible.tween(
    'top', -(this.options.liSize.height * this.options.click  )
     );
   }
      
},
/* 
 * DETECTION DE LA SOURIE
 */
detectMouse : function(p)
{
//recupere le position de la sourie
var posMouse = (p.options.mousePos.page.y - p.options.coo.top);
p.moveBt( posMouse );
},

/*
 *mouvement auto
 */
autoMove : function()
{   

    if( this.options.setMove )
    {
        
    //appel de la fonction move
    this.move( 1 );
     
    }
    

},
/*
 * arrete un moment le defilement auto si on click, reprend tout seul
 */
stopAuto : function()
{
    
    if(this.options.periode != null)
    {   
        $clear(this.options.periode);
    }
    
     this.options.periode = this.setTrueMove.delay(this.options.periode , this );
     this.options.setMove = false;

},
/*
 * appellŽ par la fontion  ci dessus
 */
setTrueMove : function()
{

    this.options.setMove = true;

},
/*
 * Affiche ou non les bt en function de la position de la sourie
 */
moveBt : function( m ){
    
    
    if( m < (this.options.cooC.height/4) && this.options.click > 0 )
    {
        this.options.btTop.tween('top' , 0 );
    }
    else 
    {
        this.options.btTop.tween('top' , -(this.options.btcc.height));
    }
    
    if(  m > ((this.options.cooC.height)-(this.options.cooC.height/4)) && this.options.click < (this.options.nb-1) )
    {
        this.options.btBottom.tween('bottom' , 0 );
    }
    else 
    {
        this.options.btBottom.tween('bottom' , -(this.options.btcc.height));
    }

    
    
},
/*
 * Click Sur le bt haut
 */
up : function(evt)
{
    
    if(this.options.click > 0)
    {
    this.move( -1 );
    this.options.setMove = false;
    this.stopAuto();
    }
    else
    {     
         
         this.options.btTop.tween('top' , -(this.options.btcc.height));
         
    }
},
/*
 * Click Sur le bt bas
 */
down : function(evt)
{
    if (this.options.click < (this.options.nb-1))
    {
    this.move( 1 );
    this.options.setMove = false;
    this.stopAuto();
    }
    else
    {   
        
        this.options.btBottom.tween('bottom' , -(this.options.btcc.height));
        
    }
    
    
}





});