/**********************************************************
Author:
Adam Barry
eBOUND
www.ebound.dk

Date: February 20 2007

© 2007 Adam Barry, all rights reserved

Inspiration: http://simonwillison.net/2004/May/26/addLoadEvent/
-----------------------------------------------------------

Name:
windowOnLoad script

-----------------------------------------------------------
Description:
Function that enables loading of multiple functions during
window.onload

-----------------------------------------------------------
Usage:
Simply place a link to the this script in the top of the
<head>-section of the XHTML page - before including
additional JavaScript files. The script will then
automatically execute on page load.

Include the addLoadEvent code in the scripts that you wish to have
loaded at the time of page-load according to the example below.

<script type="text/javascript" src="windowOnLoad.js"></script>

-----------------------------------------------------------
Example:
<script type="text/javascript" src="windowOnLoad.js"></script>

function functionToLoad() {
	alert("Execute me on page-load, please");
}

addLoadEvent(function(){functionToLoad();});

-----------------------------------------------------------
Dependencies:
None

**********************************************************/

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}