var sections = Array('about', 'products', 'industries', 'commitments', 'investor', 'careers', 'orderonline');

var off_images = Array();
var on_images = Array();

for(i = 0; i < sections.length; i++){
	off_images[sections[i]] = new Image();
	off_images[sections[i]].src = "/images/main_nav/" + sections[i].toLowerCase() + "_off.gif"

	on_images[sections[i]] = new Image();
	on_images[sections[i]].src = "/images/main_nav/" + sections[i].toLowerCase() + "_on.gif"
}
	
function image_mouseover(img, layer){
	img.src = on_images[layer].src;
}

function image_mouseout(img, layer){
		img.src = off_images[layer].src;
}
					
var state = "none"
var plus_or_minus = "+"

function showhide(layer_ref) {
	var state = 'block';
	var plus_or_minus = '&ndash;';
	
	var expander = document.getElementById(layer_ref + "Expand");
	
	// if it doesn't start with a '+' then hide what is below
	// and change to a '+'

	if (expander && ! expander.innerHTML.match(/^\+/)) {
		state = 'none'; 
		plus_or_minus = '+';
	} 

	document.getElementById(layer_ref).style.display = state;
	expander.innerHTML = expander.innerHTML.replace(/^./, plus_or_minus);
					
}

function expand(active) {
	if (active.id == "nav_top")
		return;
	
	// this is the first iteration if we were not passed a HTML element
	if (! active.nodeName)
		active = document.getElementById(active);
	
	// set the expander (if there is one) to use ndash
	if ( document.getElementById(active.id + 'Expand') )
		document.getElementById(active.id + 'Expand').innerHTML = '&ndash;'; 
	
	active.style.display = "block";
	expand(active.parentNode);
}

function number_sitemap () {
	var list = document.getElementById('map');
	number_list(list);
}

function number_list(list,base) {
	var itemcount = 1;
	list.style.listStyleType = 'none';
	for (var i=0; i < list.childNodes.length; i++) {
		var child = list.childNodes[i];
		
		if (child.nodeName == 'LI') {
			child.innerHTML =  itemcount + '&nbsp;' + child.innerHTML;
			
			if (base)
				child.innerHTML = base + "." + child.innerHTML;
				
			for (var j=0; j < child.childNodes.length; j++) {
				if ( child.childNodes[j].nodeName == 'OL' ) {
					var newbase;
					
					if ( base )
						newbase = base + "." + itemcount;
					else
						newbase = itemcount;
						
					number_list(child.childNodes[j], newbase);
				}
			}
			
			itemcount++;
		}
	}
}

// highlight the current link
function nav_setactive () {
	//return if we aren't on a page with the nav
	if (! document.getElementById('nav_top') )
		return;
	
	var links = document.getElementById('nav_top').getElementsByTagName('A');
	for (var i=0; i < links.length; i++ ) {
		if (links[i].href == document.URL || links[i].href.match(highlighturl)) {
			links[i].style.color = '#8E0000';
			return;
		}
	}
}

var highlighturl = null;

var do_on_load = new Array;
do_on_load.push(nav_setactive);

// show the navigation after we have set it up
do_on_load.push( function () { 
	if (document.getElementById('nav_contain')) {
		document.getElementById('nav_contain').style.visibility = 'visible';
	}
} );

window.onload = function () {
	for( var i=0; i < do_on_load.length; i++) {
		do_on_load[i]();
	}
};