/* subnav //////////////////////////////////////////////////////////////////////////////////////////////////////////// */
$(function(){
	
	// hoverIntent settings
	var config = {    
		sensitivity: 1,			// number = sensitivity threshold (must be 1 or higher)    
		interval: 50,			// number = milliseconds for onMouseOver polling interval    
		over: open_sub,	// function = onMouseOver callback (REQUIRED)    
		timeout: 300,			// number = milliseconds delay before onMouseOut    
		out: close_sub		// function = onMouseOut callback (REQUIRED)    
    };
    
    // Current setup
    var current = $('ul.navigation > li.current ul:first');
    var p_current = $('ul.navigation > li.current');
	var s_current = true;
	function show_current()
	{
		p_current.removeClass("temp_remove");
		$('ul.navigation li ul:first').hide().doTimeout(250, function()
		{
			if($.browser.msie)
				current.show();
			else
				current.stop().fadeTo('fast', 1).show();	
		});
	} show_current(); // initially load current

	// Double check currents
	$('div.header').mouseleave(function() { if(current.is(':not(:visible)')) show_current(); else p_current.removeClass("temp_remove"); });
	$('div.t_nav').mouseenter(function() { if(current.is(':not(:visible)')) show_current(); else p_current.removeClass("temp_remove"); });

    // Execute on over
	function open_sub()
	{
		p_current.addClass("temp_remove");
		$(this).addClass("over"); // Add over class to li
		
		if(!$(this).hasClass('current') && current.is(':visible'))
		{
			current.hide();
			s_current = false;
		}
		
		if($.browser.msie)
			$('ul:first', this).show();
		else
			$('ul:first', this).stop().fadeTo('fast', 1).show();
	}
	
	// Execute on out
	function close_sub()
	{
		$(this).removeClass("over"); // Remove over class from li
		if(!$(this).hasClass('current'))
		{
			$('ul:first', this).hide();	
			if(s_current) show_current();
		}
	}
	
	// Start hoverIntent set defaults
	$('ul.navigation > li').hoverIntent(config);
	if(!$.browser.msie) $('ul.navigation li ul').css({'opacity':'0'});
	
	// Add styles etc.
	$('ul.navigation li:has(ul)').addClass('parent');
	/* $("ul.navigation li ul li:has(ul)").find("a:first").append(" &raquo;"); */
	
});
