/* define variables for "if n4 (Netscape 4), if IE and if N6 (if Netscape 6/W3C-DOM compliant)" */

var n4, ie, n6;

/* detecting browser support for certain key objects/methods and assembling a custom document object */

var doc, doc2, doc3, sty;

if (document.layers)
{
doc = "document.";
doc2 = ".document.";
doc3 = "";
sty = "";
n4 = true;
}

else if (document.all)
{
doc = "document.all.";
doc2 = "";
doc3 = "";
sty = ".style";
ie = true;
}

else if (document.getElementById) {
  doc = "document.getElementById('";
  doc2 ="')";
  doc3 ="')";
  sty = "').style";
  n6 = "true";
 }

//Function that shows or hides the dropdown menu
function showhide(elem,state) {
	docObj = eval(doc + elem + sty);
	docObj.visibility = state;

}


//Preload top navigation bar images
var loaded = false;

function preload() {
	contact_off = new Image();
	contact_off.src = "../pictures/contactoff.gif";
	//rollover image
	contact_on = new Image();
	contact_on.src = "../pictures/contacton.gif";

	about_off = new Image();
	about_off.src = "../pictures/aboutoff.gif";
	//rollover image
	about_on = new Image();
	about_on.src = "../pictures/abouton.gif";

	search_off = new Image();
	search_off.src = "../pictures/searchoff.gif";
	//rollover image
	search_on = new Image();
	search_on.src = "../pictures/searchon.gif";

	authors_off = new Image();
	authors_off.src = "../pictures/authorsoff.gif";
	//rollover image
	authors_on = new Image();
	authors_on.src = "../pictures/authorson.gif";

	//index button off
	index_off = new Image();
	index_off.src = "../pictures/indexoff.gif";
	//index button on
	index_on = new Image();
	index_on.src = "../pictures/indexon.gif";

	//current issue button off
	current_off = new Image();
	current_off.src = "../pictures/currentoff.gif";
	//current issue button of
	current_on = new Image();
	current_on.src = "../pictures/currenton.gif";

	//back issues button off
	back_off = new Image();
	back_off.src = "../pictures/backoff.gif";
	//back issues button on
	back_on = new Image();
	back_on.src = "../pictures/backon.gif";

	//resources button off
	resources_off = new Image();
	resources_off.src = "../pictures/resourcesoff.gif";
	//resources button on
	resources_on = new Image();
	resources_on.src = "../pictures/resourceson.gif";

	//tools button off
	tools_off = new Image();
	tools_off.src = "../pictures/toolsoff.gif";
	//tools button on
	tools_on = new Image();
	tools_on.src = "../pictures/toolson.gif";

	loaded = true;

}

//Image swapping function
function onoff (elemparent,elem,state) {
	if (loaded)
		{
		newstate = eval(elem +"_" + state);
		if (n4)
			{
			menuObj = eval (doc + elemparent + doc2 + elem);
			}
		else if (ie || n6)
			{
			menuObj = eval (doc + elem + doc2);
			}
		menuObj.src = newstate.src;
		}


}

/* variables that hold the value of the currently active (open) menu */

var active_submenu = null;
var active_menuelem = null;
var active_topelem = null;

//function that closes the submenus
function closeallmenus() {
	if(active_submenu != null) {
		showhide(active_submenu, 'hidden');

		}
	if (active_topelem != null)
		{
		onoff('topmenu',active_topelem,'off');
		}

	if (active_menuelem != null)
		{
		changecolor(active_menuelem,offcolor);
		}

	}


function controlsubmenu(submenu,menuelem,topelem) {
stopall();
closeallmenus();

if (submenu != null) {
  showhide(submenu,'visible');
  active_submenu = submenu;
  
  }
if (menuelem != null) {
 changecolor(menuelem,oncolor);
 active_menuelem = menuelem;
 }

if (topelem != null) {
  onoff('topmenu',topelem,'on');
  active_topelem = topelem;
 }
 
}




// the menu close timeout variable
var menu_close_timeout = 0;
//delay in milliseconds until the oopen mens are closed
var delay = 500;
//function calls the closeallmenus() function after a delay

function closeall() {
	menu_close_timeout = setTimeout('closeallmenus()',delay);
}

//stop all timeout functions (stops menus from closing)
function stopall() {
	clearTimeout(menu_close_timeout);
}

// mouse over (on) and mouseoff(off) color values
var oncolor = "#ff0033";
var offcolor = "#cc0033";

function changecolor(divname,colorname) {
stopall();
if (!n4) {
menuObj = eval(doc + divname + sty);
menuObj.backgroundColor = colorname;
  }
}


