<!--// JavaScript Document
// Coded by Raleighvon.com
// This handles the lack of CSS Standard Compliant hover support for IE Win
// got this from listapart.com
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("navigation");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

// Mundi helped me with this
// This Aligns the subnavs to the div with the specified ID in var AlignToThis
function alignSubnav(){
	
	var AlignToThis = document.getElementById('navigation');
	var Subnav1 = document.getElementById('atlasSubnav');
    var Subnav2 = document.getElementById('atlasonlineSubnav');
	// var Subnav3 = document.getElementById('awardsSubnav');
	var Subnav4 = document.getElementById('linksSubnav');
	var Subnav5 = document.getElementById('shopSubnav');
	var Subnav6 = document.getElementById('bizSubnav');
	var Subnav7 = document.getElementById('aboutSubnav');
	var Subnav8 = document.getElementById('advertiseSubnav');
	var Subnav9 = document.getElementById('articlesSubnav');	
	var Subnav10 = document.getElementById('homeSubnav');	

	AlignToThisLeft = getLeft(AlignToThis);
	
	Subnav1.style.left = AlignToThisLeft+'px';
	Subnav2.style.left = AlignToThisLeft+'px';
        //Subnav2.style.left = 200+'px';
	// Subnav3.style.left = AlignToThisLeft+'px';
	Subnav4.style.left = AlignToThisLeft+'px';
	Subnav5.style.left = AlignToThisLeft+'px';
	// This aligns under IE but not under Mozilla
	//Subnav5.style.width = 300+'px';
	Subnav6.style.left = AlignToThisLeft+'px';
	//Subnav6.style.left = 240+'px';
	Subnav7.style.left = AlignToThisLeft+'px';
	//Subnav7.style.left = 240+'px';
	Subnav8.style.left = AlignToThisLeft+'px';
	Subnav9.style.left = AlignToThisLeft+'px';
	//Subnav9.style.left = 240+'px';
    Subnav10.style.left = AlignToThisLeft+'px';


//This is to fix for IE6's positioning which was commented out of secondary-nav.css
/*
	var browser=navigator.appName;
	var b_version=navigator.appVersion;

	if(browser.indexOf('Internet Explorer')!=-1 && b_version.indexOf('6')!=-1)
	{		
		Subnav1.style.top = 98+'px';
		Subnav2.style.top = 98+'px';
		// Subnav3.style.top = 98+'px';
		Subnav4.style.top = 98+'px';
		Subnav5.style.top = 98+'px';
		Subnav6.style.top = 98+'px';
		Subnav7.style.top = 98+'px';
		Subnav8.style.top = 98+'px';
		Subnav9.style.top = 98+'px';
		Subnav10.style.top = 98+'px';			
	}
*/
}

// The name says it all
function getLeft(obj){
	var left = obj.offsetLeft;
	var tempObj = obj.offsetParent;
	while (tempObj != null) {
		left += tempObj.offsetLeft;
		tempObj = tempObj.offsetParent;
	}
	return left;
}

// IE Mac wouldn't let me write 2 window.onload calls 
// So I consolidated them into  one Function
function triggerTwoFunctions() {
	alignSubnav();
	startList();
}

// Detect for IE Win
if (window.attachEvent) {
	window.attachEvent('onload', startList);
	window.attachEvent('onload', alignSubnav);
	window.attachEvent('onresize', alignSubnav)
// Detect for W3C Standards Compliant Browsers - 
// Oh how i love you standards compliant browsers
} else if (window.addEventListener){
	window.addEventListener('load', startList, false);
	window.addEventListener('load', alignSubnav, false);
	window.addEventListener('resize', alignSubnav, false);
// Mac IE - not sure what other browsers,
// Get a modern browser, ok?
} else {
	window.onload=triggerTwoFunctions;
	window.onresize=alignSubnav;
}
//-->
