var current_sub = 0;
var current_sub_a = 0;
var submenu_timer;
function show_submenu(id)
{
	$('#submenu-container').css("display","block");
	$('#submenu-content').html($("#submenu_"+id).html());
	
	atop = ($('#submenu-container').height() - $("#menu_"+id).height()) / 2;
	
	$('#submenu-container').css("top",($("#menu_"+id).offset().top-atop-2)+"px");

	$('#submenu-container').mouseover(function() { show_submenu_a(current_sub) });
	$('#submenu-container').mouseout(function() { hide_submenu() });
	
	current_sub = id;
	current_sub_a = id;

	clearTimeout(submenu_timer);
}

function show_submenu_a(id)
{
	clearTimeout(submenu_timer);
	current_sub_a = current_sub;	
}

function hide_submenu()
{
	current_sub_a = 0;
	submenu_timer = setTimeout("delay_hide()", 500);
}

function delay_hide()
{
	if(current_sub_a == 0)
	{
		$('#submenu-container').css("display","none");		
	}
}


window.onload = function() { set_background() };
window.onresize = function() { set_background() };

function set_background()
{
	width = getWindowWidth();
	height = getWindowHeight();
	$('#bck_overlay').css("left", ((width / 2)-300)+"px");
	$('#bck_overlay').css("background-position", ((width / 2)-300)+"px 0px");
	$('#bck_overlay_nav').css("width", ((width / 2)-300)+"px");
	$('#bck_overlay_nav').css("background-position", (((width / 2)-300)-560) + "px " +  ((height - 830))  +"px");
	
	$('#bck_overlay_nav').css("display", "block");
	$('#bck_overlay').css("display", "block");
}

function getWindowWidth()
{
	if (window.self && self.innerWidth) {return self.innerWidth;}
	if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}return 0;
}

function getWindowHeight()
{
	if (window.self && self.innerHeight) {return self.innerHeight;}
	if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}return 0;
}

