var currentsubmenu = "sub0";
var menutest = "";
var menulocation = "";
var submenulocation = new String(top.location);

var AllowSubMenus = 0;
var ActiveMenu = "";

window.onerror = ErrorTrap;

submenulocation = submenulocation.split('com/')[1];
submenulocation = submenulocation.split('.')[0];

menutest = "home location missionstatement requestsandmessages contactus careers";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "home"; 
}

menutest = "controlsystems systemarchitecture plc hmi designandcad simulation documentation";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "controlsystems"; 
}

menutest = "informationsystems systemdesign databasedesign software reports dataacquisition batchcontrol";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "informationsystems"; 
}

menutest = "industrialcontrolpanels";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "industrialcontrolpanels"; 
}

menutest = "industryexperience affiliations processskills technologyskills customercomments";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "industryexperience"; 
}

menutest = "projectsuccess customerservice projecttracking fastturnaround structuredapproach";
if (menutest.indexOf(submenulocation) != -1) {
	menulocation = "projectsuccess"; 
}

menutest = "home controlsystems informationsystems industrialcontrolpanels industryexperience projectsuccess";
if (menutest.indexOf(submenulocation) != -1) {
	submenulocation = "0"; 
}

function preloadimages() {
	SetCurrentMenu();
		
	preloadimage('buttons/home2.gif');
	preloadimage('buttons/controlsystems2.gif');
	preloadimage('buttons/informationsystems2.gif');
	preloadimage('buttons/industrialcontrolpanels2.gif');
	preloadimage('buttons/industryexperience2.gif');
	preloadimage('buttons/projectsuccess2.gif');
}

function preloadimage() { 
  var d=document; 
  if(d.images){ 
		if(!d.imagearray) d.imagearray=new Array();
  
		var i,j=d.imagearray.length,a=preloadimage.arguments; 
		for(i=0; i<a.length; i++) {
			d.imagearray[j]=new Image; 
			d.imagearray[j++].src=a[i];
		}
  }
}

function SetCurrentMenu() { 
	swapimage(menulocation + "button","buttons/" + menulocation + "3.gif");
}

function swapimage(n,p) { 
	if (document[n]) {
		if (((n.substring(0,menulocation.length) == menulocation) && (p.substring(p.length-5,p.length-4) == "1")) || ((n.substring(0,submenulocation.length) == submenulocation) && (p.substring(p.length-5,p.length-4) == "1"))) {
			document[n].src = p.substring(0,p.length-5) + "3.gif";
		} else {
			if (n.substring(0,menulocation.length) != menulocation) {
				document[n].src = p;
			} else {
				document[n].src = p.substring(0,p.length-5) + "3.gif";
			}
		}
  }
}

function SetAllowSubMenus() {
	AllowSubMenus = 1;
}

function SubMenuOn(id) {
	ActiveMenu = id;
	
	//if (AllowSubMenus == 1) top.bodycontent.SubMenuOn(id);
	
	if (document.layers){
	   //Netscape 4 specific code
	   if (top.bodycontent.document.subprojectsuccess) top.bodycontent.SubMenuOn(id);
	}
	if (document.getElementById){
	   //Netscape 6 specific code
	   if (top.bodycontent.document.getElementById("subprojectsuccess")) top.bodycontent.SubMenuOn(id);
	}
	if (document.all){
	   //IE4+ specific code
	   if (top.bodycontent.document.all.subprojectsuccess) top.bodycontent.SubMenuOn(id);
	}
}

function SubMenuOffWithDelay(factor) {
	//if (AllowSubMenus == 1) 
	top.bodycontent.SubMenuOffWithDelay(factor);	
}

function ErrorTrap(msg, url, line) {
  return true;
}
