function changeClass(id, newClass) {
	identity=document.getElementById(id);
    if (identity != null) {   
	    identity.className=newClass;
    }
}		

var currentTopNav = 0;
var currentSubNav = 0;
var navTimer;
var subNavTimer;

isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;

function setActiveNav(idx) {
	if (isIE6) { return; }
	if (currentTopNav != idx) {
		changeClass('topNav' + currentTopNav, '');
		changeClass('topNav' + idx, 'active');
		currentTopNav = idx;
	}	
	if (currentSubNav != currentTopNav) {
		changeClass('subNav' + currentSubNav, 'hidden');
		navTimer = setTimeout("showSubNav()", 300);
	}
}

function setActiveNavNoSub(idx) {
	if (isIE6) { return; }
	if (currentTopNav != idx) {
		changeClass('topNav' + currentTopNav, '');
		changeClass('topNav' + idx, 'activeNoSub');
		currentTopNav = idx;
	}	
	if (currentSubNav != currentTopNav) {
		changeClass('subNav' + currentSubNav, 'hidden');
		currentSubNav = 0;
	}
}

function clearNavTimer() {
	if (isIE6) { return; }
	clearTimeout(navTimer);
}

function preserveSubNav() {
	if (isIE6) { return; }
	clearTimeout(subNavTimer);
}

function hideSubNav() {
	if (isIE6) { return; }
	subNavTimer = setTimeout("removeSubNav()", 250);
}

function removeSubNav() {
	if (isIE6) { return; }
	changeClass('subNav' + currentSubNav, 'hidden');
	currentSubNav = 0;	
}

function showSubNav() {
	if (isIE6) { return; }
	changeClass('subNav' + currentSubNav, 'hidden');
	changeClass('subNav' + currentTopNav, 'activeSubNav');
	currentSubNav = currentTopNav;
}
		