/*function Enum(constantsList) {
    for (var i in constantsList) {
        this[constantsList[i]] = i;
    }
}*/


function Enum()
{
	this.allValues = arguments;
    for (var i in arguments)
    {
        this[arguments[i]] = i;
    };
}

Enum.prototype.values = function()
{
    return this.allValues;
};

//var Color = new Enum('RED', 'GREEN', 'BLUE');
/*
function Semaphore(name, hitCount, active)
{
	this.hits = 0;
	this.hitCount = hitCount; // how many kicks to get the center of the semaphore
	this.name = name;
	this.active = active;
	this.callbacks = new Array();
	this.links = new Array(); // to link semaphores so they all kick at the same time
	
	this.addLink = function (link)
	{
		if (link != this)
		{
			var hasLink = false;
			for (var index = 0; index < this.links.length; index++)
			{
				if (this.links[index] == link)
				{
					hasLink = true;
				}
			}
			if (hasLink == false)
			{
				this.links.push(link);
				link.addLink(this); // cross pollinate
			}
		}
	};
	
	this.activate = function(active)
	{
		this.active = active;
	};
	
	this.ready = function ()
	{
		var retVal = false;
		
		if (this.hits == this.hitCount)
		{
			retVal = true;
		}
		return retVal;
	};
	
	this.kick = function ()
	{
		this.hits++;
		
		if (this.hits == this.hitCount)
		{
			// kick all callbacks
			if (this.active == true)
			{
				var allReady = true;
				
				for (var link = 0; link < this.links.length; link++)
				{
					if (this.links[link].ready() == false)
					{
						allReady = false;
					}
				}
				
				if (allReady == true)
				{
					var thisObj = this;
					
					// let the flood commence
					for (var link = 0; link < this.links.length; link++)
					{
						var callObject = this.links[link];
						setTimeout(function () {callObject.issueCallbacks();}, 20);
					}
					setTimeout(function () {thisObj.issueCallbacks();}, 20); // give small delay to allow the caller that kicked it off to return to its normally scheduleded process
				}
			}
		}
	};
	
	this.reset = function ()
	{
		this.hits = 0;
		this.active = false;
		// wack links?
	};
	
	this.issueCallbacks = function ()
	{
		for (var index = 0; index < this.callbacks.length; index++)
		{
			this.callbacks[index]();
		}
	};
	
	this.wait = function(callback)
	{
		this.callbacks.push(callback);
	};
	
	return this;
}
*/

function CallBack(object, func)
{          
    // arguments[0] == object
    // arguments[1] == func
    
    
    var args = []; // empty array
    
    // copy all other arguments we want to "pass through"
    for(var i = 2; i < arguments.length; i++)
    {
        args.push(arguments[i]);
    }

    func.apply(object, args);
}

//	setTimeout(CallBack(gameDevice, spinReel, reelIndex, stops[stop]), reelDelay);
function TimeDelay(delay, object, func)
{
	// first three args are detailed above.  The rest are to be passed to the delayed method
	var argsToPass = [];
	
    for(var i = 3; i < arguments.length; i++)
    {
    	argsToPass.push(arguments[i]);
    }
    
    setTimeout(func.apply(object, argsToPass), delay);
}
