var menuTDHeight = 20;
var lastChildDivHeight;
var lastParentDivID;
var lastChildDivID;

function ChangeHieght(ID, Sign, SubNum)
{
	try
	{
		var tempHeight = document.getElementById("div" + ID).style.height.substring(0, document.getElementById("div" + ID).style.height.length - 2);
		if(Sign == '+')
		{
			tempHeight = tempHeight * 1 + 1 * 1;
			document.getElementById("div" + ID).style.height = tempHeight + "px";
			if(tempHeight * 1 < menuTDHeight * SubNum)
			{
				expandMove = window.setTimeout("ChangeHieght('" + ID + "', '+', " + SubNum + ");", 0.000000000000000000000000000000000001);
			}
			else
			{
				document.getElementById("div" + ID).style.display = "block";
				document.getElementById("img" + ID).src = "images/wpm_menu_negative.gif";
			}
		}
		else
		{
			tempHeight = tempHeight * 1 - 1 * 1;
			document.getElementById("div" + ID).style.height = tempHeight + "px";
			if(tempHeight * 1 > 0)
			{
				expandMove = window.setTimeout("ChangeHieght('" + ID + "', '-', " + SubNum + ");", 0.000000000000000000000000000000000001);
			}
			else
			{
				document.getElementById("div" + ID).style.display = "none";
				document.getElementById("img" + ID).src = "images/wpm_menu_positive.gif";
			}
		}
	}
	catch(ex)
	{
	}
}

function ExpandMenu(ID, SubNum)
{
	try
	{
		if(lastChildDivHeight != null && lastChildDivHeight != 0)
		{
			ExpandMenu2(lastChildDivID.substring(3), lastChildDivHeight / menuTDHeight,  ID, SubNum)
			lastChildDivHeight = 0;
			ExpandMenu(ID, SubNum);
		}
		else
		{
			if(lastParentDivID != null && lastParentDivID != "div" + ID)
			{
				if (document.getElementById(lastParentDivID).style.display == "block")
				{
					ChangeHieght(lastParentDivID.substring(3), '-', SubNum);
				}
			}
			lastParentDivID = "div" + ID;

			if (document.getElementById("div" + ID).style.display == "block")
			{
				ChangeHieght(ID, '-', SubNum);
			}
			else
			{
				ChangeHieght(ID, '+', SubNum);
				document.getElementById("div" + ID).style.display = "block";
			}
		}
	}
	catch(ex)
	{
	}
}

function ChangeHieght2(ID, Sign, SubNum, parentID, SubParent)
{
	try
	{
		var tempHeight = document.getElementById("div" + ID).style.height.substring(0, document.getElementById("div" + ID).style.height.length - 2);
		var tempParentHeight = document.getElementById("div" + parentID).style.height.substring(0, document.getElementById("div" + parentID).style.height.length - 2);
		if(Sign == '+')
		{
			tempHeight = tempHeight * 1 + 1 * 1;
			tempParentHeight = tempParentHeight * 1 + 1 * 1
			document.getElementById("div" + ID).style.height = tempHeight + "px";
			document.getElementById("div" + parentID).style.height = tempParentHeight + "px";
			if(tempHeight * 1 < menuTDHeight * SubNum)
			{
				expandMove2 = window.setTimeout("ChangeHieght2('" + ID + "', '+', " + SubNum + ", '" + parentID + "', '" + SubParent + "');", 0.000000000000000000000000000000000001);
			}
			else
			{
				document.getElementById("div" + ID).style.display = "block";
				document.getElementById("img" + ID).src = "images/wpm_menu_negative.gif";
			}
			lastChildDivHeight = tempHeight;
		}
		else
		{
			tempHeight = tempHeight * 1 - 1 * 1;
			document.getElementById("div" + ID).style.height = tempHeight + "px";
			if(tempParentHeight * 1 - 1 * 1 > 2)
			{
				document.getElementById("div" + parentID).style.height = tempParentHeight * 1 - 1 * 1 + "px";
			}
			
			if(tempHeight * 1 > 0)
			{
				expandMove2 = window.setTimeout("ChangeHieght2('" + ID + "', '-', '" + SubNum + "', '" + parentID + "', '" + SubParent + "');", 0.000000000000000000000000000000000001);
			}
			else
			{
				document.getElementById("div" + ID).style.display = "none";
				document.getElementById("img" + ID).src = "images/wpm_menu_positive.gif";
			}
			lastChildDivHeight = 0;
		}
	}
	catch(ex)
	{
	}
}

function ExpandMenu2(ID, SubNum, parentID, SubParent)
{
	try
	{
		if(lastChildDivID != null && lastChildDivID != "div" + ID)
		{
			if (document.getElementById(lastChildDivID).style.display == "block")
			{
				ChangeHieght2(lastChildDivID.substring(3), '-', SubNum, parentID, SubParent);
			}
		}
		lastChildDivID = "div" + ID;

		if (document.getElementById("div" + ID).style.display == "block")
		{
			ChangeHieght2(ID, '-', SubNum, parentID, SubParent);
		}
		else
		{
			ChangeHieght2(ID, '+', SubNum, parentID, SubParent);
			document.getElementById("div" + ID).style.display = "block";
		}
		lastChildDivHeight = document.getElementById(lastChildDivID).style.height.substring(0, document.getElementById(lastChildDivID).style.height.length - 2);
	}
	catch(ex)
	{
	}
}
