function Main_Menu() {

	this.menu			= {"menu_news":{"index":{"url":"/news/index.html","menu_text":"Последние новости"},"our_news":{"url":"/news/our_news/index.html","menu_text":"Наши новости и обновления"},"blog":{"url":"/news/blog/index.html","menu_text":"Блог"},"subway":{"url":"/news/subway/index.html","menu_text":"Метро"},"tram":{"url":"/news/tram/index.html","menu_text":"Трамвай"},"trol":{"url":"/news/trol/index.html","menu_text":"Троллейбус"},"bus":{"url":"/news/bus/index.html","menu_text":"Автобус"},"railway":{"url":"/news/railway/index.html","menu_text":"ЖД транспорт"},"avia":{"url":"/news/avia/index.html","menu_text":"Авиатранспорт"},"region":{"url":"/news/region/index.html","menu_text":"Город и область"},"incidents":{"url":"/news/incidents/index.html","menu_text":"Происшествия"},"misc":{"url":"/news/misc/index.html","menu_text":"Разное"},"archive":{"url":"/news/archive/index.html","menu_text":"Архив"}},"menu_photobase":{"index":{"url":"/photobase/index.html","menu_text":"Все фото и схемы"},"subway":{"url":"/photobase/subway/index.html","menu_text":"Метро"},"tram":{"url":"/photobase/tram/index.html","menu_text":"Трамвай"},"trol":{"url":"/photobase/trol/index.html","menu_text":"Троллейбус"},"bus":{"url":"/photobase/bus/index.html","menu_text":"Автобус"},"railway":{"url":"/photobase/railway/index.html","menu_text":"ЖД транспорт"},"avia":{"url":"/photobase/avia/index.html","menu_text":"Авиатранспорт"},"region":{"url":"/photobase/region/index.html","menu_text":"Город и область"},"misc":{"url":"/photobase/misc/index.html","menu_text":"Разное"},"authors":{"url":"/photobase/authors/index.html","menu_text":"Авторы"}},"menu_site":{"index":{"url":"/site/index.html","menu_text":"Общие сведения"},"map":{"url":"/site/map/index.html","menu_text":"Карта сайта"},"rss":{"url":"/site/rss/index.html","menu_text":"RSS"},"search":{"url":"/site/search/index.html","menu_text":"Поиск по сайту"},"thanks":{"url":"/site/thanks/index.html","menu_text":"Благодарности"},"banners":{"url":"/site/banners/index.html","menu_text":"Наши кнопки"}},"menu_links":{"index":{"url":"/links/index.html","menu_text":"О Харькове"},"subway":{"url":"/links/subway/index.html","menu_text":"Метро"},"tram":{"url":"/links/tram/index.html","menu_text":"Трамвай"},"trol":{"url":"/links/trol/index.html","menu_text":"Троллейбус"},"bus":{"url":"/links/bus/index.html","menu_text":"Автобус"},"railway":{"url":"/links/railway/index.html","menu_text":"ЖД транспорт"},"misc":{"url":"/links/misc/index.html","menu_text":"Разное"}},"menu_subway":{"index":{"url":"/subway/index.html","menu_text":"Общие сведения"},"history":{"url":"/subway/history/index.html","menu_text":"История"},"chronicle":{"url":"/subway/chronicle/index.html","menu_text":"Хроника"},"maps":{"url":"/subway/maps/index.html","menu_text":"Схемы"},"stations":{"url":"/subway/stations/index.html","menu_text":"Станции и сооружения"},"ps":{"url":"/subway/ps/index.html","menu_text":"Подвижной состав"},"statistics":{"url":"/subway/statistics/index.html","menu_text":"Статистика"},"sounds":{"url":"/subway/sounds/index.html","menu_text":"Аудио"},"books":{"url":"/subway/books/index.html","menu_text":"Документы, книги, публикации"},"contacts":{"url":"/subway/contacts/index.html","menu_text":"Контакты"}},"menu_tram":{"index":{"url":"/tram/index.html","menu_text":"Общие сведения"},"konka":{"url":"/tram/konka/index.html","menu_text":"Конка"},"chronicle":{"url":"/tram/chronicle/index.html","menu_text":"Хроника"},"routes":{"url":"/tram/routes/index.html","menu_text":"Маршруты"},"maps":{"url":"/tram/maps/index.html","menu_text":"Схемы"},"ps":{"url":"/tram/ps/index.html","menu_text":"Подвижной состав"},"photobase":{"url":"/tram/photobase/index.html","menu_text":"Фотогалерея"},"get":{"url":"/get/index.html","menu_text":"ХКП \"Горэлектротранс\""}},"menu_trol":{"index":{"url":"/trol/index.html","menu_text":"Общие сведения"},"chronicle":{"url":"/trol/chronicle/index.html","menu_text":"Хроника"},"routes":{"url":"/trol/routes/index.html","menu_text":"Маршруты"},"maps":{"url":"/trol/maps/index.html","menu_text":"Схемы"},"ps":{"url":"/trol/ps/index.html","menu_text":"Подвижной состав"},"photobase":{"url":"http://trolley.kh.ua/","menu_text":"Фотоальбом"},"get":{"url":"/get/index.html","menu_text":"ХКП \"Горэлектротранс\""}},"menu_bus":{"index":{"url":"/bus/index.html","menu_text":"Общие сведения"},"chronicle":{"url":"/bus/chronicle/index.html","menu_text":"Хроника"},"routes":{"url":"/bus/routes/index.html","menu_text":"Городские маршруты"},"suburban":{"url":"/bus/suburban/index.html","menu_text":"Пригородные и междугородние"},"ps":{"url":"/bus/ps/index.html","menu_text":"Подвижной состав"},"contacts":{"url":"/bus/contacts/index.html","menu_text":"Контакты"}},"menu_railway":{"index":{"url":"/railway/index.html","menu_text":"Общие сведения"},"chronicle":{"url":"/railway/chronicle/index.html","menu_text":"Хроника"},"shedules":{"url":"/railway/shedules/index.html","menu_text":"Расписания"},"ps":{"url":"/railway/ps/index.html","menu_text":"Подвижной состав"},"lines":{"url":"/railway/lines/index.html","menu_text":"Линии"},"contacts":{"url":"/railway/contacts/index.html","menu_text":"Контакты"}},"menu_avia":{"index":{"url":"/avia/index.html","menu_text":"Общие сведения"},"history":{"url":"/avia/history/index.html","menu_text":"История аэропорта"},"chronicle":{"url":"/avia/chronicle/index.html","menu_text":"Хроника"},"shedule":{"url":"/avia/shedule/index.html","menu_text":"Расписание"},"contacts":{"url":"/avia/contacts/index.html","menu_text":"Контакты"}},"menu_misc":{"index":{"url":"/misc/index.html","menu_text":"Общие сведения"},"dgd":{"url":"/misc/dgd/index.html","menu_text":"Малая Южная"},"roapway":{"url":"/misc/roapway/index.html","menu_text":"Канатная дорога"},"passage_boat":{"url":"/misc/passage_boat/index.html","menu_text":"Паром"},"maps":{"url":"/misc/maps/index.html","menu_text":"Карты и схемы"},"docs":{"url":"/misc/docs/index.html","menu_text":"Документы"},"statistics":{"url":"/misc/statistics/index.html","menu_text":"Статистика"},"bahn":{"url":"/misc/bahn/index.html","menu_text":"Bahn"},"model":{"url":"/misc/model/index.html","menu_text":"Модель харьковского трамвая"},"humour":{"url":"/misc/humour/index.html","menu_text":"Юмор"}}};
	this.menu_divs		= {};
	this.hide_timeouts	= {};
	this.zindex			= 1000;

	this.createMenu = function(menu_item) {
		var menu_item_id = menu_item.attr("id");
		if ( (menu_item_id) && (this.menu[menu_item_id]) ) {
			var object = this;
			this.menu_divs[menu_item_id] = $("<ul/>")
				.hide()
				.attr("id", menu_item_id + '_actions')
				.addClass("actions_list")
				.addClass("actions_list_main_menu")
				.bind('mouseenter', function(event) { object.clearHideTimeout(event, menu_item); })
				.bind('mouseleave', function(event) { object.setHideTimeout(event, menu_item); });
			actions = this.menu[menu_item_id];
			for (key in actions) {
				action = actions[key];
				this.menu_divs[menu_item_id].append('<li><a href="' + action.url + '">' + action.menu_text + '</a></li>');
			}
			this.menu_divs[menu_item_id].appendTo('body');
			return this.menu_divs[menu_item_id];
		} else {
			window.alert('Ошибка');
			throw('Wrong ID');
		}
	}

	this.showMenu = function(event, menu_item) {
		this.clearHideTimeout(event, menu_item);
		event = event || window.event;
		var menu_item_id = menu_item.attr("id");
		var list = null;
		if (!this.menu_divs[menu_item_id]) {
			list = this.createMenu(menu_item);
		} else {
			list = this.menu_divs[menu_item_id];
		}
		var offset = menu_item.offset();
		list.css('top', offset.top + menu_item.outerHeight());
		list.css('left', offset.left + 10);
		list.css('z-index', this.zindex++);
		list.show();
		menu_item.addClass('active');
	}

	this.setHideTimeout = function(event, menu_item) {
		var object = this;
		var menu_item_id = menu_item.attr("id");
		this.hide_timeouts[menu_item_id] = setTimeout( function() { object.hideMenu.call(object, event, menu_item); }, 25);
	}

	this.clearHideTimeout = function(event, menu_item) {
		var menu_item_id = menu_item.attr("id");
		if (this.hide_timeouts[menu_item_id]) {
			clearTimeout(this.hide_timeouts[menu_item_id]);
		}
		this.hide_timeouts[menu_item_id] = null;
	}

	this.hideMenu = function(event, menu_item) {		event = event || window.event;
		var target = event.target || event.srcElement;
		var menu_item_id = menu_item.attr("id");
		var list = this.menu_divs[menu_item_id];
		if (typeof(list) == 'object') {			list.hide();
		}
		menu_item.removeClass('active');
	}

	this.init = function() {
		var object = this;
		var header = $('#header');
		header.find('#main_menu li[id], #additional_menu li[id]').bind("mouseenter", function(event) { object.showMenu(event, $(this)); });
		header.find('#main_menu li[id], #additional_menu li[id]').bind("mouseleave", function(event) { object.setHideTimeout(event, $(this)); });
	}

	this.init();

}

$(document).ready(function () { new Main_Menu(); });

/* function createMenu() {
	if (typeof(jQuery) != 'undefined') {
		if (window.jQuery && window.Main_Menu) {
			return new Main_Menu();
		} else {
			return null;
		}
	} else {
		retun null;
	}
}

var menu = createMenu();
if (!menu) {
	var menu_interval = setInterval(function() { if (menu = createMenu()) { clearInterval(menu_interval); } }, 500);
} */