window.addEvent('domready', function(){

	var nav_blocks;
	var nav_links;

	var active_nav = null;

	nav_blocks = $$('div#header div.menu_block a.main_nav');
	nav_links = $$('div#header div.menu_block a');


	nav_blocks.each(function(el, idx){
		var child_ul;
		child_ul = el.getNext('ul');

		if($chk(child_ul)){

			fx = new Fx.Morph(child_ul, {duration: '700', link: 'cancel', transition: 'bounce:out'});

			el.store('morph', fx);

			el.addEvents({
				'mouseenter': function(){
					if($chk(active_nav) && active_nav != el){
						active_nav.retrieve('morph').start({
							'opacity': [1,0],
							'top': [16,-40]
						})
					}
					if(active_nav != el){
						this.retrieve('morph').start({
							'opacity': [0,1],
							'top': [-40,16]
						})
					}
					active_nav = el;
				}
			})
		}
	})

	//console.log(paige);

	nav_links.each(function(el,idx){
		if(el.href.indexOf(paige)>0 && paige!=('/')){
			el.addClass('on');
			if($chk(el.getParent('ul'))){
				el.getParent('ul').getPrevious().fireEvent('mouseenter');
				active_nav = el.getParent('ul').getPrevious();
			}
		}
	})

});
