
// SCRIPT TO HIDE THEN REVEAL SUB NAV SMOOTHLY

// Stores sub nav in a variable
var objSubNav = document.getElementById("subNav");

// Sets sub nav display style to block
objSubNav.style.display = "block";

// Obtains the full height of the sub nav
var endHeight = objSubNav.offsetHeight;

// Sets sub nav display style to none
objSubNav.style.display = "none";

// Reduces displayed height of sub nav to zero
objSubNav.style.height = "0px";

// Sets increment by which to increase height
var step = endHeight / 25;

// Defines repeater interval globally
var repeaterID;

// Pause before revealing sub nav
var launchDelay = window.setTimeout("revealNav()", 600);

// Function to reveal sub nav
function revealNav()
{
	// Sets sub nav display style to block
	objSubNav.style.display = "block";

	// Incrementally adds height to displayed subnav
	repeaterID = window.setInterval('setHeight()', 3);
}

// Function to set height of sub nav, to be repeated until fully revealed 
function setHeight()
{
	// Obtains current displayed height of sub nav
	var currentHeight = parseFloat(objSubNav.offsetHeight);

	// Adjusts final increment to fit the desired height
	if ((currentHeight + step) > endHeight)
		step = endHeight - currentHeight;

	// Adds increment to the displayed height of the subnav
	objSubNav.style.height = (currentHeight + parseFloat(step)) + "px";

 	// Once sub nav is fully revealed...
	if (currentHeight + step >= endHeight)
	{
		// Repeater is cancelled
		window.clearInterval(repeaterID);

		// Sub nav height is set back to default so that it can scale with text size
		objSubNav.style.height = "";
	}
}

