﻿function navClick(obj)
{
	dobj = document.getElementById("main");
	if (dobj.offsetHeight)
	{
		currentObj = obj;
		currentLink = obj.href;
		obj.href = "javascript:void(0)";
		collapseContent();
	}
}

stepSize = 10;
stepDelay = 15;
documentScale = 1;
currentObj = null;
currentLink = "";

function collapseContent(currentHeightPx)
{
	dobj = document.getElementById("main");

	if (!currentHeightPx)
	{
		refObj = document.getElementById("imgLogoText");
		documentScale = refObj.offsetWidth/473;

		currentHeightPx = (dobj.offsetHeight-5) / documentScale;
	}

	dobj.style.overflow = "hidden";
	
	if (currentHeightPx >= stepSize) 
	{
		currentHeightPx -= stepSize;
		dobj.style.height = currentHeightPx*(1/16) + "em";
		window.setTimeout("collapseContent(" + currentHeightPx + ")", stepDelay);
	}
	else
	{
		location.href = currentLink;
	}
	
}
function expandContent(currentHeightPx, expandedHeightPx)
{
	dobj = document.getElementById("main");
	if (!currentHeightPx)
	{
		dobj.style.visibility = "hidden";
		dobj.style.overflow = "hidden";
		dobj.style.height = "auto";
		
		refObj = document.getElementById("imgLogoText");
		documentScale = refObj.offsetWidth/473;
		currentHeightPx = 0;

		expandedHeightPx = dobj.offsetHeight / documentScale;
		//alert(documentScale + " , " + expandedHeightPx);
		if (expandedHeightPx < 280) expandedHeightPx = 280;

		dobj.style.visibility = "visible";

	}
	if (currentHeightPx < expandedHeightPx)
	{
		currentHeightPx += stepSize;
		dobj.style.height = currentHeightPx*(1/16) + "em";
		window.setTimeout("expandContent(" + currentHeightPx + ", " + expandedHeightPx + ")", stepDelay);
	}
	else
	{
		dobj.style.height = expandedHeightPx*(1/16) + "em";
	}
}
