var d = document;

function trHilite() {
	var tb = d.getElementsByTagName("tbody");
	if (tb) {
		for (b=0; b<tb.length; b++) {
			var rows = tb[b].getElementsByTagName("tr");
			for (r=0; r<rows.length; r++) {
				rows[r].onmouseover = function() {this.style.backgroundColor = "#EEE";};
				rows[r].onmouseout = function() {this.style.backgroundColor = "#FFF";};
			}
		}
	}
}

function toggleMap() {
	var mapDiv = document.getElementById("map");
	if (mapDiv) {
		var map = mapDiv.getElementsByTagName("img")[0];
		map.onclick = function() {window.open('images/map.gif','','width=425,height=425');};
		map.onmouseover = function() {this.style.cursor = "pointer";};
		map.onmouseout = function() {this.style.cursor = "default";};
	}
}

function initSearch() {
	var searchCriteria = document.getElementById('criteria');
	var searchButton = document.getElementById('submit-search');
	if (searchButton) {
		searchButton.onclick = function() {
			if (searchCriteria.value == '') {
				thePrompt = prompt('What would you like to search for?');
				location.href = 'search.cfm?criteria=' + thePrompt;
				return false;
			}
			
		};
	}
}

function init() {
	trHilite();
	toggleMap(); // contact page
	initSearch();
}

window.onload = init;
