/*
	Copyright (c) 2004 Ned Martin
	http://copyright.the-i.org/
	Unless otherwise stated.

	JavaScript for nedmartin.org/
*/

// modified from http://www.alistapart.com/articles/dropdowns/
// shows hidden nested list menus

function menuShow(li)
{
	// IE only
	if (document.all && document.getElementById)
	{
		li.className += " show";
	}
} // end menuShow

function menuHide(li)
{
	// IE only
	if (document.all && document.getElementById)
	{
		li.className = li.className.replace(" show", "");
	}
} // end menuHide

menuList = function()
{
	// IE only
	if (document.all && document.getElementById)
	{
		// get div.menu
		divMenu = document.getElementById("menu");

		// loop through all child elements of div.menu
		for (i = 0; i < divMenu.childNodes.length; i++)
		{
			ulNode = divMenu.childNodes[i];

			// if the element is ul
			if (ulNode.nodeName=="UL")
			{
				// loop through all child nodes of div.menu ul
				for (j = 0; j < ulNode.childNodes.length; j++)
				{
					node = ulNode.childNodes[j];

					// if the node is a div.menu ul li
					if (node.nodeName=="LI")
					{
						// add mouse events
						node.onmouseover = function()
						{
							this.className += " show";
						}
						node.onmouseout=function()
						{
							this.className=this.className.replace(" show", "");
						}
					}
				}
			}
		}
	}
}
//window.onload = menuList;


// Clear input boxes
function clr(fieldID) {
	if (fieldID.defaultValue==fieldID.value) fieldID.value = "";
	else if (fieldID.value == "") fieldID.value = fieldID.defaultValue
}

// Show and hide comments
function showCom(show) {
	if (document.getElementById && document.createTextNode) {
		if (show ==1) {
			document.getElementById("comments").style.display="block";
			document.getElementById("show-comments").style.display="none";
			document.getElementById("hide-comments").style.display="block";
		}
		else {
			document.getElementById("comments").style.display="none";
			document.getElementById("show-comments").style.display="block";
			document.getElementById("hide-comments").style.display="none";
		}
	}
}

// Show menu
function hideMenu()
{
	document.getElementById("menus").style.display = "none";
	document.getElementById("dimmer").style.display = "none";
	document.getElementById("header").style.borderStyle = "";
	document.getElementById("header").style.backgroundColor = "";
	document.getElementById("showMenu").innerHTML = "Menu";
	return false;
}
function showMenu()
{
	// get page height and set dimmer to that
	if (window.innerHeight && window.scrollMaxY) // Moz
	{
		document.getElementById("dimmer").style.height = window.innerHeight + window.scrollMaxY + "px";
	}
	else if (document.body.scrollHeight) // IE
	{
		document.getElementById("dimmer").style.height = document.body.scrollHeight + "px";
	}
	// hide menu if already shown
	if (document.getElementById("menus").style.display == "block")
	{
		hideMenu();
	}
	else
	{
		document.getElementById("dimmer").style.display = "block";
		document.getElementById("menus").style.display = "block";
		document.getElementById("header").style.borderStyle = "solid";
		document.getElementById("header").style.backgroundColor = "#FFFFFF";
		document.getElementById("showMenu").innerHTML = "Hide Menus";
	}
	return false;
}


// Show links only if javascript properly supported
function ifJS(section)
{
	if( document.getElementById && document.createTextNode )
	{
		if( section == 'menuControl' )
		{
			document.write('<p id="head-right">');
			document.write('<a id="menu-left" href="menu" onclick="setActiveStyleSheet(\'left\'); return false" onkeypress="setActiveStyleSheet(\'left\'); return false" title="View menu left, content right">&lt; Left</a>');
			document.write(' | <a id="menu-hidden" href="menu" onclick="setActiveStyleSheet(\'hidden\'); return false" onkeypress="setActiveStyleSheet(\'hidden\'); return false" title="View content only, menu hidden">Hidden</a>');
			document.write(' | <a id="menu-right" href="menu" onclick="setActiveStyleSheet(\'default\'); return false" onkeypress="setActiveStyleSheet(\'default\'); return false" title="View menu right, content left">Right &gt;</a>');
			document.write('</p>');
		}
		if( section == 'menuStyle' )
		{
			document.write('<style type="text/css"><!-- @import url("_menub.css"); --></style>');
		}
		
	}
}

// do Contact
function doCon()
{
	var a,b,c,d,e
	a='mai'
	d='martin.'
	c='@'
	a+='lto:'
	b='ned'
	d+='org'
	e="?Subject=Regarding%20n%20e%20d%20m%20a%20r%20t%20i%20n%20.%20o%20r%20g&Body=Please%20state%20clearly%20the%20address%20of%20the%20page/resource%20that%20you%20are%20enquiring%20about%2C%20and%20the%20reason%20for%20the%20enquiry.%0D%0A%0D%0A%0D%0A%0D%0A%0D%0ANo%20spam%20-%20No%20garbage%20-%20Keep%20it%20real."
	document.location.href = (a+b+c+b+d+e);
}

