/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 */

/**
 * Effects.js
 *
 * File Path: /scripts/
 *
 * $Id: Effects.js 218 2007-12-19 15:37:18Z topdog $
 *
 * LICENSE: copyright 2005 - 2007 Edward Vermillion - Doggydoo Codeworks.
 * Unless otherwise stated ALL RIGHTS ARE RESERVED. Use or reuse without prior
 * written permission from the author or Doggydoo Codeworks is prohibited.
 * Visit http://www.doggydoo.net/license/DDJS-V1.X.txt for the full license.
 * Installation and use of this software implies agreement to the full
 * license.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DOGGYDOO
 * CODEWORKS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 * @package     DDJS
 * @author      Edward Vermillion <evermillion@doggydoo.net>
 * @copyright   2005 - 2007 Edward Vermillion, Doggydoo Codeworks
 * @license     http://www.doggydoo.net/license/DDJS-1.x.txt
 * @version     1.0
 */

if (typeof DDJS == 'undefined') {
    var DDJS = {};
}

/**
 * @object DDJS.Effects
 *
 * The effects namespace and object container
 */
DDJS.Effects = {

    /**
     * @property _effectsObjs
     *
     * The container object for registered effects objects
     *
     * @type {Object}
     * @return void
     * @private
     */
    _effectsObjs: {},

    /**
     * @method registerEffect
     *
     * Registers an effect object
     *
     * @param {Object} obj
     * @param {String} objID
     * @return void
     */
    registerEffect: function (obj, objID) {
    	effectID = objID || obj._objectID;
        this._effectsObjs[effectID] = obj;
    },

    /**
     * @method execEffect
     *
     * Executes a method of a registered effect object, optionally passing any
     * arguments to the method
     *
     * @param {String} objID
     * @param {String} func
     * @param {Mixed} args    May be either a string for a single argument or an
     *                        array for multiple arguments
     * @return void
     */
    execEffect: function (objID, func, args) {

        var evalString = 'this._effectsObjs["'+objID+'"].'+func+'(';

        if (typeof args != 'undefined') {
            if (typeof args == 'string') {
                evalString += "'"+args+"'";
            } else {
                for (var i=0; i<args.length; i++) {
                    evalString += "'"+args[i]+"',";
                }
                evalString.replace(/,$/, '');
            }
        }

        evalString += ');';

        eval(evalString);
    },

    /**
     * @method toString
     * @return {String}
     */
    toString: function () {
        return '[Object] DDJS.Effects';
    }
    
}; // End DDJS.Effects









