/**
 * spadar-api
 *
 * LICENSE
 *
 * This source file is subject to the MIT license that is bundled
 * with this package in the file MIT-LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://api.spadar.com/license
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to api@spadar.com so we can send you a copy immediately.
 *
 * @category   spadar-api
 * @package    spadar::Ajax
 * @copyright  Copyright (c) 2008-2009 Yury Ksenevich (http://api.spadar.com)
 * @license    http://api.spadar.com/license     MIT License
 */

var spadar  = spadar || {};
spadar.ajax = spadar.ajax || {};

spadar.ajax.Trigger = function(sName, aArgs)
{
    this.sName                      = sName || '';
    this.aArgs                      = aArgs || {};

    spadar.ajax.Trigger._aListeners = spadar.ajax.Trigger._aListeners || {};
    var aListeners                  = spadar.ajax.Trigger._aListeners[sName] || [];

    for (var i = 0; i < aListeners.length; i++)
    {
    	aListeners[i](this);
    }
}

spadar.ajax.Trigger.addListener = function(sName, oCallback)
{
	spadar.ajax.Trigger._aListeners = spadar.ajax.Trigger._aListeners || {};
	spadar.ajax.Trigger._aListeners[sName] = spadar.ajax.Trigger._aListeners[sName] || [];
	spadar.ajax.Trigger._aListeners[sName].push(oCallback);
}
