// JavaScript Document

var hideInt;
var hideMenuDuration = 100;
var scrollInt;
var menuWidth = 160;
var subWidth = 205;
var width;
var newWidth;
var lastMenu;
var thesub
var thetier
var newid

window.onload = init;

function init()
{
	var a = document.getElementsByTagName("DIV")
	
	for( i=0; i<a.length;i++ )
	{
		if( a[i].className )
		{
			if( a[i].className == 'nav2' )
			{
				a[i].onmouseover = function()
				{
					if( document.getElementById('sub_'+this.id.split('_')[0]))
						thesub = document.getElementById('sub_'+this.id.split('_')[0])
						thesub.style.display = 'block'
				}
				
				a[i].onmouseout = function()
				{
					if( document.getElementById('sub_'+this.id.split('_')[0]))
						thesub = document.getElementById('sub_'+this.id.split('_')[0])
						thesub.style.display = 'none'
						
				}
			}
			
			if(a[i].className == 'subtier' )
			{
				a[i].onmouseover = function()
				{
					newid = this.id.split('_')[1]
					thesub = document.getElementById('tier_'+newid)
					thesub.style.display = 'block'
				}
				
				a[i].onmouseout = function()
				{
					newid = this.id.split('_')[1]
					thesub = document.getElementById('tier_'+newid)
					thesub.style.display = 'none'
				}
			}
		}
	}
	
	
}

function menuOver(id)
{
	alert(id);
	clearTimeout(hideInt);
	showMenu(id);
	if( document.getElementById(lastMenu) && lastMenu != id )
	{
		document.getElementById(lastMenu).style.display = "block"
	}
	lastMenu = id
}

function menuOut(id)
{
	hideInt = setTimeout("hideMenu('"+id+"')",hideMenuDuration);
}

function showMenu(id)
{
	var navLink = document.getElementById(id+"Tag");
	var subNav = document.getElementById(id);
	var w = (id == "subnav") ? subWidth:menuWidth
	
	if( subnav.style.visibility == "hidden" )
	{
		width = Math.ceil(w/2);
		newWidth = 0;
		subnav.style.left = navLink.offsetLeft+"px";
		//alert( navLink.offsetLeft);
		subnav.style.width = width + "px";
		subnav.style.visibility = "visible";
		scrollInt = setInterval( "slideMenu('"+id+"')",50 );
	}
	//alert( navLink.offsetLeft );
}

function hideMenu(id)
{
	var subNav = document.getElementById(id);
	subNav.style.visibility = "hidden";
	subNav.style.width = "1px";
}

function slideMenu(id)
{
	var subnav = document.getElementById(id);
	var w = (id == "subnav") ? subWidth:menuWidth
	width = subnav.offsetWidth;
	newWidth = Math.ceil(((w-width)/2)+width);
	//var newWidth = subNav.offsetWidth + 20;
	subnav.style.width = newWidth + "px";
	if( newWidth == w ) clearInterval(scrollInt);
}