window.addEvent('domready', function() {
    Page.init();
});

window.addEvent('resize', function() {
    Page.init();
});

// IE only
if(Browser.Engine.trident) {
  window.addEvent('scroll', function(){
      Page.scroll();    
  });
}

var Page = {  
 
  timer : null,
 
  init : function(){
  
    var menu = $('menu');
    var content = $('content');
    if(menu && content){
      
      // Start and end positions for the menu
      var startPos = content.getCoordinates().left - 20;
      
      
      // Position the menu properly
      menu.setStyles({
        left: startPos,
        display: "block"
      }); 
      
     
      var endPos = startPos - menu.getSize().x + 60;      
      var slideOut = new Fx.Tween(menu);
      menu.addEvents({
        'mouseover' : this.move.bindWithEvent(slideOut, {property: 'left', end: endPos}),
        'mouseout'  : this.move.bindWithEvent(slideOut, {property: 'left', end: startPos})
      });    

    }
  
  },
    
  move : function(event, args){   
    var relatedObj = $(event.relatedTarget);  
    if((relatedObj == null || relatedObj.get('tag') != 'a') && 
        event.target.id == 'menu' && 
        event.target.getStyle('left').toInt() != args.end) {
      this.start(args.property, args.end);
    }    
  },
 
  scroll : function(){
    $('menu').setStyle('top', window.getScroll().y + 130);
  }
  
}  

