/*
External Links using rel attribute and Javascript 
to make markup html strict compliant
*/

/**
 * Function: InitUtilities
 * ------------------------------------------------------------------
 * All utilities that need onload firing should be called from here
 * ------------------------------------------------------------------
 */
function InitUtilities(){
  InitExternalLinks();
}

/**
 * Function: Toggle
 * ------------------------------------------------------------------
 * Toggles div classes from hidden to visible and vice versa to reduce space usage
 * ------------------------------------------------------------------
 */
function InitUtilities(){
  InitExternalLinks();
}

/**
 * Function: InitialiseDocument
 * ------------------------------------------------------------------
 * Alters links in their JavaScript objects to use a target="_black"
 * so as to conform with XMTML rules while opening offsite sites in
 * a new window
 * ------------------------------------------------------------------
 */
function InitExternalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 

/**
 * Function: InitialiseDocument
 * ------------------------------------------------------------------
 * All basic initialisations will occur here. Emulates windows.onload
 * in a DOM way. For every script file added that needs to fire some
 * events onload, please place a call here
 * ------------------------------------------------------------------
 */
function InitialiseDocument(){
  InitUtilities();
  InitialiseMenu();
  if(sysLoadChain) { 
  /*eventHook declared in the bootstrap.js and uses the paradigm similar to
    windows hooking. Just queue up all onload init script names there and they
	will be fired.
  */
	for(var i=0; i < sysLoadChain.length ; i++) {
	  eval(sysLoadChain[i]);
	}
  }
}
window.addEventListener("load",InitialiseDocument,false);

