function changeDiv(the_div,the_change) {
	var the_style = getStyleObject(the_div);
	if (the_style != false) {
		the_style.display = the_change;
	}
}

function getStyleObject(objectId) {
	if (document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else {
		return false;
	}
}

var navDefault = null;
var navNowShowing = null;
var navTimer = null;

// set the default state
function setDefaultNav(subnavID){
	navDefault = subnavID;
	navShowNow(navDefault);
}

// on mouseover
function navShow(subnavID) {
	navHideNow();
	navShowNow(subnavID);
}

// on mouseout
function navHide(msec){
	// start a timer
	if(!msec){msec = 2000;}
	navTimer = setTimeout("navHideNow()", msec);	
}

function navHideNow(){
	// stop the timer
	if(navTimer){clearTimeout(navTimer);}
	navTimer = null;
	// hide the nav that is showing
	if(navNowShowing && navNowShowing != navDefault){
		changeDiv(navNowShowing, 'none');
	}
	// unhide the default nav
	if(navDefault){
		changeDiv(navDefault, 'inline');
	}
	navNowShowing = null;	
}

function navShowNow(subnavID){
	// stop the timer
	if(navTimer){clearTimeout(navTimer);}
	navTimer = null;
	// hide the default nav
	if(navDefault && subnavID != navDefault){
		changeDiv(navDefault, 'none');
	}
	// unhide the selected nav
	changeDiv(subnavID, 'inline');
	// keep track that this nav is now showing
	if(!navNowShowing){navNowShowing = subnavID};
}

