// JavaScript Document

if (document.getElementById && document.getElementsByTagName && document.createTextNode) {	
	window.onload = initShowHide;  	
}

function initShowHide() {
			
			if (document.getElementById('project-list')) {	
				//call function in ajax-replace.js
				getLinks();
			}
	
	
			hide(); 
            var toggle = document.getElementById('nav'); 
            var as = toggle.getElementsByTagName('a');  
            for (var i = 0; i < as.length; i++) { 
                        as[i].onmouseover = function() { 
                                    show(this); 
                                    //return false; 
                        }
                     
                        as[i].onmouseout = function() { 
                                    window.setTimeout("hide(this)", timeout);
                                    return false; 
                        }
                        
                        as[i].onclick = function() { 
                                    show(this); 
                                    return true; 
                        }
            }
            
            var subNav = document.getElementById("subnav");
            var aSubNavs = subNav.getElementsByTagName("div");
            for (var i = 0; i < aSubNavs.length; i++) {
                        aSubNavs[i].onmouseover = function() {
                                    currSubNav = this;
                        };

                        aSubNavs[i].onmouseout = function() {
                                    currSubNav = null;
                                    window.setTimeout("hide()", 100);
                        };
            }           
}

var timeout = 30000;
var currSubNav = null;

function show(s) { 
            hide(); 
            var id = s.href.match(/#(\w.+)/)[1]; 
            document.getElementById(id).style.display = 'block'; 
}

function hide() {
            if (currSubNav == null) {
                        var toggleable = document.getElementById('subnav').getElementsByTagName('div'); 
                        for (var i = 0; i < toggleable.length; i++) { 
                                    toggleable[i].style.display = 'none'; 
                        }
            }
}


