/* 
 * From: http://forum.java.sun.com/thread.jspa?forumID=45&threadID=550658
 * 
 * Note: The JavaScript functions called 'vfnOnLoad' and 'vfnOnUnLoad' will 
 * be called automatically on all pages using SubMenuLayout.jsp.  Page parts 
 * should not overwrite these functions, but instead, register a function 
 * to be called by passing the name of the function to call on load/unload a 
 * as a string to 'vfnRegOnLoad' and 'vfnRegOnUnLoad'.  All functions will 
 * then be called at the appropriate time, in the order registered.  
 * For example:  vfnRegOnLoad('myOnloadFunction();');

Example: 
 Then in the single body, I have this:

<body ... onload="vfnOnLoad()" onunload="vfnOnUnLoad()">

And in my tiles, if I want to have something run 
on load, I just do this:

<script language="Javascript">
doPageThingOnLoad = function() {
   ...
}
vfnRegOnLoad('doPageThingOnLoad();');
</script>

This way you can have multiple things register to 
call on load or unoad from any tile.

 */
var aOnLoadFunctions = new Array();
var aOnUnLoadFunctions = new Array();
 
vfnOnLoad = function() {
	if(aOnLoadFunctions.length != 0) {
		for(var i = 0; i < aOnLoadFunctions.length; i++) {
			eval(aOnLoadFunctions[i]);
		}
	}
}
 
vfnOnUnLoad = function() {
	if(aOnUnLoadFunctions.length != 0) {
		for(var i = 0; i < aOnUnLoadFunctions.length; i++) {
			eval(aOnUnLoadFunctions[i]);
		}
	}
}
 
vfnRegOnLoad = function(sFunc) {
	if(typeof(sFunc) != 'undefined' && sFunc != null && sFunc != '') {
		aOnLoadFunctions[aOnLoadFunctions.length] = sFunc;
	}
}
 
vfnRegOnUnLoad = function(sFunc) {
	if(typeof(sFunc) != 'undefined' && sFunc != null && sFunc != '') {
		aOnUnLoadFunctions[aOnUnLoadFunctions.length] = sFunc;
	}
}
