/*
Show menus using dynamic html.

Inspired by cbdhtml.js Copyright 1998, 1999 by Mike Hall.

Updated to handle Netscape 6
*/

// handles to the visible menus
var menuDepth = 6;
menuHandle = new Array(menuDepth);
for (i=0; i<menuDepth; i++) menuHandle[i] = null;

// create a menu
function createMenu(
level, // menu depth level
name, // name of the menu
left, top, // absolute location
width, height, // size of the menu
content) // contents of the menu
{
  drawMenu(level,name,left,top,width,height,content);
  menuHandle[level]=getHandle(name);
//  clipHandle(menuHandle[level],width,height);
}

// show a menu
function showMenu(level,name)
{
  hideMenu(level);
  menuHandle[level]=getHandle(name);
  showHandle(level,menuHandle[level]);
}

// hide the current menus at and above a certain level
function hideMenu(level)
{
  var i;
  for (i=level; i<menuDepth; i++)
  {
	if (menuHandle[i]) hideHandle(menuHandle[i]);
  }
}

// hide the menus if we are going in another table cell
function outsideMenu(level)
{
  // Internet Explorer or Netscape 6
  if (document.all || document.getElementById) hideMenu(level);
}

// menu utility functions

// draw a menu
function drawMenu(
level, // menu depth level
name, // name of the menu
left, top, // absolute location
width, height, // size of the menu
content) // contents of the menu
{
  // Netcape 4
  if (document.layers)
  {
	document.writeln('<layer name="' + name +
	 '" left=' + left + ' top=' + top +
	 ' width=' + width + ' height=' + height + ' bgcolor="#000066"' +
	 ' visibility="hide" z-index=2 onMouseOut="hideMenu(' + level + ')">');
	document.writeln(content);
	document.writeln('</layer>');
  }
  // Internet Explorer or Netscape 6
  else if (document.all || document.getElementById)
  {
	document.writeln('<div id="' + name +
	 '" style="position:absolute; overflow:none; left:' + left +
	 'px; top:' + top + 'px; width:' + width + 'px; height:' + height +
	 'px; visibility:hidden; z-index:2;' +
	 'background-color:#000066; font-size: 10px">');
	document.writeln(content);
	document.writeln('</div>');
  }
}

// get the handle for a given name
function getHandle(name)
{
  // Netcape 4
  if (document.layers) return document.layers[name];
  // Internet Explorer
  else if (document.all) return eval('document.all.' + name + '.style');
  // Netcape 6
  else if (document.getElementById) return document.getElementById(name)
}

// show the handle
function showHandle(level,handle)
{
  // Netcape 4
  if (document.layers && level==0) handle.visibility = "show";
  // Internet Explorer
  else if (document.all) handle.visibility = "visible";
  // Netcape 6
  else if (document.getElementById) handle.style.visibility = "visible";
}

// hide the handle
function hideHandle(handle)
{
  // Netcape 4
  if (document.layers) handle.visibility = "hide";
  // Internet Explorer
  else if (document.all) handle.visibility = "hidden";
  // Netcape 6
  else if (document.getElementById) handle.style.visibility = "hidden";
}

// sets clipping for a menu
function clipHandle(handle,width, height)
{
  // Netcape 4
  if (document.layers)
  {
	handle.width = width;
	handle.height = height;
	handle.clip.left   = 0;
	handle.clip.top    = 0;
	handle.clip.right  = width;
	handle.clip.bottom = height;
  }
  // Internet Explorer
  else if (document.all)
    handle.clip = 'rect(0 ' +  width + ' ' + height + ' 0)';
  // Netscape 6
  else if (document.getElementById)
    handle.style.clip = 'rect(0 ' +  width + ' ' + height + ' 0)';
}

// put a bigger picture right in the corner

function cornerPic()
{
  // Netcape 4
  if (document.layers)
  {
	document.writeln('<layer left=0 top=0 z-index=3 visibility="show"'
	+ ' width=158 height=119>');
	document.writeln('<a href="http://www.eng.fsu.edu/home.php"'
	+ ' onMouseOver="hideMenu(0)"><img'
	+ ' src="http://www.eng.fsu.edu/me/img/coe_bldg.jpg"');
	document.writeln(' width=158 height=119 border=0></a>');
	document.writeln('</layer>');
  }
  // Internet Explorer or Netscape 6
  else if (document.all || document.getElementById)
  {
	document.writeln('<div style="position:absolute; overflow:none;'
	+ ' left:0px; top:0px; width:0px visibility:hidden; z-index:2">');
	document.writeln('<a href="http://www.eng.fsu.edu/me/"'
	+ ' onMouseOver="hideMenu(0)"><img'
	+ ' src="http://www.eng.fsu.edu/me/img/coe_bldg.jpg"');
	document.writeln(' width=158 height=119 border=0></a>');
	document.writeln('</div>');
  }

  // For Internet Explorer, put a drop shadow on the header
  if (document.all)
  {
	if (document.all.tags("H1").item(0))
	{
		document.all.tags("H1").item(0).contentEditable='true';
		document.all.tags("H1").item(0).style.filter=
		"DropShadow(Offx=2,Offy=3,Color='#BBBBBB')";
	}
  }
}
