
/**Expandable/Collapsible Menus
  *@author Kevin Leong
  *@reference "collapsible page objects" on www.codingtuts.com 
  *@date 07/20/08
  */

/**getObject Function
  *@purpose to return the requested page element as an object
  *@return obj
  *@param id 
  */
  
function getObject(id){
  var obj = null;
  
  if(document.getElementById)
    obj = document.getElementById(id);
	
    //following else if statements to ensure compatibility with as many browsers as possible
	else if(document.all)
	  obj = document.all[id];
	
	else if(document.layers)
	  obj = document.layers[id];
  
  return obj;
}

/**toggleObject Function
  *@purpose to 
  *@return obj
  *@param id 
  */

function toggleObject(id){

  //sets obj variable to result of getObject call
  var obj = getObject(id);
  
  //exits program if obj is not valid
  if(!obj)
    return false;

  //checks to see the current css display property of the selected element
  //'none' = not visible
  //'' = default display state (e.g., block, inline, etc.)
  if(obj.style.display=='none'){
    obj.style.display='';
  }
  
  //if already displayed, then it collapses the selected object
  else{
    obj.style.display='none';
  }
  
  //exit function
  return true  
 }