// JavaScript Document


function waldenDropdown ( menuId)
	{
	// this function shows the submenu to the user
	this.hover = function ()
		{
		thisObj.menuList.style.display = "block";
		}
		
	// this function hides the submenu from the user
	this.mouseout = function ()
		{			
		thisObj.menuList.style.display = "none";
		}
		
	/////////////////////////////////////////////////////////
	// INITIALIZE THE  OBJECT:
	
	// declare a static, local instance of THIS for later use
	var thisObj = this;
	
	// grab the element that contains the menu and store it as a property of this object
	this.menuEl = document.getElementById( menuId );
	
	// find the UL that contains the actual drop-down and assign it to a property of this object
	//this.menuList = this.menuEl.childNodes[3];
	for( x2 = 0; x2 < this. menuEl.childNodes.length; x2++ )
		{
		if( this.menuEl.childNodes[x2].tagName && this.menuEl.childNodes[x2].tagName == "UL" )
			{
			this.menuList = this.menuEl.childNodes[x2];
			}
		}
	
	// hide the dropdown menus
	this.mouseout();
	
	// assign the hover event handler
	this.menuEl.onmouseover = this.hover;
	
	// assign the mouseout event handler
	this.menuEl.onmouseout = this.mouseout;
	}


function getElementsByClassName(classname, node) 
	{
	if( !node ) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for( var i=0,j=els.length; i<j; i++ )
		{
		if( re.test(els[i].className )) 
			{
			a.push(els[i]);
			}
		}
	return a;
	}

function init ()
	{
	menus = getElementsByClassName( "has_submenu" );
	for( x = 0, array_length = menus.length; x < array_length; x++ )
		{
		menus[x].waldenDropdownMenu = new waldenDropdown( menus[x].id );
		}
		
	// add the email address to the page
	add_email();
	}


window.onload = init;
