/*

	Series of methods that should have been classes together with objects created,
	but was done through programmatic functionality instead.  These scripts observe
	and provide the fuctionality for the right hand navigation panel and its
	accordion menu.

*/

var oldDT = null;
var oldDD = null;

function observeRightNav() {
	
	var dds = $$('#right-navigation dd');
	dds.invoke('hide');
	dds.invoke('removeClassName', 'hidden');
	
	
	$$('#right-navigation dt').each(function(e){
								if (e != $('right-top') && e != $('right-bottom') ) {	
									Event.observe(e, 'click', function(event){
																dropDown(Event.element(event) );		   
															   });
								}
									 });

	$$('#right-navigation dt').each(function(e){
									Event.observe(e, 'mouseover', function(event){
																	Event.element(event).addClassName('hover');		   
															       });
							  });
	$$('#right-navigation dt').each(function(e){
									Event.observe(e, 'mouseout', function(event){
																	Event.element(event).removeClassName('hover');		   
															     });
							  });
}

function dropDown(element) {
	var dt = element;
	var dd = element.next();
	
	if (oldDT) {
		new Effect.BlindUp(oldDD, {queue: 'end', duration: .3});

		oldDT.removeClassName('on');
		if (oldDT == $$('.first-right')[0]  ) {
			$('right-top').removeClassName('on');
		}
		if (oldDT == $$('.last-right')[0] ) {
			$('right-bottom').removeClassName('on');
			
		}
	}
	
	if (dt != oldDT) {
		
		if (dt == $$('.first-right')[0]  ) {
			$('right-top').addClassName('on');
		}
		if (dt == $$('.last-right')[0] ) {
			$('right-bottom').addClassName('on');
			
		}
		
		dt.addClassName('on');
		new Effect.BlindDown(dd, {queue: 'end', duration: .3});
		
		oldDT = dt;
		oldDD = dd;
	}
	else {
		oldDT = null;
		oldDD = null;
		$('right-top').removeClassName('on');
		$('right-bottom').removeClassName('on');
	}
}



