var imgRefs = new Array();
var mnuRefs = new Array();
var activeMenu = null;
var tID = null;

function SwapImage(img) {
	if (!img || !img.src) return;
	var arr = img.src.split(".");
	var origSrc = img.src;
	if (arr.length > 2) arr[arr.length-2] += "_over";
	else arr[0] += "_over";
	img.src = arr.join(".");
	imgRefs[img.src] = origSrc;
}
function ActiveImage(img) {
	if (!img || !img.src) return;
	var arr = img.src.split(".");
	var origSrc = img.src;
	if (arr.length > 2) arr[arr.length-2] += "_active";
	else arr[0] += "_over";
	img.src = arr.join(".");
	imgRefs[img.src] = origSrc;
}
function UnswapImage(img) {
	if (!img || !img.src) return;
	img.src = imgRefs[img.src];
}
function ShowMenu(tI) {
	if (activeMenu) CloseMenu();
	var width = navigator.product == "Gecko" ? window.innerWidth : document.body.offsetWidth;
	var img = tI.firstChild;
	SwapImage(img);
	var menu = document.getElementById("menu" + tI.id);
	if (menu) {
		if (menu.style.right == "0px" || menu.style.right == "10px") {
			menu.style.right = navigator.product == "Gecko" ? "10px" : "0px";
		} else {
			menu.style.left = (tI.offsetLeft - 1) + "px";		
		}
		menu.style.display = "block";
	}
	activeMenu = tI;
}
function HideMenu() {
	if (!activeMenu) return;
	tID = setTimeout("CloseMenu()", 500);
}
function CloseMenu() {
	clearTimeout(tID);
	if (!activeMenu) return;
	var img = activeMenu.firstChild;
	var menu = document.getElementById("menu" + activeMenu.id);
	UnswapImage(img);
	menu.style.display = "none";
	activeMenu = null;
}
function CancelHide() {
	clearTimeout(tID);
}

function launchNewWindow(url, windowName)
{
     // Open a modal window with no toolbars.
     windowHandle = window.open("", windowName, "toolbar=yes,directories=yes,menubar=yes,titlebar=yes,statusbar=yes,width=900,height=525,scrollbars=yes,resizable=yes");

     // Navigate the window to the location provided.
     windowHandle.location.href = url;

     // Bring focus to the window
     windowHandle.focus();                   
}