// IMAGE PRE-LOAD //
if (document.images) {
	preloadImage			= new Image();
	preloadImage.src 		= 'images/menu.hover.png';
	preloadImage			= new Image();
	preloadImage.src 		= 'images/menu.select.png';
}

// MENU SYS
var activeMenu = null;
var closingSub = null;
var waitingClose = null;

document.onclick = menuOff;

function showMenu(parent, menu, x, y) {
	menuSource = document.getElementById(parent);
	activeMenu = document.getElementById(menu);
	
	menuSource.style.backgroundImage = 'url(images/menu.select.png)';
	activeMenu.style.display = "block";
	activeMenu.style.left = parseInt(x + menuSource.offsetLeft)+ "px";
	activeMenu.style.top = parseInt(y + menuSource.offsetHeight)+ "px";	
}

function menuExtend(menuSource)		{ clearTimeout(waitingClose); closingSub = 0; }
function menuOffWait(menuSource)	{ closingSub = activeMenu; waitingClose = setTimeout('menuOff()', 250); }
function menuOff()			{
	if (closingSub) {
		if (closingSub == activeMenu) {
			clearTimeout(waitingClose); 
			if (menuSource.className == 'menuBarItemStatic')
				{ menuSource.style.backgroundImage = 'url(images/menu.hover.png)'; }
			else
				{ menuSource.style.backgroundImage = 'none'; }
			closingSub.style.display = 'none';
			closingSub = 0;
		}
	}
}
