var Roadmap = {
	
	initialise: function()
	{
		['open', 'closed'].each(function(element)
		{
			if ($(element))
			{
				// Check the cookie
				var cookie = Cookie.get('arctic_section_' + element);
				
				if (cookie == '1')
				{
					$(element).addClass('hidden');
				}
	
				Roadmap.button(element).injectTop($('header_' + element));
			}
		});
	},
	
	button: function(element)
	{
		var button = new Element('img', { src: 'templates/arctic/images/' + ($(element).hasClass('hidden') ? 'expand' : 'collapse') + '.gif' });
		
		// Event handlers
		button.addEvent('mouseover', function() { this.setStyle('opacity', 0.7) });
		button.addEvent('mouseout', function() { this.setStyle('opacity', 1) });
		
		button.addEvent('click', function() { this.toggle(element); }.bind(this));
		
		return button;
	},
	
	toggle: function(element)
	{		
		$(element).toggleClass('hidden');
		$('header_' + element).getElement('img').src = 'templates/arctic/images/' + ($(element).hasClass('hidden') ? 'expand' : 'collapse') + '.gif';
		
		// Store cookie
		Cookie.set('arctic_section_' + element, $(element).hasClass('hidden') ? '1' : '0', { duration: 1 });
	}
	
}

window.addEvent('domready', Roadmap.initialise);
