onDomReady(function(){

  
  var slideMenu = $('jewelry_slide');
  
  if(slideMenu){
  
    var topArrow = $('top_arrow');
    var bottomArrow = $('bottom_arrow');
    
    var fx = new Fx;
    fx.initialize($('jewelry_menu'),{duration:600,curve:['cos']});
    
    if(slideMenu.scrollHeight > 350){
    
      topArrow.style.display = 'block';
      bottomArrow.style.display = 'block';
  
      var topPosition = findPos(slideMenu).top;
  
      var activeHeight = findPos($el(slideMenu,'a.jewelry_item_on')[0]).top;
  
      var menuPosition = (activeHeight - topPosition)-135;

      slideMenu.scrollTop = ( menuPosition > 0 )? menuPosition : 0;
  
      fx.start({'opacity':[0,1]});

      var scrollFx = new scrollBox();
      scrollFx.set(slideMenu);
  
      addEvent(slideMenu,'mousemove',function(event){   
        cursorRatio = (Cursor(event).page.y - (topPosition+(slideMenu.offsetHeight/2)))/80;       
        scrollFx.init({'Top':cursorRatio});    
      });
  
      addEvent(slideMenu,'mouseleave',function(event){scrollFx.stop()});
  
      addEvent(topArrow,'mouseover',function(event){scrollFx.init({'Top':-5})});  
      addEvent(topArrow,'mouseout',function(event){scrollFx.stop()});
      addEvent(bottomArrow,'mouseover',function(event){scrollFx.init({'Top':5})});  
      addEvent(bottomArrow,'mouseout',function(event){scrollFx.stop()});
    
    }else{
    
      fx.start({'opacity':[0,1]});
      
    }
  
  }     
  
});


function scrollBox(){

  this.set = function(el){
    this.el = el;
    this.timer = false;
    this.limit = {
      'Top':(el.scrollHeight)-(el.offsetHeight),
      'Left':(el.scrollWidth)-(el.offsetWidth)
    }
  };
  
  this.init = function(move){
 
    this.slide = [];
    this.increase = [];    
    for(var pos in move){
      this.increase[pos] = move[pos];
      this.slide[pos] = this.el["scroll"+pos];
    }
  
    if(!this.timer){
      this.timer = setInterval(function() {
        for(var pos in move) this.move(pos);
      }.bind(this),30);
    }
  };
  
  this.move = function(pos){
    if (this.slide[pos]+this.increase[pos] < 0){
      this.stop();
      this.el['scroll'+pos] = 0;
      this.slide[pos] = 0;
    }else if (this.slide[pos]+this.increase[pos] > this.limit[pos]){
      this.stop();
      this.slide[pos] = this.limit[pos];
      this.el['scroll'+pos] = this.limit[pos];
    }else{        
      this.slide[pos] += this.increase[pos];
      this.el['scroll'+pos] = this.slide[pos];    
    }  
  }
  
  this.stop = function(){
    clearInterval(this.timer);
    this.timer = false;
  }

}
