/**
 * @Source: http://anotherdan.com/9/simple-drop-down-menu-with-jquery
 * @Author: Dan
 * @Modifications: lloydirvin (lloyd@agyuku.net)
 * @date: 02.17.2009
 **/

$(document).ready(function() {			
	var selected = $('#selectedtab').html();	
	
	$('ul#nav > li').hover(function() {
		var classname = $(this).attr('class').split(' ')[0];
		
		if(classname != selected) {
			if(classname.indexOf('-selected') == -1) {
				$(this).removeClass().addClass(classname+'-hover tab');
				$('#hovered').html(classname);
			}
		}	
		
		// IE FIX :$theglue
		if($.browser.msie) {			
			$('ul', this).css('top',$(this).position().top + $(this).height());
			$('ul', this).css('left',$(this).position().left);
		}  	
		
	$('ul:first', this).show();
	},
	function() {		
		var hovered = $('#hovered').html();
		$('.'+hovered+'-hover').removeClass().addClass(hovered+' tab');
		$('#hovered').html('');	
		$('ul:first', this).hide();
	});
	
	$('ul#nav li li').hover(function() {
		$('a:first',this).addClass('hilite');
		$('ul:first', this).each(function() {
			$(this).css('top', $(this).parent().position().top - 1);
		  	$(this).css('left', $(this).parent().position().left + $(this).parent().width());
		  	$(this).show();	  	
		});	
	},
	function() {
		$('a:first',this).removeClass('hilite');
		$('ul:first', this).hide();
	});
});
