//#=================================
//#IMPORTANT FUNCTIONS/GLOBALS! PARSE FIRST!
//#=================================
//Globals
var event = window.event;
//#=================================
//#=================================

function getElementsByClassName(target, name)
{
   //Check supplied element
   if(!target.nodeType || !target.nodeType == 1) return '[Type Error] Supplied object does not support target method';
   //Grab all elements (document.all)
   var children = target.getElementsByTagName("*");
   //Setup elements Array
   var elements = new Array;
   //Loop through all elements and check class
   for(var i = 0; i <= children.length - 1; i++)
      if(children[i].className == name) elements[elements.length] = children[i];
   //Return elements Array
   return elements;
}

function display()
{
   var elemProperty;
   
   for(var i = 0; i < arguments.length; i++)
   {   
      if(typeof(arguments[i]) == 'boolean')  continue;
      
      elemProperty = arguments[i].style
            
      if(typeof(arguments[i + 1]) == 'boolean')
         elemProperty.display = (arguments[i + 1] == true) ? 'block' : 'none';
      else
         elemProperty.display = (elemProperty.display != 'none') ? 'none' : 'block';
   }
}

function setupDocument()
{
   window.onload = function ()
   {
      //Setup max/minimize toggles
      setupToggle(); 
      
      //Setup navigation if DOM Level 2 is supported
      if(window.addEventListener)
         setupNav( document.getElementById('nav') );
   }
   
   function setupToggle()
   {
      //Loop through all title elements
      var items = getElementsByClassName(document, 'title');
      for(var i = 0; i < items.length; i++)
      {
         //Assign events
         items[i].ondblclick= function () { display( (this.nextSibling.nextSibling) ? this.nextSibling.nextSibling : this.nextSibling ) };
         items[i].onmousedown = function () { return false }
      }
   }
}

setupDocument(); //Setup global document events