bPreventExpand=0;
fullHeight=188;
minHeight = 25;
MenuSpeed = 50;

function narrowswitch_SDMenu(id)
	{
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	}

narrowswitch_SDMenu.prototype.init = function() 
	{
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		{
		this.submenus[i].getElementsByTagName("span")[0].onmouseover = function() 
			{
			mainInstance.expandMenu(this.parentNode,1);
			};
		this.submenus[i].getElementsByTagName("span")[1].onmouseover = function() 
			{
			mainInstance.expandMenu(this.parentNode.parentNode,1);
			};
		this.submenus[i].getElementsByTagName("span")[2].onmouseover = function() 
			{
			mainInstance.expandMenu(this.parentNode.parentNode,1);
			};
		};
	};

narrowswitch_SDMenu.prototype.expandMenu = function(submenu,bCollapseOthers) 
	{
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
		{
		if (bPreventExpand!=1)
			{
			bPreventExpand=1;
			var links = submenu.getElementsByTagName("a");
			var moveBy = Math.round(MenuSpeed * links.length);
			var mainInstance = this;
			
			var intId = setInterval(function() {
				var curHeight = submenu.offsetHeight;
				var newHeight = curHeight + moveBy;
				if (newHeight < fullHeight)
					{
					submenu.style.height = newHeight + "px";
					}
				else {
					submenu.style.height = fullHeight + "px";
					clearInterval(intId);
					submenu.className = "";
					bPreventExpand=0;
				}
			}, 20);
			if (bCollapseOthers==1)
				{
				this.collapseOthers(submenu);
				}
			}
		}
	else
		{
		submenu.style.height = fullHeight + "px";
		if (bCollapseOthers==1)
			{
			this.collapseOthers_Quick(submenu);
			}
		}
	};

narrowswitch_SDMenu.prototype.collapseMenu = function(submenu) 
	{
	var moveBy = Math.round(MenuSpeed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else 
			{
			submenu.style.height = minHeight + "px";
			clearInterval(intId);
			}
		}, 20);
	};

narrowswitch_SDMenu.prototype.collapseMenu_Quick = function(submenu) 
	{
	submenu.style.height =  minHeight + "px";
	};

narrowswitch_SDMenu.prototype.collapseOthers_Quick = function(submenu) 
	{
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i] != submenu)
				this.collapseMenu_Quick(this.submenus[i]);
	};

narrowswitch_SDMenu.prototype.collapseOthers = function(submenu) 
	{
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
	};
