var popupHideTimer;
$(document).ready(function() 
{
	
	$('.topmenu').bind('mouseenter mouseover', function()
	{
		$('#'+$(this).attr('id').replace('topmenu-', 'topmenulvl5-')).css('display', 'block');
	});

	$('.topmenu').bind('mouseleave', function()
	{
		$('#'+$(this).attr('id').replace('topmenu-', 'topmenulvl5-')).css('display', '');
		$(this).find('a').data('touchClickAllowed', false);
	});

	$('.topmenulvl5item').bind('mouseenter mouseover', function()
	{
		var div = $('#'+$(this).attr('id').replace('topmenulvl5item-', 'topmenulvl6-'));
		if(div.find('.topmenulvl6item').length==0)
			return;

		div.css('display', 'block');
		$(this).addClass('topmenulvl5item-selected')
	});

	$('.topmenulvl5item').bind('mouseleave', function()
	{
		$('#'+$(this).attr('id').replace('topmenulvl5item-', 'topmenulvl6-')).css('display', '');
		$(this).removeClass('topmenulvl5item-selected')
		$(this).find('a').data('touchClickAllowed', false);
	});
	
	$('.topmenulvl5item').each(function()
	{
		
		if($('#'+$(this).attr('id').replace('topmenulvl5item-', 'topmenulvl6-')).find('.topmenulvl6item').length>0)
			$(this).addClass('topmenulvl5item-haschildren')
	});

	
});

function isTouchClickAllowed(obj)
{
	if('ontouchstart' in document.documentElement)
	{
		if($(obj).data('touchClickAllowed')==true)
		{
			return true;
		}
		else
		{
			if($(obj).parent().hasClass('topmenulvl5item-haschildren')||$(obj).parent().hasClass('topmenu'))
			{
				$(obj).data('touchClickAllowed', true);
				return false;
			}
			else
			{
				return true;
			}
		}
	}
}
