// JavaScript Document

var timeout = null;
var timeout2 = null;
//var objects = new Array('manufacturing', 'glorytrain', 'hilltopper', 'magazine', 'promise');
var objects = new Array('manufacturing', 'glorytrain', 'magazine', 'promise');

// this function shows the drop down menu passed
function showMenu(obj) {
  if (timeout != null) {
	clearTimeout(timeout);
	for (i = 0; i < objects.length; i++) {
	  delayMenuHide(objects[i]);
	}
  }
  main_obj = findObj(obj).style;
  sub_obj = findObj('sub_' + obj).style;
  main_obj.backgroundColor = '#990000';
  sub_obj.visibility = 'visible';
  if (obj == 'manufacturing') {
	main_obj.backgroundImage = 'url(/images/layout/nav_bg2.jpg)';  
  }
}


// this function hides the menu after a half second delay
function hideMenu(obj) {
  timeout = setTimeout("delayMenuHide('" + obj + "')", 500);
}


// this is the function that actually hides the menu
function delayMenuHide(obj) {
  main_obj = findObj(obj).style;
  sub_obj = findObj('sub_' + obj).style;
  main_obj.backgroundColor = '#49587C';
  sub_obj.visibility = 'hidden';
  if (obj == 'manufacturing') {
	main_obj.backgroundImage = 'url(/images/layout/nav_bg.jpg)';  
  }
}



// Example: obj = findObj("image1");

function findObj(theObj, theDoc) {
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}