/* GENERAL FUNCTIONS*/

var MENU_TIMEOUT = 200;

var d = detectMacXFF();

  
 /*this function is to detect if the user is on a MAC using the firefox browser.  There is a bug that doesn't allow the css opacity property*/
function detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}

function keepAlive() {
	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function hideDiv(nm) {
	document.getElementById(nm).style.display = 'none';
}


function showDiv(nm) {
	document.getElementById(nm).style.display = 'block';
	
}
/*the following function shows the flash_shield div and sets the style for the flash_shield div depending on whether the user is using Firefox on a MAC or not*/
function showFlashShield() {
	var yourShade = document.getElementById('flash_shield');

	if (d) {
		//osx ff css opacity + flash wmode transparent doesn't work
		yourShade.style.backgroundImage= "url(/images/flash_shield_mac.png)";
		yourShade.style.backgroundRepeat="repeat";
		yourShade.style.zIndex = 3; 
		yourShade.style.width = "423px"; 
		yourShade.style.height = "337px";
	   
	  } else {
		yourShade.style.backgroundColor = "#ffffff";
		yourShade.style.MozOpacity = .60;
		yourShade.style.opacity = .60;
		yourShade.style.filter = "alpha(opacity=60)";
		yourShade.style.zIndex = 3; 
		yourShade.style.width = "423px"; 
		yourShade.style.height = "337px"; 
	
	  }
	  
	showDiv('flash_shield');
}


function hideFlashShield() {
	hideDiv('flash_shield');
}

/*the following are functions for each item on the Main Nav that have subnavs*/

function showMenuCollections() {
	
	showDiv('menu_collections');
	
	hideDiv('menu_exhibitions');
	hideDiv('menu_events');
	hideDiv('menu_visiting');
	hideDiv('menu_about');
	hideDiv('menu_support');
}

function hideMenuCollections() {
	interval_id = setTimeout(timeOutMenuCollections, MENU_TIMEOUT);
}

function timeOutMenuCollections() {
	hideDiv('menu_collections');

	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function showMenuExhibitions() {
	
	showDiv('menu_exhibitions');

	hideDiv('menu_collections');
	hideDiv('menu_events');
	hideDiv('menu_visiting');
	hideDiv('menu_about');
	hideDiv('menu_support');
}

function hideMenuExhibitions() {
	interval_id = setTimeout(timeOutMenuExhibitions, MENU_TIMEOUT);
}

function timeOutMenuExhibitions() {
	hideDiv('menu_exhibitions');

	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function showMenuEvents() {
	
	showDiv('menu_events');

	hideDiv('menu_collections');
	hideDiv('menu_exhibitions');
	hideDiv('menu_visiting');
	hideDiv('menu_about');
	hideDiv('menu_support');
}

function hideMenuEvents() {
	interval_id = setTimeout(timeOutMenuEvents, MENU_TIMEOUT);
}

function timeOutMenuEvents() {
	hideDiv('menu_events');

	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function showMenuVisiting() {
	
	showDiv('menu_visiting');

	hideDiv('menu_events');
	hideDiv('menu_exhibitions');
	hideDiv('menu_collections');
	hideDiv('menu_about');
	hideDiv('menu_support');
}

function hideMenuVisiting() {
	interval_id = setTimeout(timeOutMenuVisiting, MENU_TIMEOUT);
}

function timeOutMenuVisiting() {
	hideDiv('menu_visiting');

	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function showMenuAbout() {
	
	showDiv('menu_about');

	hideDiv('menu_exhibitions');
	hideDiv('menu_events');
	hideDiv('menu_visiting');
	hideDiv('menu_collections');
	hideDiv('menu_support');
}

function hideMenuAbout() {
	interval_id = setTimeout(timeOutMenuAbout, MENU_TIMEOUT);
}

function timeOutMenuAbout() {
	hideDiv('menu_about');
	
	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}

function showMenuSupport() {
	
	showDiv('menu_support');

	hideDiv('menu_exhibitions');
	hideDiv('menu_events');
	hideDiv('menu_visiting');
	hideDiv('menu_collections');
	hideDiv('menu_about');
}

function hideMenuSupport() {
	interval_id = setTimeout(timeOutMenuSupport, MENU_TIMEOUT);
}

function timeOutMenuSupport() {
	hideDiv('menu_support');
	
	if (typeof(interval_id) != "undefined") {
		clearInterval(interval_id);
	}
}
