window.addEvent('domready', function() {
	var 	submenu = document.id('submenu'),
		directionmenu = document.id('directionmenu');

	if(submenu) {
		var 	subitems = submenu.getElements('.toggler'),
			current = null;
		
		subitems.addEvent('click', function(e) {
			var item = this.getElement('ul');
			if(current) { current.dissolve(); }
			if(item) {  
				item.set('reveal', {transitionOpacity: false});
				item.reveal(); 
			}
			current = item;
		});
	}

	if(directionmenu) {
		var 	dm_subitems = directionmenu.getElements('.toggler'),
			dm_photos = dm_subitems.getElements('.photo');

		dm_subitems.each(function(item,key) {
			item.set('tween', { duration: 400, transition: 'linear'});
			dm_photos[key].set('tween', { duration: 400, transition: 'linear'});
		});

		dm_subitems.addEvents( {
			'mouseenter': function(e) {
				var photo = this.getElement('.photo');
				photo.get('tween').start('height',287);
				this.get('tween').start('bottom',287);
			},
			'mouseleave': function(e) {
				var photo = this.getElement('.photo');
				photo.get('tween').start('height',0);
				this.get('tween').start('bottom',0);
			}
		});
		
	}
	
});
