var aboutNavMenuVisible = false;
var servicesNavMenuVisible = false;
var galleryNavMenuVisible = false;
var walkthroughNavMenuVisible = false;

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setMenusInvisible() {
	document.getElementById("aboutNavMenu").style.display="none";
	aboutNavMenuVisible = false;
	
	document.getElementById("servicesNavMenu").style.display="none";
	servicesNavMenuVisible = false;
	
	//document.getElementById("galleryNavMenu").style.display="none";
	//galleryNavMenuVisible = false;

	document.getElementById("walkthroughNavMenu").style.display="none";
	walkthroughNavMenuVisible = false;
}



var thisMenuOpacity = 0;
var thisMenuOpacityIE = 0;
var thisIntervalID = 0;
function menuFadeIn() {
	window.thisMenuOpacity += 0.025;
	thisMenuOpacityIE = "alpha(opacity=" + (thisMenuOpacity * 100) + ")";
	if (thisMenuOpacity > 1) { clearInterval(thisIntervalID); }
	else { 
		if (aboutNavMenuVisible) { 
			document.getElementById('aboutNavMenu').style.opacity = thisMenuOpacity; 
			document.getElementById('aboutNavMenu').style.filter = thisMenuOpacityIE;
		} else if (servicesNavMenuVisible) { 
			document.getElementById('servicesNavMenu').style.opacity = thisMenuOpacity;
			document.getElementById('servicesNavMenu').style.filter = thisMenuOpacityIE;
		//} else if (galleryNavMenuVisible) { 
		//	document.getElementById('galleryNavMenu').style.opacity = thisMenuOpacity;
		//	document.getElementById('galleryNavMenu').style.filter = thisMenuOpacityIE;
		} else if (walkthroughNavMenuVisible) { 
			document.getElementById('walkthroughNavMenu').style.opacity = thisMenuOpacity;
			document.getElementById('walkthroughNavMenu').style.filter = thisMenuOpacityIE;
		}
	}
}

function toggleMenuVisibility(menuitem) {
	clearInterval(thisIntervalID);
	aboutNavMenuVisible = false;
	servicesNavMenuVisible = false;
	galleryNavMenuVisible = false;
	walkthroughNavMenuVisible = false;
	thisMenuOpacity = 0;
	thisMenuOpacityIE = "alpha(opacity=0)";

	if (menuitem) {
		if (menuitem == "about") { aboutNavMenuVisible = true; }
		else if (menuitem == "services") { servicesNavMenuVisible = true; }
		else if (menuitem == "gallery") { galleryNavMenuVisible = true; }
		else if (menuitem == "walkthrough") { walkthroughNavMenuVisible = true; }
	}
	if (aboutNavMenuVisible) { 
		document.getElementById("aboutNavMenu").style.zoom = 1; // Because IE is horrible 
		document.getElementById("aboutNavMenu").style.opacity = thisMenuOpacity;
		document.getElementById("aboutNavMenu").style.filter = thisMenuOpacityIE;
		document.getElementById("aboutNavMenu").style.display = "block"; 
		thisIntervalID = setInterval("menuFadeIn()",50);
	} else { document.getElementById("aboutNavMenu").style.display = "none"; }
	
	if (servicesNavMenuVisible) {
		document.getElementById("servicesNavMenu").style.zoom = 1;
		document.getElementById("servicesNavMenu").style.opacity = thisMenuOpacity;
		document.getElementById("servicesNavMenu").style.filter = thisMenuOpacityIE;
		document.getElementById("servicesNavMenu").style.display = "block"; 
		thisIntervalID = setInterval("menuFadeIn()",50);	
	} else { document.getElementById("servicesNavMenu").style.display = "none"; }
	
	/*if (galleryNavMenuVisible) {
		document.getElementById("galleryNavMenu").style.zoom = 1; // Because IE is horrible 
		document.getElementById("galleryNavMenu").style.opacity = thisMenuOpacity;
		document.getElementById("galleryNavMenu").style.filter = thisMenuOpacityIE;
		document.getElementById("galleryNavMenu").style.display = "block"; 
		thisIntervalID = setInterval("menuFadeIn()",50);
	} else { document.getElementById("galleryNavMenu").style.display = "none"; }
	*/
	
	if (walkthroughNavMenuVisible) {
		document.getElementById("walkthroughNavMenu").style.zoom = 1;
		document.getElementById("walkthroughNavMenu").style.opacity = thisMenuOpacity;
		document.getElementById("walkthroughNavMenu").style.filter = thisMenuOpacityIE;
		document.getElementById("walkthroughNavMenu").style.display = "block"; 
		thisIntervalID = setInterval("menuFadeIn()",50);	
	} else { document.getElementById("walkthroughNavMenu").style.display = "none"; }
	if (menuitem == "contact" || menuitem == "home") { return(true); } // Tell browser to follow link
	return(false);
}

function initialize(location) {
	MM_preloadImages('images/navbar/home-over.gif',
					 'images/navbar/about-over.gif',
					 'images/navbar/walkthrough-over.gif',
					 'images/navbar/photogallery-over.gif',
					 'images/navbar/services-over.gif',
					 'images/navbar/contact-over.gif',
					 'images/navbar/ttm-over.gif',
					 'images/navbar/certs-over.gif');
	
}
