function MenuOver (menu) {
	$(menu).addClass('hover');
	submenu = $(menu).find('div.topsubmenu');
	submenu.show();
	
	bottom_submenu = $(menu).find('div.bottomsubmenu');
	bottom_submenu.show();
	
	bottom2submenu = $(menu).find('div.bottom2submenu');
	bottom2submenu.show();
}

function MenuOut (menu) {
	if (!$(menu).find('div.topsubmenu').hasClass('hover'))
		$(menu).find('div.topsubmenu').hide();
	$(menu).removeClass('hover');
	
	if (!$(menu).find('div.bottomsubmenu').hasClass('hover'))
		$(menu).find('div.bottomsubmenu').hide();
	$(menu).removeClass('hover');
	
	if (!$(menu).find('div.bottom2submenu').hasClass('hover'))
		$(menu).find('div.bottom2submenu').hide();
	$(menu).removeClass('hover');
}

function SubMenuOver (submenu) {
	$(submenu).addClass('hover');
}

function SubMenuOut (submenu) {
	$(submenu).removeClass('hover');
}

function SubMenuOver (bottom_submenu) {
	$(bottom_submenu).addClass('hover');
}

function SubMenuOut (bottom_submenu) {
	$(bottom_submenu).removeClass('hover');
}

function SubMenuOver (bottom2submenu) {
	$(bottom2submenu).addClass('hover');
}

function SubMenuOut (bottom2submenu) {
	$(bottom2submenu).removeClass('hover');
}

$(document).ready(function () {
	$('td.menu-item').bind('mouseenter', function () { MenuOver($(this)) });
	$('td.menu-item').bind('mouseleave', function () { MenuOut($(this)) });
	$('div.topsubmenu').bind('mouseenter', function () { SubMenuOver($(this)) });
	$('div.topsubmenu').bind('mouseleave', function () { SubMenuOut($(this)) });
	$('div.topsubmenu').each(function () {
		pos = $(this).parents('td').eq(0).position();
		X = pos.left - 5;
		Y = pos.top + 28;
		$(this).css({ 'left': X + 'px', 'top': Y + 'px' });
	});
	
	$('td.bottom-menu-item').bind('mouseenter', function () { MenuOver($(this)) });
	$('td.bottom-menu-item').bind('mouseleave', function () { MenuOut($(this)) });
	$('div.bottomsubmenu').bind('mouseenter', function () { SubMenuOver($(this)) });
	$('div.bottomsubmenu').bind('mouseleave', function () { SubMenuOut($(this)) });
	$('div.bottomsubmenu').each(function () {
		pos = $(this).parents('td').eq(0).position();
		X = pos.left - 5;
		if (document.location.href.indexOf('shop.ru/index.html')> 0){
			if (navigator.appName == 'Microsoft Internet Explorer') Y = pos.top + 153;
			else Y = pos.top + 165;
		}else{
			Y = pos.top - 70;
		}
		$(this).css({ 'left': X + 'px', 'top': Y + 'px' });
	});
	
	$('td.bottom-menu-item-2').bind('mouseenter', function () { MenuOver($(this)) });
	$('td.bottom-menu-item-2').bind('mouseleave', function () { MenuOut($(this)) });
	$('div.bottom2submenu').bind('mouseenter', function () { SubMenuOver($(this)) });
	$('div.bottom2submenu').bind('mouseleave', function () { SubMenuOut($(this)) });
	$('div.bottom2submenu').each(function () {
		pos = $(this).parent('td.bottom-menu-item-2').eq(0).position();
		X = pos.left - 5;
		if (document.location.href.indexOf('shop.ru/index.html')> 0){
			if (navigator.appName == 'Microsoft Internet Explorer') Y = pos.top + 58;
			else Y = pos.top + 70;
		}else{
			Y = pos.top - 166;
		}
		$(this).css({ 'left': X + 'px', 'top': Y + 'px' });
	});
});

