// JavaScript Document

var hideInt;
var hideMenuDuration = 100;
var scrollInt;
var menuWidth = 150;
var subWidth = 205;
var width;
var newWidth;
var lastMenu;


var a = document.getElementsByTagName("*")
//alert(a.length)
for( i=0; i<a.length;i++ )
{
	//alert(a.length)
	//if( a[i].className )
//	{
		if( a[i].className == 'nav' )
		{
			alert('yes')
			a[i].onmouseover = function()
			{
				
				if( document.getElementById('firstsub_'+this.id.split('_')[0]))
					document.getElementById('firstsub_'+this.id.split('_')[0]).style.display = 'block'
			}
			
			a[i].onmouseout = function()
			{
				if( document.getElementById('firstsub_'+this.id.split('_')[0]))
					document.getElementById('firstsub_'+this.id.split('_')[0]).style.display = 'none'
			}
		}
	//}
}
	



function menuOver(id)
{
	//alert(id)
	clearTimeout(hideInt);
	showTierMenu(id);
	if( document.getElementById('firstsub_'+lastMenu) && 'firstsub_'+lastMenu != 'firstsub_'+id )
	{
		document.getElementById('firstsub_'+lastMenu).style.display = "none"
	}
	lastMenu = id
	//alert(lastmenu)
}

function menuOut(id)
{
	hideInt = setTimeout( "hideTierMenu('"+id+"')",1000);
}

function showTierMenu(id)
{
	var navLink = document.getElementById('nav_'+id);
	var firstsub = document.getElementById('firstsub_'+id);
	var w = (id == 'firstsub_'+id) ? subWidth:menuWidth
	//alert(w)
	if(firstsub != null)
	{
		if( firstsub.style.display == "none" )
		{
			width = Math.ceil(w/2);
			newWidth = 0;
			firstsub.style.width = width + "px";
			firstsub.style.display = "block";
			scrollInt = setInterval( "slideMenu('"+id+"')",100 );
		}
	}
}

function hideTierMenu(id)
{
	//alert(id)
	var subnav = document.getElementById('firstsub_'+id);
	if(subnav != null)
	{
		subnav.style.display = "none";
		subnav.style.width = "1px";
	}
}

function slideMenu(id)
{
	//alert(id)
	var subnav = document.getElementById('firstsub_'+id);
	var w = (id == "subnav") ? subWidth:menuWidth
	width = subnav.offsetWidth;
	newWidth = Math.ceil(((w-width)/2)+width);
	subnav.style.width = newWidth + "px";
	if( newWidth == w ) clearInterval(scrollInt);
}