var primaryNav;
var secondaryNav;
var activeTimeout = null;
var timeoutLength = 1000;

var sectionList = new Array('about','products','clients','expertise','contact');

function toggleVisibility(id, newVisibility) {
 	for (i = 0; i < sectionList.length; i++) {
    	var section = sectionList[i];
    	if (section == id) {
			var div = document.getElementById(id);
	
			//closing previous subnav
			if (primaryNav != null && primaryNav != id){
				secnavdiv = document.getElementById(primaryNav);
    			secnavdiv.style.visibility = 'hidden';		
			}
    		if (div != null) {
    			div.style.visibility = newVisibility;
    			primaryNav = id;	//remembers previous primary nav that was clicked
			}
		}
	}
}

function stopTimer() {
    if (activeTimeout != null) {
    clearTimeout(activeTimeout);
    }
}

function startTimer() {
    resetTimer();
}

function resetTimer() {
    stopTimer();
    activeTimeout = setTimeout("resetSubNav()", timeoutLength);
}

function resetSubNav() {
	toggleVisibility(primaryNav,'hidden');
}

/* This method opens a new popup window */
function popup(url, name, width, height){
	settings="toolbar=no,location=no,directories=no,"+
	"status=no,menubar=no,scrollbars=yes,"+
	"resizable=yes,width="+width+",height="+height;

	MyNewWindow=window.open(url,name,settings);
	MyNewWindow.focus()
}
