function swapImage(imageID, ext) {

	if (document.getElementById(imageID)) {
		document.getElementById(imageID).src = 'images/' + imageID + ext + '.gif';
	}
}

function swapClass(hrefID, ext) {
	if (document.getElementById(hrefID)) {
		if (ext == '') {
			document.getElementById(hrefID).style.backgroundColor = '#ffffff'
		} else {
			document.getElementById(hrefID).style.backgroundColor = '#FF9C00'
		}
	}
}
var activeMenu = null;
var activeSubMenu = null;


function getObjectWidth(thisObject) {
	if (self.innerWidth) {// all except Explorer
		return thisObject.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		return thisObject.clientWidth;
	} else if (document.body) { // other Explorers
		return thisObject.clientWidth;
	}
}

function initPage() {
	mbSet('mainMenu', 'mbv'); 
	document.getElementById('mainMenu').style.display = 'block'; 
	fixMenu();
}

function popupPhoto(thisFilename, thisWidth, thisHeight, thisDescription) {
	
	
	//var newWindow = window.open("popupphoto.asp?file_name=" + thisFilename + "&width=" + thisWidth + "&height=" + thisHeight + "&description=" + escape(thisDescription), "_blank", "width=" + thisWidth + ", height=" + thisHeight + ", resizable=1, fullscreen=0, status=yes, scrollbars=no, toolbar=0, location=0, directories=0, menubar=0");
	/*
	var currentX = window.screenLeft
	var currentTop = window.screenLeft
	var currentWidth = window.availWidth
	var currentHeight = window.availHeight
	
	document.documentElement.style.filter = "alpha(opacity=10)";
	document.documentElement.style.opacity = ".10";
	return false
	*/
	var newWindow = window.open("popupphotofs.asp?file_name=" + thisFilename + "&width=" + thisWidth + "&height=" + thisHeight + "&description=" + escape(thisDescription), "_blank", "resizable=1, fullscreen=0, status=yes, scrollbars=no, toolbar=0, location=0, directories=0, menubar=0");
	if (!newWindow) {
		alert("Your pop-up blocker has prevented the photo from being loaded.\nPlease allow pop-ups for this site!");
	}
	
} 
var ulArray = new Array();
function fixMenu() {
	/*
	windowHeight = document.documentElement.clientHeight;
	docHeight = document.getElementById("mainContentBorder").clientHeight;
	alert("windowHeight = " + windowHeight + "\ndocHeight = " + docHeight);
	alert("scroll = " + document.documentElement.scrollTop);
	*/
		
	for (loop = 0; loop < ulArray.length; loop ++) {
		var startElement = document.getElementById(ulArray[loop]);
	
		// move submenus that end below the document's end up
		submenuHeight = startElement.clientHeight
		startElementPosition = getPosition(startElement);
		//windowHeight = getDocHeight();
		if (window.innerHeight) { // for Mac safari (and also MZ a.o.)
			windowHeight = window.innerHeight + document.documentElement.scrollTop;
		} else { // for IE
			windowHeight = document.documentElement.clientHeight + document.documentElement.scrollTop;
		}
		docHeight = document.getElementById("mainContentBorder").clientHeight;
		
		if (windowHeight <  docHeight) {
			docHeight = windowHeight;
		}

		submenuEndY = startElementPosition.y + submenuHeight
		if (submenuEndY > docHeight) {
			startElementPosition = docHeight - submenuEndY - 18
			startElement.style.top = startElementPosition + "px";
		}


		
		var listElements = startElement.getElementsByTagName('a');
		var divElements = startElement.getElementsByTagName('div');
		var maxWidth = 0;
		for (i = 0; i < listElements.length; i ++) { // get the greatest width (used for IE only)
			//alert(divElements[i].offsetWidth)
			//break;
			if (getObjectWidth(listElements[i]) > maxWidth) {
				maxWidth = getObjectWidth(listElements[i]);
			}
		}
		
		if (maxWidth > 0) { // set the UL to the same width (MZ does this automatically)
			startElement.style.width = maxWidth + 'px';
		}
		var listElements = startElement.getElementsByTagName('ul');
		for (i = 0; i < listElements.length; i ++) { // set the subsubmenu to the right of the submenu
			listElements[i].style.left = (startElement.clientWidth + 2) + 'px';
		}
		
		
	}
	
}
