	/* Menu */
	var top_menu_timeout	= 200;
	var top_menu_timer	= 0;

	function menu_init()
	{
		$("#menu div.sub_header a").bind("click", function()
		{
			$(this).parent().next("div.sub").toggle();
			return false;
		});

		var hrefs = $("#menu a");
		for (var i = 0; i < hrefs.length; i++)
		{
			var href = hrefs.eq(i);
			if (location.href != href[0].href)
				continue;

			href.addClass("mselected");
			href.parents("div.sub").show();
			break;
		}

		add_class($("div.toplinks a"), "selectedtop");
		add_class($("div.bottomlinks a"), "selectedbottom");

		$("div.topmenu div").bind("mouseenter mouseleave", select_top_item);
		$("div.topmenu div").bind("dbclick click", click_top_item);

		$("div.topmenu").bind("mouseenter", stop_hide_top_menu);
		$("div.topmenu").bind("mouseleave", start_hide_top_menu);
	}

	function add_class(as, cname)
	{
		for (var i = 0; i < as.length; i++)
		{
			if (as[i].href != location.href)
				continue;

			as.eq(i).addClass(cname);
			break;
		}

		as.eq(2).bind("mouseenter", {href: as.eq(2).attr("href")}, show_top_menu);
		as.eq(3).bind("mouseenter", {href: as.eq(3).attr("href")}, show_top_menu);
		as.eq(2).bind("mouseleave", start_hide_top_menu);
		as.eq(3).bind("mouseleave", start_hide_top_menu);
	}

	function select_top_item()
	{
		$(this).toggleClass("topmenuselected");
	}

	function click_top_item()
	{
		var hrefs = $("a", this);

		if (hrefs.length == 0)
			return;

		location.href = hrefs[0].href;
	}

	function show_top_menu(eventObject)
	{
		clearTimeout(top_menu_timer);

		var topmenu = $("div.topmenu");

		topmenu.show();
		topmenu.css("top", $(this).offset().top + this.offsetHeight - 1);
		topmenu.css("left", $(this).offset().left);

		$("div.topmenu a").eq(0).attr("href", eventObject.data["href"] + " Оборудование/");
		$("div.topmenu a").eq(1).attr("href", eventObject.data["href"] + " Экологическое/");
	}

	function hide_top_menu()
	{
		$("div.topmenu").hide();
	}

	function start_hide_top_menu()
	{
		top_menu_timer = setTimeout("hide_top_menu()", top_menu_timeout);
	}

	function stop_hide_top_menu()
	{
		clearTimeout(top_menu_timer);
	}

	$(document).ready(menu_init);