//initialize array of secondary menus and primary menu elements
var menus = ['menu_about','nav_about','menu_global','nav_global','menu_offerings','nav_offerings','menu_ir','nav_ir','menu_news','nav_news'];
var addl_ie_menu_fix = ['nav_right_section','product_list'];
var utime = null;

function startList() {
	if (document.all&&document.getElementById) {
	for (j=0; j<(menus.length-1); j+=2) {
		navSecond = document.getElementById(menus[j]);
		if(navSecond != null) {
			navRoot = navSecond.childNodes[0];
			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", "");
					}
				}
		  	}
		}
	}

	for (j=0; j<addl_ie_menu_fix.length; j++) {
		navRoot = document.getElementById(addl_ie_menu_fix[j]);
		if(navRoot != null) {
			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", "");
					}
				}
		  	}
		}
	}
 	}
}

function showhide(menu) {
	clearTimeout(utime);
	for (j=0; j<(menus.length-1); j+=2) {
		selected_menu = menus[j];
		selected = menus[j+1];
		if(menu == selected_menu) {
			offOn(selected_menu,selected,'visible','#CC731A'); //color primary tab and show secondary tab
		} else {
			offOn(selected_menu,selected,'hidden','#B96A1B');
		}
	}
}

function closemenus(menu_close) {
	var expr = "showhide('" + menu_close + "')";
	utime = setTimeout(expr,750);
}

function offOn() {
	args = offOn.arguments;
	for (i=0; i<(args.length-1); i+=4) {
		cycle_menu = args[i];
		cycle_tab = args[i+1];
		state_menu = args[i+2];
		state_tab = args[i+3];
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			eval( "document.all." + cycle_menu + ".style.visibility = state_menu");
			eval( "document.all." + cycle_tab + ".style.background = state_tab");
		}
		if (document.layers) { //IS NETSCAPE 4 or below
			document.layers[cycle_menu].visibility = state_menu;
			document.layers[cycle_tab].background = state_tab;
		}
		if (document.getElementById && !document.all) {
			maxwell_smart = document.getElementById(cycle_menu);
			maxwell_smart.style.visibility = state_menu;
			maxwell_smart2 = document.getElementById(cycle_tab);
			maxwell_smart2.style.background = state_tab;
		}
	}
}


function setFooter() {
	var minFooter = 550;
	var objFooter = new getObj('menu_footer');
	var objContent = new getObj('content_container');
	offsetFooter = findPosY(objFooter.obj);
	if (offsetFooter < minFooter) {
		objContent.style.height = minFooter-30 + 'px';
	}
}

function getObj(name) {
if (document.getElementById) {
	   this.obj = document.getElementById(name);
	   //this.style = document.getElementById(name).style;
	} else if (document.all) {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
	} else if (document.layers) {
	   if (document.layers[name]) {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   } else {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

function findPosY(obj) {
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}
