var Navigation = new Class({
	initialize: function(options){
		_self = this;
		_self.addListeners();
	},
	
	addListeners: function() {
		var buttons = $$('#navigation div.navItem');
		buttons.each(function(el, i){
			var link = $(el.getElementsByTagName("a")[0])
			
			var onButton = el.getElementById(el.id+'_on');
			var offButton = el.getElementById(el.id+'_off');
			var resetButton = new Fx.Styles(onButton, {'duration': 0, 'wait': false, transition: Fx.Transitions.linear});
			resetButton.start({'opacity':0});
			
			var overONfxs = new Fx.Styles(onButton, {'duration': 150, 'wait': false, transition: Fx.Transitions.linear});
			var overOFFfxs = new Fx.Styles(offButton, {'duration': 50, 'wait': false, transition: Fx.Transitions.linear});
			if (!link || link.getTag() != 'a') return;
			link.addEvent('mouseover', function(){
				if(!this.getParent().hasClass('active')){
					overONfxs.start({'opacity':1});
					overOFFfxs.start({'opacity':0});
				}
			});
			link.addEvent('mouseout', function(){
				if(!this.getParent().hasClass('active')){
					overONfxs.start({'opacity':0});
					overOFFfxs.start({'opacity':1});
				}
			});
		});
	},
	
	removeListeners: function() {
		document.removeEvent('mouseup', _self.stop);
	},
	
	setActive: function(navID){
		var currentNavItem = $$('.active')[0];
		//alert(currentNavItem);
		if(!currentNavItem){}else{currentNavItem.removeClass('active');};
		var newNavItem = $('nav_'+navID);
		//alert(newNavItem);
		newNavItem.addClass('active');
		if(!currentNavItem){}else{navigation.fadeOut(currentNavItem);};
		navigation.fadeIn(newNavItem);
		
	},
	
	fadeIn: function(el) {
		var onButton = el.getElementById(el.id+'_on');
		var offButton = el.getElementById(el.id+'_off');
		
		var overONfxs = new Fx.Styles(onButton, {'duration': 150, 'wait': false, transition: Fx.Transitions.linear});
		var overOFFfxs = new Fx.Styles(offButton, {'duration': 50, 'wait': false, transition: Fx.Transitions.linear});
		overONfxs.start({'opacity':1});
		overOFFfxs.start({'opacity':0});
	},
	
	fadeOut: function(el) {
		var onButton = el.getElementById(el.id+'_on');
		var offButton = el.getElementById(el.id+'_off');
		
		var overONfxs = new Fx.Styles(onButton, {'duration': 150, 'wait': false, transition: Fx.Transitions.linear});
		var overOFFfxs = new Fx.Styles(offButton, {'duration': 50, 'wait': false, transition: Fx.Transitions.linear});
		overONfxs.start({'opacity':0});
		overOFFfxs.start({'opacity':1});
	}
	
});

