/* --- MOUSE OVER CODE --- */

over = new Array() 
out = new Array()

function imageHover(id) { 
	document.getElementById(id).src = over[id].src; 
} 
 
function imageReset(id) {
	if (typeof(activePages) != "undefined") {
		if (!activePages.inArray(id)) {
			document.getElementById(id).src = out[id].src;
		}
	} else {
		document.getElementById(id).src = out[id].src;
	}
} 

function highlightActivePages(ap) {
	if (ap.length > 0) {
		for (i = 0; i < ap.length; i++) {
			if (document.getElementById(ap[i]) != null) {
				document.getElementById(ap[i]).src = over[ap[i]].src;
			}
		}
	}
}

over["topNavHome"] = new Image()
over["topNavHome"].src = "/images/topNavHomeOn.gif" 
over["topNavAbout"] = new Image()
over["topNavAbout"].src = "/images/topNavAboutOn.gif" 
over["topNavTechnical"] = new Image()
over["topNavTechnical"].src = "/images/topNavTechnicalOn.gif" 
over["topNavLiterature"] = new Image()
over["topNavLiterature"].src = "/images/topNavLiteratureOn.gif" 
over["topNavCaseStudies"] = new Image()
over["topNavCaseStudies"].src = "/images/topNavCaseStudiesOn.gif" 
over["topNavNews"] = new Image()
over["topNavNews"].src = "/images/topNavNewsOn.gif" 
over["topNavEnvironment"] = new Image()
over["topNavEnvironment"].src = "/images/topNavEnvironmentOn.gif" 
over["topNavContact"] = new Image()
over["topNavContact"].src = "/images/topNavContactOn.gif" 

out["topNavHome"] = new Image()
out["topNavHome"].src = "/images/topNavHome.gif" 
out["topNavAbout"] = new Image()
out["topNavAbout"].src = "/images/topNavAbout.gif" 
out["topNavTechnical"] = new Image()
out["topNavTechnical"].src = "/images/topNavTechnical.gif" 
out["topNavLiterature"] = new Image()
out["topNavLiterature"].src = "/images/topNavLiterature.gif" 
out["topNavCaseStudies"] = new Image()
out["topNavCaseStudies"].src = "/images/topNavCaseStudies.gif" 
out["topNavNews"] = new Image()
out["topNavNews"].src = "/images/topNavNews.gif" 
out["topNavEnvironment"] = new Image()
out["topNavEnvironment"].src = "/images/topNavEnvironment.gif" 
out["topNavContact"] = new Image()
out["topNavContact"].src = "/images/topNavContact.gif" 

var lastDisplayedLayer = "";

/* --- SUBMENU DISPLAY CODE --- */
function showSubMenu(layerName) {
	if (typeof(delayTimer) != "undefined") {
		clearTimeout(delayTimer);
		if (lastDisplayedLayer != layerName) {
			hideSubMenu(lastDisplayedLayer);
		}
	}
	document.getElementById(layerName).style.display = "block";
	lastDisplayedLayer = layerName;
}

function delayHideSubMenu(layerName) {
	if (typeof(activeSubCat) != "undefined") {
		if (!activeSubCat.inArray(layerName)) {
			delayTimer = window.setTimeout("hideSubMenu('" + layerName + "')", 250);
		}
	} else {
		delayTimer = window.setTimeout("hideSubMenu('" + layerName + "')", 250);
	}
}

function hideSubMenu(layerName) {
	if (typeof(activeSubCat) != "undefined") {
		if (!activeSubCat.inArray(layerName)) {
			document.getElementById(layerName).style.display = "none";
		}
	} else {
		document.getElementById(layerName).style.display = "none";
	}
}

/* --- LEFT NAV SUB MENU CODE --- */
function toggleDiv (div) {
	var tempDiv = document.getElementById(div);
	if (tempDiv)
	{
		if (tempDiv.style.display == "block") {
			tempDiv.style.display = "none";
		} else {
			tempDiv.style.display = "block";
		}
	}
}

bulletArrowOpen = new Image()
bulletArrowOpen.src = "/images/bulletArrowOpen.gif" 
bulletArrowClosed = new Image()
bulletArrowClosed.src = "/images/bulletArrowClosed.gif" 

function toggleIcon (icon) {
	var tempImg = document.getElementById(icon);
	if (tempImg)
	{
		if (tempImg.src.indexOf("bulletArrowClosed.gif") != -1) {
			tempImg.src = bulletArrowOpen.src; 
		} else {
			tempImg.src = bulletArrowClosed.src; 
		}
	}
}

/* --- MISC DHTML FUNCTIONS --- */
plusIcon = new Image()
plusIcon.src = "/images/plusIcon.gif" 
minusIcon = new Image()
minusIcon.src = "/images/minusIcon.gif" 

function toggleListIcon (icon) {
	var tempImg = document.getElementById(icon);
	if (tempImg.src.indexOf("plusIcon.gif") != -1) {
		tempImg.src = minusIcon.src; 
	} else {
		tempImg.src = plusIcon.src; 
	}
}

function validate(what) {
    var errorMsg = "";
    
    var valid = false;
    for (var i = 0; i < what.interest.length && !valid; i++) {
        valid = what.interest[i].checked;
    }
    
    if (!valid) errorMsg += "Interest is required\n";
    
    if (what.name.value == "") errorMsg += "Name is required\n";
    if (what.company.value == "") errorMsg += "Company is required\n";
    if (what.state.value == "") errorMsg += "State is required\n";
    if (what.email.value == "") errorMsg += "E-mail address is required\n";
    if (what.phone.value == "") errorMsg += "Phone number is required\n";
    
    if (errorMsg.length > 0) {
        alert(errorMsg);
        return false;
    }
    return true;
}
