isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

// Initialize Variables
var disappearTime = new Array(); showTime = new Array();
var currentHeight = new Array(); currentWidth = new Array();
var width = new Array(); height = new Array();
var widthSpeed = new Array(); heightSpeed = new Array();

// Set initial variable values.
//		Speed: delay between layer resizes: less is faster.
//		WidthHeightSpeedBase: pixels resized every layer resize: less is smoother, but slower.
//			The two speeds are to be used in conjunction with each other for smoothness.
//		DelayTime: before beginning to hide a menu, it stays open for this number of milliseconds.
//			This is to allow the viewer to make a choice before the menu fades away.
var speed = 15; widthHeightSpeedBase=10; delayTime=300;

function initMenuSize(menuText,menuNum) {
  if ( isIE5 || isNS6 ) {
	// Generic width/height in pixels per menu.  Used in respective speed calculations.
	menu = document.getElementById(menuText+""+menuNum);
	width[menuNum]=parseInt(menu.offsetWidth);
	height[menuNum]=parseInt(menu.offsetHeight);

	menu.style.width="0px";
	menu.style.height="0px";

	// Assuming your layers are named as follows: pop1, hmm2, sds3
	//	They must end with a number.  The word is irrellevant, it is specified in your mouseOver/mouseOut.
	//  What is important is that each number is unique
	currentWidth[menuNum]=1; currentHeight[menuNum]=1;
	if ( width[menuNum] < height[menuNum] ) {
		widthSpeed[menuNum]=widthHeightSpeedBase;
		heightSpeed[menuNum]=(height[menuNum]/width[menuNum])*widthSpeed[menuNum];
	} else {
		heightSpeed[menuNum]=widthHeightSpeedBase;
		widthSpeed[menuNum]=(width[menuNum]/height[menuNum])*heightSpeed[menuNum];
	}
  }
}

function showMenu(menuText,menuNum) {
	if (isIE5 || isNS6 ) {
		clearTimeout(disappearTime[menuNum]);
		slideMenu("in",menuText,menuNum);
	}
}

function hideMenu(menuText,menuNum) {
	if (isIE5 || isNS6) {
		disappearTime[menuNum] = window.setTimeout("slideMenu('out','"+menuText+"',"+menuNum+")",delayTime);
	}
}

function slideMenu(inOut,menuText,menuNum) {
	if ( isIE5 || isNS6 ) {
		var menuId=menuText+""+menuNum;
		menu = document.getElementById(menuId);
		menu.style.visibility="visible";
		if ( inOut=="in" ) {
			if ( (currentHeight[menuNum] > height[menuNum]-(widthHeightSpeedBase+1)) ) {
				currentWidth[menuNum]=width[menuNum]; currentHeight[menuNum]=height[menuNum];
				menu.style.width=width[menuNum]+"px";
				menu.style.height=height[menuNum]+"px";
			} else {
				currentWidth[menuNum]+=widthSpeed[menuNum];
				currentHeight[menuNum]+=heightSpeed[menuNum];
				menu.style.width=Math.floor(currentWidth[menuNum])+"px";
				menu.style.height=Math.floor(currentHeight[menuNum])+"px";
				showTime[menuNum] = window.setTimeout("slideMenu('in','"+menuText+"',"+menuNum+")",speed);
			}
		} else {
			clearTimeout(showTime[menuNum]);
			if ( (currentHeight[menuNum] < (widthHeightSpeedBase+1)) ) {
				currentWidth[menuNum]=1; currentHeight[menuNum]=1;
				menu.style.width="1px";
				menu.style.height="1px";
				menu.style.visibility="hidden";
			} else {
				//currentWidth[menuNum]-=widthSpeed[menuNum];
				currentHeight[menuNum]-=heightSpeed[menuNum];
				if ( currentWidth[menuNum] >= 1 ) { menu.style.width=Math.floor(currentWidth[menuNum])+"px"; }
				if ( currentHeight[menuNum] >= 1 ) { menu.style.height=Math.floor(currentHeight[menuNum])+"px"; }
				disappearTime[menuNum] = window.setTimeout("slideMenu('out','"+menuText+"',"+menuNum+")",speed);
			}
		}
	}
}




