
var prodTimer, adviceTimer, woodyTimer, metalTimer, paintTimer;

function inactivateAdviceMenu() {
	clearTimeout(adviceTimer);
	if (link = myGetElementById("advice_menu_link")) {
		link.className = "none";
	}
	if (menu = myGetElementById("advice_menu")) {
		menu.style.visibility = "hidden";
		restoreSelect();
	}
}
function activateAdviceMenu() {
	inactivateProdMenu();
	if (link = myGetElementById("advice_menu_link")) {
		if (menu = myGetElementById("advice_menu")) {
			var lft = link.offsetLeft;
			var top = (link.offsetTop + link.offsetHeight);
			var parent = link;
			while (parent = parent.offsetParent) {
				lft += parent.offsetLeft;
				top += parent.offsetTop;
			}
			// ie mac doesn't figure the padding Ð adjust for it here
			if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Explorer") {
				lft -= 38;
			}
			menu.style.left = lft + "px";
			menu.style.top = top + "px";
			var wdth = link.offsetWidth + 40; // add a little
			menu.style.width = wdth + "px";
			if (link.className == "current") {
				clearTimeout(adviceTimer);
				link.className = "none";
				restoreSelect();
				menu.style.visibility = "hidden";
			} else {
				link.className = "current";
				hideSelect();
				menu.style.visibility = "visible";
			}
			// everything except ie needs to subtract the indent margin space
			if (navigator.userAgent.indexOf("MSIE") == -1) {
				wdth -= 25;
			}
			// assign the 3 submenus to the same width as the advice menu
			// this is necessary for the way ie works
			if (elem = myGetElementById("wood_ass")) {
				elem.style.width = wdth + "px";
			}
			if (elem = myGetElementById("metal_ass")) {
				elem.style.width = wdth + "px";
			}
			if (elem = myGetElementById("paintings_on")) {
				elem.style.width = wdth + "px";
			}
		}
	}
	return false;
}

function doAdviceClick() {
	setInnerHTMLById("", "footer");
	setInnerHTMLById("", "content");
	inactivateAdviceMenu();
	return true;
}

function moutAdvice() {
	if (link = myGetElementById("advice_menu_link")) {
		if (link.className == "current") {
			adviceTimer = setTimeout("inactivateAdviceMenu()", 700);
		}
	}
}

function moverAdvice() {
	clearTimeout(adviceTimer);
}

function moverWoody() {
	inactivateMetal();
	inactivatePaint();
	clearTimeout(woodyTimer);
	if (link = myGetElementById("wood_ass")) {
		if (menu = myGetElementById("wood_ass_menu")) {
			var top = link.offsetTop;// + link.offsetHeight);
			var lft = link.offsetLeft;
			var parent = link;
			while (parent = parent.offsetParent) {
				lft += parent.offsetLeft;
				top += parent.offsetTop;
			}
			// ie mac doesn't figure the padding Ð adjust for it here
			if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Explorer") {
				lft -= 38;
			}
			menu.style.left = lft + link.offsetWidth + "px";
			menu.style.top = top + "px";
			menu.style.width = link.offsetWidth + "px";
			link.className = "current";
			menu.style.visibility = "visible";
		}
	}
}

function moutWoody() {
	woodyTimer = setTimeout("inactivateWoody()", 200);
}

function inactivateWoody() {
	if (menu = myGetElementById("wood_ass_menu")) {
		menu.style.visibility = "hidden";
	}
	if (link = myGetElementById("wood_ass")) {
		link.className = "indent";
	}
}

function doWoodyClick() {
	inactivateWoody();
	return doAdviceClick();
}

function moverMetal() {
	inactivateWoody();
	inactivatePaint();
	clearTimeout(metalTimer);
	if (link = myGetElementById("metal_ass")) {
		if (menu = myGetElementById("metal_ass_menu")) {
			var top = link.offsetTop;// + link.offsetHeight);
			var lft = link.offsetLeft;
			var parent = link;
			while (parent = parent.offsetParent) {
				lft += parent.offsetLeft;
				top += parent.offsetTop;
			}
			// ie mac doesn't figure the padding Ð adjust for it here
			if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Explorer") {
				lft -= 38;
			}
			menu.style.left = lft + link.offsetWidth + "px";
			menu.style.top = top + "px";
			menu.style.width = link.offsetWidth + "px";
			link.className = "current";
			menu.style.visibility = "visible";
		}
	}
}

