$(document).ready(function(){ init() });

function changeTopMenuView(id, hover) {
	var additional = hover ? "Selected" : "";
	document.getElementById("left_" + id).className = "leftLine" + additional;
	document.getElementById("right_" + id).className = "rightLine" + additional;
	document.getElementById("center_" + id).className = "mblock" + additional;
	
	var els = document.getElementById("center_" + id).getElementsByTagName("a");
	for(var i in els) {
		els[i].className = hover ? "mblockSelectedLink" : "";
	}
}

function init()
{
	initMenu();
	sameOffsetTopForButtons();
	return true;
}

function initMenu()
{
	var menu = "#header .menu li";
	$(menu).hover(
		function(){
			var listContainer = $(this).children();
			var maxWidth = 0;
			$(listContainer).each(function(){
				if($(this).width() > maxWidth)
					maxWidth = $(this).width();
			});
			$(listContainer).each(function(){
				
				$(this).children().width(maxWidth);
				
				if($(this).hasClass("parent"))
					$(this).show();
				$(this).bind("mouseover", function(){
					$(this).children().show();
				})				
			});
			return false;
		},
		function(){		
			var elm = $(this);
			setTimeout(function(){
				$(elm).find("ul").hide();
			}, 500)
		}
		
	)
}

function sameOffsetTopForButtons()
{
	var offsetTopMax = $(".navigation ul.menu").height();
	var offsetTop = $(".navigation ul.menu").height() - $(".information ul.news").height();
	
	if(offsetTopMax < $(".information ul.news").height())
	{
		offsetTopMax = $(".information ul.news").height();
		offsetTop = offsetTopMax - $(".navigation ul.menu").height();
		$("#button-order").css("margin-top", offsetTop+"px")
		alert(offsetTop)
	}
	else
	{
		$("#button-hotline").css("margin-top", offsetTop+"px")
	}	
}