window.addEvent('domready', function(){
	// Set active navigation item
	$$('#navigation a').filter(function(item){
		return document.location.href.contains(item.href);
	}).addClass('active');
	
	// Also make parent navigation item active
	$$('#navigation a.active').getParents('li').each(function(item){
		item.getFirst('a').addClass('active');
	});
	
	// Fading navigation items
	$$('#navigation a:not(.active)').setStyles({
		'background': 'none'
	}).addEvents({
		'mouseenter': function(){
			this.getElement('span').fade(1);
		},
		'mouseleave': function(){
			this.getElement('span').fade(0);
		}
	}).each(function(item){
		new Element('span', {
			'styles': {
				'opacity': 0
			},
			'tween': {
				duration: 300,
				transition: 'quad:out'
			}
		}).inject(item);
	});
	
	// Tooltips
	$$('#tooltipMap area[title][alt]').each(function(area){
		// Get position of tooltip
		var position = area.get('alt').split(',');
		
		// Create new tooltip
		new Tooltip(area, {
			title: function(){
				return this.get('title').split('|')[0]
			},
			text: function(){
				return this.get('title').split('|')[1]
			},
			position: {
				x: position[0].toInt(),
				y: position[1].toInt()
			}
		});
		
		// Remove title and alt property (so browsers don't show yellow tooltip)
		area.removeProperty('title').removeProperty('alt');
	});
});