window.addEvent('domready', function() {

	
	
    //fix IE zindex issues
	if(Browser.Engine.trident){
    	var zIndexNumber = 1000;
    	$$('div').each(function(el,i){
    		el.setStyle('z-index',zIndexNumber);
    		zIndexNumber -= 1;
    	});
    };
	
	$('eat_expand').addEvent('click',function(e){
	   e.stop();
	   $('eat_options').toggle();
	   $('eat').toggleClass('eat_open');
	});
	
	var status = {
		'true': 'Close menu',
		'false': 'Open menu'
	};
	
	var fadeTo = {
		'true': 'out',
		'false': 'in'
	};
	
	// Initialise the slide effect for the element that requires it
	// Menus
	var locVerticalSlide = new Fx.Slide('locations');
	var actVerticalSlide = new Fx.Slide('activities');
	var offVerticalSlide = new Fx.Slide('offers');
	var sorVerticalSlide = new Fx.Slide('sort');
	
	// Mini-menus / status
	var locStatus = new Fx.Slide('location_status');
	var actStatus = new Fx.Tween('activities_mini_menu');
	var offStatus = new Fx.Tween('offer_status');
	var sorStatus = new Fx.Tween('sort_status');
	
	$('close_menu').addEvent('click', function(e){
		e.stop();
		$('eat_options').hide();
		$('eat').removeClass('eat_open');		
		locVerticalSlide.toggle();
		actVerticalSlide.toggle();
		offVerticalSlide.toggle();
		sorVerticalSlide.toggle();
	});
	
	// When Vertical Slide ends its transition, we check for its status
	// note that complete will not affect 'hide' and 'show' methods
	// This is based on the activities menu only
	actVerticalSlide.addEvent('complete', function() {
		$('close_menu').set('html', status[actVerticalSlide.open]);
		// Show status
		$('location_status').fade(fadeTo[actVerticalSlide.open]);
		$('activities_mini_menu').fade(fadeTo[actVerticalSlide.open]);
		$('offer_status').fade(fadeTo[actVerticalSlide.open]);
		$('sort_status').fade(fadeTo[actVerticalSlide.open]);
	});
	
	// Hide the status menus
	
	// alert(locStatus);
	
	// locStatus.hide();
	$('location_status').setStyle('opacity',0);
	$('activities_mini_menu').setStyle('opacity',0);
	$('offer_status').setStyle('opacity',0);
	$('sort_status').setStyle('opacity',0);
});
