/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var linkset = new Array()

linkset[0] = '<a href="index.php">Home</a>'
linkset[0] += '<a href="mission.php">Our Mission</a>'
linkset[0] += '<a href="press.php">Press Releases</a>'

linkset[1] = '<a href="about_us.php">About Us</a>'
linkset[1] += '<a href="idaho.php">Idaho Office</a>'
linkset[1] += '<a href="our_president.php">Our President</a>'
linkset[1] += '<a href="sean.php">Founder</a>'

linkset[2] = '<a href="projects.php">Projects</a>'
linkset[2] += '<a href="products.php">Products</a>'
linkset[2] += '<a href="capabilities.php">Capabilities</a>'
linkset[2] += '<a href="publications.php">Publications</a>'

var ie5 = document.all && !window.opera
var ns6 = document.getElementById

if (ie5 || ns6)
	document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest()
{
	return (document.compatMode && document.compatMode.indexOf("CSS") != -1)? document.documentElement : document.body
}

function showmenu(which, type)
{
	if (!document.all && !document.getElementById)
		return

	clearhidemenu()
	menuobj = ie5? document.all.popitmenu : document.getElementById("popitmenu")
	menuobj.innerHTML = which
	menuobj.style.width = 140 + 'px'
	menuobj.contentwidth = menuobj.offsetWidth
	menuobj.contentheight = menuobj.offsetHeight

	menuItem = ie5? document.all.homebtn : document.getElementById("homebtn")
	var position = findPos(menuItem)

	menuobj.style.left = position[0] + 140 + 'px'

	if (type == 0)
		menuobj.style.top = position[1] + 'px'
	else if (type == 1)
		menuobj.style.top = position[1] + 24 + 'px'
	else
		menuobj.style.top = position[1] + 48 + 'px'

	menuobj.style.visibility = "visible"
	return false
}

//http://www.quirksmode.org/js/findpos.html#
function findPos(obj)
{
	var curleft = curtop = 0;

	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop

		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}

	return [curleft,curtop];
}

function contains_ns6(a, b)
{
	//Determines if 1 element in contained in another - by Brainjar.com
	while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;

	return false;
}

function hidemenu()
{
	if (window.menuobj)
		menuobj.style.visibility = "hidden"
}

function dynamichide(e)
{
	if (ie5 && !menuobj.contains(e.toElement))
		hidemenu()
	else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))
		hidemenu()
}

function delayhidemenu()
{
	delayhide = setTimeout("hidemenu()", 10)
}

function clearhidemenu()
{
	if (window.delayhide)
		clearTimeout(delayhide)
}

if (ie5 || ns6)
	document.onclick = hidemenu