var currentSubNavID;
var subNavHoverStatus = 'off';
var dropDownTimer;

$(function()
{
	$('#tagNavigation a').hover(function()
	{
		if($(this).next('ul').hasClass('subNav'))
		{	
			clearTimeout(dropDownTimer);
			currentSubNavID = $(this).next('ul.subNav').attr('id');
			openSubNav();
		}
		
	}, function()
	{
		if($(this).next('ul').hasClass('subNav'))
		{
			dropDownTimer = setTimeout('closeSubNav();', 200);
		}
	});
	
	$('#subNavContainerContentWithTag').hover(function()
	{
		clearTimeout(dropDownTimer);
		subNavHoverStatus = 'on';
	}, function()
	{
		subNavHoverStatus = 'off';
		dropDownTimer = setTimeout('closeSubNav();', 1000);
	});
	
	$('#subNavContainerProducts').hover(function()
	{
		clearTimeout(dropDownTimer);
		subNavHoverStatus = 'on';
	}, function()
	{
		subNavHoverStatus = 'off';
		dropDownTimer = setTimeout('closeSubNav();', 1000);
	});
	
	/*$('.subNav li a').hover(function()
	{
		var backGroundImage = $(this).css('backgroundImage');
		backGroundImage = backGroundImage.replace('Off.', 'On.');
		$(this).css('backgroundImage', backGroundImage);
		
	}, function()
	{
		var backGroundImage = $(this).css('backgroundImage');
		backGroundImage = backGroundImage.replace('On.', 'Off.');
		$(this).css('backgroundImage', backGroundImage);
	});*/
});


function openSubNav()
{
	$('.subNav').slideUp();
	$('#'+currentSubNavID).stop(true, true).slideDown();
}

function closeSubNav()
{
	if(subNavHoverStatus == 'off')
	{
		$('#'+currentSubNavID).stop(true, true).slideUp();
	}
}