function moutMetal() {
	metalTimer = setTimeout("inactivateMetal()", 200);
}

function inactivateMetal() {
	if (menu = myGetElementById("metal_ass_menu")) {
		menu.style.visibility = "hidden";
	}
	if (link = myGetElementById("metal_ass")) {
		link.className = "indent";
	}
}

function doMetalClick() {
	inactivateMetal();
	return doAdviceClick();
}


function moverPaint() {
	inactivateWoody();
	inactivateMetal();
	clearTimeout(paintTimer);
	if (link = myGetElementById("paintings_on")) {
		if (menu = myGetElementById("paintings_on_menu")) {
			var top = link.offsetTop;// + link.offsetHeight);
			var lft = link.offsetLeft;
			var parent = link;
			while (parent = parent.offsetParent) {
				lft += parent.offsetLeft;
				top += parent.offsetTop;
			}
			// ie mac doesn't figure the padding Ð adjust for it here
			if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Explorer") {
				lft -= 38;
			}
			menu.style.left = lft + link.offsetWidth + "px";
			menu.style.top = top + "px";
			menu.style.width = link.offsetWidth + "px";
			link.className = "current";
			menu.style.visibility = "visible";
		}
	}
}

function moutPaint() {
	paintTimer = setTimeout("inactivatePaint()", 200);
}

function inactivatePaint() {
	if (menu = myGetElementById("paintings_on_menu")) {
		menu.style.visibility = "hidden";
	}
	if (link = myGetElementById("paintings_on")) {
		link.className = "indent";
	}
}

function doPaintClick() {
	inactivatePaint();
	return doAdviceClick();
}


function inactivateProdMenu() {
	clearTimeout(prodTimer);
	if (link = myGetElementById("prod_menu_link")) {
		link.className = "none";
	}
	if (menu = myGetElementById("prod_menu")) {
		menu.style.visibility = "hidden";
		restoreSelect();
	}
}
function activateProdMenu() {
	inactivateAdviceMenu();
	if (link = myGetElementById("prod_menu_link")) {
		if (menu = myGetElementById("prod_menu")) {
			var lft = link.offsetLeft;
			var top = (link.offsetTop + link.offsetHeight);
			var parent = link;
			while (parent = parent.offsetParent) {
				lft += parent.offsetLeft;
				top += parent.offsetTop;
			}
			// ie mac doesn't figure the padding Ð adjust for it here
			if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Explorer") {
				lft -= 38;
			}
			menu.style.left = lft + "px";
			menu.style.top = top + "px";
			menu.style.width = link.offsetWidth + "px";
			if (link.className == "current") {
				clearTimeout(prodTimer);
				link.className = "none";
				menu.style.visibility = "hidden";
				restoreSelect();
			} else {
				link.className = "current";
				menu.style.visibility = "visible";
				hideSelect();
			}
		}
	}
	return false;
}

function doProdClick() {
	setInnerHTMLById("", "footer");
	setInnerHTMLById("", "content");
	inactivateProdMenu();
	return true;
}

function moutProd() {
	if (link = myGetElementById("prod_menu_link")) {
		if (link.className == "current") {
			prodTimer = setTimeout("inactivateProdMenu()", 700);
		}
	}
}

function moverProd() {
	if (link = myGetElementById("prod_menu_link")) {
		if (link.className == "current") {
			clearTimeout(prodTimer);
		}
	}
}

function selectExhibitionSection(funky) {
	if (self[funky]) {
		inactivateProdMenu();
		//alert(funky);
		eval(funky + '()');
		return false;
	} else {
		doProdClick();
		return true;
	}
}

// here's some stuff to handle ie bugginess

function hideSelect(){
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		for (var i = 0; i < document.all.length; i++) {
			o = document.all(i);
			if (o.type == 'select-multiple') {
				if (o.style) o.style.display = 'none';
			}
			if (o.type == 'select-one') {
				if (o.style) o.style.display = 'none';
			}
		}
	}
}

function restoreSelect(){
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		for (var i = 0; i < document.all.length; i++) {
			o = document.all(i);
			if (o.type == 'select-one') {
				if (o.style) o.style.display = '';
			}
			if (o.type == 'select-multiple') {
				if (o.style) o.style.display = '';
			}
		}
	}
}
