var NAV_OUT_TIMERS = [];
var NAV_POSES = [];
var NAV_ACTIVE = [];

function nav_hover(pos, inout)
{
	if (inout) {
		window.clearTimeout(NAV_OUT_TIMERS[pos]);

		if (NAV_ACTIVE[pos]) return;

		var ch = document.getElementById('subnav_'+pos).getElementsByTagName('a');
		var init = 0;
		if (typeof NAV_POSES[pos] != 'array') {
			NAV_POSES[pos] = [];
			init = 1;
		}
		for (var a in ch) {
			if (ch[a] && ch[a].style) {
				if (init) {
					NAV_POSES[pos][a] = ch[a].style.bottom.replace('px', '');
				}
				ch[a].style.bottom = '-20px';
				$('#'+ch[a].id).css('opacity', 0);
				$('#'+ch[a].id).css('display', 'block');
				NAV_ACTIVE[pos] = 1;
				$('#'+ch[a].id).animate({
					opacity: 1.0,
					bottom: NAV_POSES[pos][a]
				}, 500);
			}
		}


	}
	else {
		NAV_OUT_TIMERS[pos] = window.setTimeout('nav_fadeout('+pos+');', 200);
	}
}

function subnav_hover(pos, inout)
{
	if (inout) {
		window.clearTimeout(NAV_OUT_TIMERS[pos]);
	}
	else {
		NAV_OUT_TIMERS[pos] = window.setTimeout('nav_fadeout('+pos+');', 200);
	}
}

function nav_fadeout(pos)
{
	var ch = document.getElementById('subnav_'+pos).getElementsByTagName('a');
	for (var a in ch) {
		if (ch[a] && ch[a].style) {
			$('#'+ch[a].id).animate({
				opacity: 0,
			});
		}
	}

	window.setTimeout('NAV_ACTIVE['+pos+']=0;', 1000);
}

