

var handler;

var openMenu = 0;
var openSubMenu = 0;


function showInfoMenu( menuID, elements ) {
	$('#nav a').removeClass('hover');
	$(this).addClass('hover');
	hideMenu( openMenu );
	showMenu( menuID, elements );
	clearTimeout( handler );
}

function showInfoSubMenu( menuID, elements ) {
	hideSubMenu( openSubMenu );
	showSubMenu( menuID, elements );
	clearTimeout( handler );
}



function hideMenu( menuID ) {
	if( document.getElementById('o_'+menuID) ) {
		jQuery('#o_'+menuID).css( "display", "none" );
		jQuery('#m_'+menuID).removeClass( "hover" );
	}
	hideSubMenu(openSubMenu);
}
function showMenu( menuID, elements ) {
	if( document.getElementById('o_'+menuID) ) {
		setMarginLeft( menuID );
		//setWidth( menuID, elements );
		jQuery('#o_'+menuID).css( "display", "block" );
		jQuery('#m_'+menuID).addClass( "hover" );
		openMenu = menuID;
	}
}


function hideSubMenu( menuID ) {
	if( document.getElementById('s_'+menuID) ) {
		jQuery('#s_'+menuID).css( "display", "none" );
	}
}
function showSubMenu( menuID, elements ) {
	if( document.getElementById('s_'+menuID) ) {
		setMarginLeftSub( menuID );
		setWidthSub( menuID, elements );
		jQuery('#s_'+menuID).css( "display", "block" );
		openSubMenu = menuID;
	}
}

function clearSubmenu() {
	$('#submenu ul').hide();
	$('#nav a').removeClass('hover');
}

//var marginInfo = new Array( 0, 0, 58, 101, 144, 187, 230, 288, 346, 404, 462, 520, 612, 700, 750, 800 );
var marginInfo = new Array( 0, 0, 46, 87, 130, 172, 215, 273, 330, 391, 446, 160, 377, 263, 549, 800, 637 );
var widthInfo = new Array( 0, 0 );

var marginInfoSub = new Array();

var widthInfoSub = 100;

function setMarginLeft( menuID ) {
	jQuery('#o_'+menuID).css( "margin", "0 0 0 "+marginInfo[menuID]+"px" );
}
function setMarginLeftSub( menuID ) {
	var overallLeft = marginInfo[openMenu]+widthInfo[openMenu];
	jQuery('#s_'+menuID).css( "margin", (marginInfoSub[menuID]-1)+"px 0 0 "+overallLeft+"px" );
}


function setWidth( menuID, elements ) {
	for(i=1; i <= elements; i++){
		jQuery('#l_'+menuID+'_'+i).css( "width", widthInfo[menuID] + "px" );
	}
}
function setWidthSub( menuID, elements ) {
	for(i=1; i <= elements; i++){
		jQuery('#x_'+menuID+'_'+i).css( "width", widthInfoSub + "px" );
	}
}

function closeMenuAfterAWhile() {
	//handler = setTimeout( "closeWindowNowStupid()", 500 );
	return true;
}


function closeWindowNowStupid() {
	//hideMenu( openMenu );
}

function stopShuttingDown() {
	clearTimeout( handler );
}