/**
* A common library of functions used in various javascript libraries that I've
* written.
*
* @author Toby Miller <tmiller@tobymiller.com>
* @copyright Copyright (C) 2005, Toby Miller
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

/*
* DO NOT EDIT BELOW THIS LINE
*/

/**
* add an event to an element
*
* @param object dom element to add event to
* @param string w3c-standard event name being handled
* @param object w3c-standard event object or simulated function
* @param boolean [optional] whether to truly process the onload event or not (default = false)
* @return void
*/


function addEvent(element, eventName, eventObject)
{
    if (element.addEventListener)
    {
        // this is a w3c-compliant browser, just wrap existing functions
        element.addEventListener(eventName, eventObject, false);
    }
    else if (element.attachEvent)
    {
        // collect optional parameters
        var processOnload = (arguments.length == 4) ? arguments[3] : false;

        if ((element == window) && (eventName == 'load') && (!processOnload))
        {
            // store this event, we'll do it in order with the other onloads
            addEvent._onloads.push(eventObject);
        }
        else
        {
            // add the new event
            element.attachEvent('on' + eventName, eventObject); 
        }
    }
    return(true);
}
addEvent._onloads = [];
addEvent(window, 'load', function(){for(var i = 0; i < addEvent._onloads.length; i++){addEvent._onloads[i]();}}, true);

function addLoadEvent(func)
-{
- var oldonload = window.onload;
- if (typeof window.onload != 'function'){
- window.onload = func;
- } else {
- window.onload = function(){
- oldonload();
- func();
- }
- }
-
+{
+ if( window.addEventListener )
+ window.addEventListener('load', func, false);
+ else if( window.attachEvent )
+ window.attachEvent('onload', func);
} 
