/* 

	You may use this js file as you wish. This script is given as is, no warranties
	implied or otherwise are given by the author. Use at your own risk.
	
	PLEASE DO NOT REMOVE THESE COMMENTS (give credit where it is due).
	
	Written by	: Arthur Y. Abon
	Date Written: February 22, 2009
	
	Description	: Contains functions used for easy creation of dynamic menus
	
	Note: You will need to add these lines to your CSS for this code to work:
	
	.hide {
		display:none;
	}
	.show {
		display:block;
	}
	
	======================================================================================
	
	Sample:
	
	<a href="#" onclick="menuShowHide('subMenu');">MENU 1<br />
	  </a>
	  <div id="subMenu" class="hide">
	  <a href="#">SubMenu 1</a><br />
	  <a href="#">SubMenu 2</a><br />
	  <a href="#">SubMenu 3</a><br />
	  <a href="#">SubMenu 4</a>
	</div>
	
*/

function menufindObj(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function menuhide(strObj)
{
	var objTarget = menufindObj(strObj);
	objTarget.className = "hide subMenu";
}

function menushow(strObj)
{
	var objTarget = menufindObj(strObj);
	objTarget.className = "show subMenu";
}

function menuShowHide(strObj)
{
	var objTarget = menufindObj(strObj);
	if(objTarget.className == "hide subMenu") menushow(strObj);
	else menuhide(strObj)
}
