var lastMenu = 'foo';
var lastTop;
var hide_with_delay;
var lastCal = 'foo';

// cross platform
if (document.layers) {
  visible = 'show';
  hidden = 'hide';
} else if (document.all) {
  visible = 'visible';
  hidden = 'hidden';
} else if (document.getElementById) {
  visible = 'visible';
  hidden = 'hidden';
}


function hideTimer() {
		hide_with_delay = setTimeout("hideLast()", 250);
}

function clearHider() {
	if (hide_with_delay) {
		clearTimeout(hide_with_delay);
	}
}

function hideLast() {
	// turn off old menu
    lastMenu.visibility = hidden;
    lastTop.visibility = hidden;
    lastMenu = 'foo';
}

function toggler(top, menu) {

// clear the Timeout
	if (hide_with_delay) {
		clearTimeout(hide_with_delay);
	}

	// Set popup to a browser specific value
	//
	if (document.layers) {
    	popup = document.layers[menu];
   	topup = document.layers[top];
	} else if (document.all) {
    	popup = document.all(menu).style;
    	topup = document.all(top).style;
	} else if (document.getElementById) {
    	popup = document.getElementById(menu).style;
    	topup = document.getElementById(top).style;
	}
	
    if (lastMenu != popup && lastMenu != 'foo') { 
    	// turn off old menu
		hideLast();
    }
    			
  	popup.visibility = visible;
	topup.visibility = visible;
	
    // set these variables for use next time
    lastMenu = popup;
    lastTop = topup;
}