$(document).ready(function() {
	$('.active').parent().parent().show();
	$('.level1 > a').mouseover(function() {
		$('.level2').hide();
		$('.level3').hide();
		$(this).parent().find('.level2').fadeIn();
	});
	$('.level2 > li > a').mouseover(function() {
		
		var position  = $(this).offset();
		var val =0;
		
				$('.level3').hide();
		
		$(this).parent().find('.level3').fadeIn();
		
		sum = 0;
		$('.level3 > li').each(function()
		{
		sum += $(this).width();
		});

		if(sum + (position.left - $('#Container').offset().left) < 900)
		{
		//alert(parseInt(position.left));
		$(this).parent().find('.level3').css('padding-left', (parseInt(position.left) - parseInt($('#Container').offset().left)));
		}
		else
		{
		//alert(parseInt(position.left));
			$(this).parent().find('.level3').css('padding-left',(parseInt(position.left) - parseInt($('#Container').offset().left)) - (sum + (parseInt(position.left) - parseInt($('#Container').offset().left)) - 900));
		}
		

	});
});
