var menuTimer = 0;
var l_MenuOver = '';
var l_MenuDown = '';
var l_Sub = '';
var l_SubOver = '';
var l_SubDown = '';
var menuOn = '';
var menuDown = '';
var subOn = '';
var subDown = '';

function menu_over (iMenu, iC) {
	//stopAll
	stopAll();

	//clearMain
	clear_menu();

	//set hilight
	if (l_MenuDown != iMenu){
		menuOn = document.all[iMenu].style.backgroundColor;
		document.all[iMenu].style.backgroundColor = iC;
		l_MenuOver = iMenu;}
}

function menu_off () {
	delayClear();
}

function menu_click (iMenu, iSub, iURL, iLayer_name, iC) {
	if (l_MenuDown != '')
	{
		document.all[l_MenuDown].style.backgroundColor = menuDown;
	}
	if (l_SubDown != ''){
		document.all[l_SubDown].style.backgroundColor = subDown;
		l_SubDown = '';
	}
	if (l_Sub != '')
	{
		document.all[l_Sub].style.visibility="hidden";
		l_Sub = '';
	}
	menuDown = menuOn
	document.all[iMenu].style.backgroundColor = iC;
	l_MenuDown = iMenu;
	if (iSub != '')
	{
		document.all[iSub].style.visibility="visible";
		l_Sub = iSub;
	}
	if (iLayer_name != '' && iURL != '')
	{
		document.all[iLayer_name].src = iURL;
	}
}

function sub_over (iSub, iC) {
	//stopAll
	stopAll();

	//clearMain
	clear_sub();

	//set hilight
	if (l_SubDown != iSub){
		subOn = document.all[iSub].style.backgroundColor
		document.all[iSub].style.backgroundColor = iC;
		l_SubOver = iSub;}
}

function sub_off () {
	delayClear();
}

function sub_click (iSub, iURL, iLayer_name, iC) {
	if (l_SubDown != '')
	{
		document.all[l_SubDown].style.backgroundColor = subDown;
	}
	subDown = subOn;
	document.all[iSub].style.backgroundColor = iC;
	l_SubDown = iSub;
	if (iLayer_name != '' && iURL != '')
	{
		document.all[iLayer_name].src = iURL;
	}

}

function stopAll(){
	if (menuTimer > 0 ){
		clearTimeout(menuTimer);
		menuTimer = 0;
	}
}

function delayClear(){
	if (menuTimer > 0) {
		clearTimeout(menuTimer);
		menuTimer = 0;
	}
	menuTimer = setTimeout('clear_menu()', 100);

}

function clear_menu () {
	clear_sub();
	if (l_MenuOver != '')
	{
		if (l_MenuOver != l_MenuDown)
		{
			document.all[l_MenuOver].style.backgroundColor = menuOn;
		}
		l_MenuOver = '';
	}
}

function clear_sub () {
	if (l_SubOver != '')
	{
		if (l_SubOver != l_SubDown)
		{
			document.all[l_SubOver].style.backgroundColor = subOn;
		}
		l_SubOver = '';
	}
}
function reset_all (iURL, iLayer_name){
	if (l_MenuDown != '') {
		document.all[l_MenuDown].style.backgroundColor = menuDown;
		l_MenuDown = '';
	}
	if (l_SubDown != '') {
		document.all[l_SubDown].style.backgroundColor = subDown;
		l_SubDown = '';
	}
	if (l_Sub != '') {
		document.all[l_Sub].style.visibility='hidden';
		l_Sub = '';
	}
	if (iLayer_name != '' && iURL != ''){
		document.all[iLayer_name].src = iURL;
	}

}

