$("document").ready(
	function() {
		/* language select */
		$("#select_lang").click(
			function() {
				$(this).siblings(".select").css({ 'top': '15px' });
			}
		);
		
		$(".languages .select").hover(
			function() {},

			function() {
				$(this).css({ 'top': '-10000px' });
			}
		);
		
		/* Main menu */
		$("#main_menu td").hover(
			function() {
				var menuItemLeft = $(this).attr("offsetLeft");
				var submenuWidth = $(this).find(".submenu").width();
				var docWidth = $(".page_wrapper").width();
				
				var posLeft = (menuItemLeft + submenuWidth < docWidth) ? menuItemLeft - 6 : docWidth - submenuWidth;
				
				$(this).find(".submenu").css({ 
					'left': posLeft + 'px',
					'top': '121px'
				});
			},
			
			function() {
				$(this).find(".submenu").css({ 
					'top': '-10000px'
				});
			}
		);
		
		
		/* Map functions */
		$("#map a.point").hover(
			function() {
				$(this).css("z-index", "960");
				$(this).siblings("area").css("z-index", "950");

				var posLeft = $(this).attr("offsetLeft") - Math.ceil($(this).siblings(".caption").width() / 2) + 5;
				var posTop = $(this).attr("offsetTop") - $(this).siblings(".caption").height();
				$(this).siblings(".caption").css({
					'left': posLeft + 'px',
					'top': posTop + 'px',
					'z-index': '980'
				});

				$(this).siblings().css('visibility', 'visible');
			},
			
			function() {
				$(this).siblings().css({
					'z-index': '0',
					'visibility': 'hidden'
				});
			}
		);
	}
);