window.addEvent('domready', function(e) {
	
	$$('body').addClass('js');
	
	if (Browser.Engine.trident) {
		if (Browser.Engine.version <= 4) {
			$$('ul#menu li').addEvent('mouseenter', function() {this.addClass('hover');});
			$$('ul#menu li').addEvent('mouseleave', function() {this.removeClass('hover');});
		}
	}

	var menulists = $$('ul#menu ul');
	var menufx = new Fx.Elements(menulists, {
		'link': 'cancel',
		'duration': 500,
		transition: Fx.Transitions.Sine.easeOut
	});
	openmenu = function(e, idx) {
		var obj = {};
		menulists.each(function(el, i) {
			if (i == idx) {
				obj[i] = {
					'height': el.getScrollSize().y
				};
			} else {
				obj[i] = {
					'height': 0
				};
			}
		});
		menufx.start(obj);
	}
	var ulcounter = 0;
	$('menu').getChildren('li').each(function(li) {
		var childul = li.getElement('ul');
		if (childul) {
			childul.setStyles({
				'overflow': 'hidden',
				'height': '0'
			});
			li.addEvent('mouseenter', openmenu.bindWithEvent(childul, ulcounter));
			ulcounter++;
		} else {
			li.addEvent('mouseenter', openmenu.bindWithEvent(childul, -1));
		}
	});
	$('menu').addEvent('mouseleave', openmenu.bindWithEvent($('menu'), -1));
	
	var toolTip = new Tips($$('.tooltip'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			toolTip.fade(.9);
		},
		onHide: function(toolTip) {
			toolTip.fade(0);
		}
	});
	
	var accordion = new Accordion('h5.atStart', 'div.atStart', {
    	opacity: false,
		start: true,
		duration: 1000,
    	transition: Fx.Transitions.Pow.easeOut,
		onActive: function(toggler, element){
    		toggler.setStyle('color', '#eaeaea');
    	},
    	
    	onBackground: function(toggler, element){
    		toggler.setStyle('color', '#666666');
    	}
    }, $('accordion'));
});	
