
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}



var menus = new Array();
menus[0] = new Array('home','');


menus[1] = new Array('company','<table><tr><td width="25">&nbsp;</td><td><a href="../company/about_us.htm" class="submenulink">About Us</a></td><td width="10">&nbsp;</td><td><a href="../company/directions.htm" class="submenulink">Directions</a></td><td width="10">&nbsp;</td><td><a href="../company/contact.htm" class="submenulink">Contact</a></td></tr></table>');


menus[2] = new Array('services','<table><tr><td>&nbsp;</td><td><a href="../services/sampling.htm" class="submenulink">Sampling</a></td><td width="10">&nbsp;</td><td><a href="../services/remediation.htm" class="submenulink">Remediation</a></td><td width="10">&nbsp;</td><td><a href="../services/industrial.htm" class="submenulink">Industrial</a></td><td width="10">&nbsp;</td><td><a href="../services/pipeline.htm" class="submenulink">Pipeline</a></td><td width="10">&nbsp;</td><td><a href="../services/pm.htm" class="submenulink">Permit Management</a></td></tr></table>');


menus[3] = new Array('links','');



var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		for (var i=0;i < menus.length;i++){
			newImage('./../images/'+menus[i][0]+'_over.gif');
		}
		preloadFlag = true;
	}
}

function pop(menuname){
	for (var i=0;i < menus.length;i++){
		if(menus[i][0] == menuname){
    		document.getElementById(menus[i][0]).src = './../images/'+menus[i][0]+'_over.gif';
    		document.getElementById("submenu").innerHTML = menus[i][1];
    	}else{
        	document.getElementById(menus[i][0]).src = './../images/'+menus[i][0]+'.gif';
    	}
    	
    }
}

preloadImages();


//MOUSE OVER FUNCTIONS

var nowshowing = null;
var timerID = null;

function showpop(menuname){
  clearTimeout(timerID);
  if(menuname != nowshowing){
    if(nowshowing){
      document.getElementById(nowshowing+"pop").style.display = 'none';
      var menubutton = document.getElementById(nowshowing);
    }

    nowshowing = menuname
    document.getElementById(menuname+"pop").style.display = 'block';
    var menubutton = document.getElementById(nowshowing);
  }
}

function hidepop(){
    if(nowshowing){
      document.getElementById(nowshowing+"pop").style.display = 'none';
      var menubutton = document.getElementById(nowshowing);
      nowshowing = null;
    }
}



function domouseover(element) { 
  while(element){

    if (element.className == "poproot") {
      clearTimeout(timerID);
      showpop(element.id);
      return;
    }
    if (element.className == "pop") {
      showpop(element.id.substring(0,element.id.length-3));
      clearTimeout(timerID);
      return;
    } 
    element = element.parentNode;
  }

}


function domouseout(element) {
  while(element){
    if (element.className == "poproot" || element.className == "pop") {
      timerID = setTimeout("hidepop()", 500);
      return;
    }
    element = element.parentNode;
  }
}

// IE and MOZ have different style event handlers routines
// These stubs format them properly for the real functions above
function domouseoverMOZ(event) { 
  domouseover(event.target);
} 

function domouseoutMOZ(event) { 
  domouseout(event.target);
} 

function domouseoverIE() { 
  domouseover(event.srcElement);
}

function domouseoutIE() { 
  domouseout(event.srcElement);
}

// HOOK into appropriate events
document.onmouseover = domouseoverMOZ; 
document.onmouseout = domouseoutMOZ; 

if (document.all){ 
  document.onmouseover = domouseoverIE; 
  document.onmouseout = domouseoutIE;
}
