/* Copyright (c) 2007 Google Italia
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You may obtain a copy of the License at
 *
 *     http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 * Version: 1.0
 *
 * Emulate Flash Delegate
 *
 */
Delegate = {
    create: function(obj, func, params){
        var f = function(){
            var target = arguments.callee.target;
            var func = arguments.callee.func;
            if (func.apply) {
                if (params) {
                    return func.apply(target, params);
                }
                else {
                    return func.apply(target, arguments);
                }
                
            }
            else {
                obj.__RCinit = func;
                obj.__RCinit(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
            }
        };
        
        f.target = obj;
        f.func = func;
        
        return f;
    }
}

