/* 
    #########################################
    Author : JEREMY BUELER www.jbueler.com
    Company : www.summitprojects.com
    Date: 9/27/07 September 27th, 2007
    #########################################

    THIS IS AN ONDOMREADY EVENT QUEUE -- MOOTOOLS ADDON CLASS FOR ALLOWING YOU TO EASILY 
    ADD AND REMOVE FUNCTIONS TO RUN ON DOM READY...
    
    Onload  =  is a global Object that you can use to add the functions:
    
    Example:
        Onload.add(fn); --> fn = a function that you wish to add to the ondomready queue 
                                that fires automatically when the dom is ready. 
                                THE FUNCTION WILL ONLY BE ADDED IF IT ISN'T ALREADY IN THE QUEUE.
                                
        Onload.remove(fn) --> fn = the function that you wish to remove from the queue.
                                    it will be permanently removed from the queue 
    
        Onload.test(fn) --> fn = Check to see if the function (fn) you are passing in is already included
                                 Returns true if the function is already in the queue false if not...
                                 
        Onload.run() --> the function that runs on domready -- the event is already set up to run then -- 
                         this function will execute all functions in the queue in the order they were added...
*/


if( typeof MooTools != "undefined" ){
    var RegisterFunctions = new Class({
            options:{
                delay: 0
            },
            initialize: function(options){
                this.setOptions(options);
                this.collection = [];
            },
            add: function(fn){
                this.collection.include(fn);
            },
            run: function(){
                this.collection.each(function(fn){
                        fn();
                })
            },
            remove: function(fn){
                if(this.collection.contains(fn)) this.collection.remove(fn);
            },
            test: function(fn){
                if(this.collection.contains(fn)){ 
                    return true;
                }
                else{
                    return false;
                }
            },
            emptyAll: function(){
            		this.collection.each(function(item){
            			this.collection.remove(item);
            		}.bind(this));
            }
    });
    RegisterFunctions.implement(new Events, new Options);
    var Onload = new RegisterFunctions();
    window.addEvent('domready',function(){
       Onload.run();     
    });
}





