﻿/*global $ */
var Alienware = window.Alienware || {};
Alienware.com = Alienware.com || {};
Alienware.com.Utils = Alienware.com.Utils || {};

/**
 * DELL.com.Utils Module
 * 
 * This module provides utility methods to be used throughout the Dell.com 
 * website.
 */
(function() {
    var $this = this; // this === DELL.com.Utils

    /**
     * Upon DOMContentLoaded, executes all the functions stored in a given object.
     * @param	{Object}	Object containing functions to be invoked.
     */
    this.Initialize = function(onload) {
        /**
         * Inner function that handles method invocation. Called once for each
         * object that has been passed to DELL.com.Utils.Initialize.
         * @private
         * @param	{Object}	Object containing functions to be invoked.
         */
        var init = function(onload) {
            var methodName;

            // Traverse through onload
            for (methodName in onload) {
                // Make sure method is actually part of onload
                // This ensures we avoid stuff that sometimes gets snuck into Object.prototype
                if (onload.hasOwnProperty(methodName) && typeof onload[methodName] === 'function') {
                    onload[methodName]();
                }
            }
        };

        $(document).ready(function() {
            init(onload);
        });
    };

}).call(Alienware.com.Utils);