/*****************************************************
 * ColorScheme.js
 * 04.18.2003
 * Eddie Lim <elim@eecs.harvard.edu>
 * www.netsymbiosis.com
 *****************************************************/

ColorScheme.schemes = new Array();
ColorScheme.Registry = [];
ColorScheme.lastColorSchemeId = "";

function ColorScheme(id, textAreaColor, titleAreaColor, activeMenuColor, inActiveMenuColor, menuSeparatorColor, textAreaBorderColor, titleAreaBorderColor, menuBorderColor)
{
	var primaryColor = textAreaColor;
	var secondaryColor = titleAreaColor;
	var tertiaryColor = activeMenuColor;
	if(!primaryColor || !secondaryColor || !tertiaryColor) { return; }

	this.id = id;
	this.textAreaColor = textAreaColor;
	this.titleAreaColor = titleAreaColor;	
	this.activeMenuColor = activeMenuColor;

	this.menuContentColor = this.inActiveMenuColor = inActiveMenuColor ? inActiveMenuColor : secondaryColor;
	this.inActiveMenuColor = inActiveMenuColor ? inActiveMenuColor : secondaryColor;	
	this.menuSeparatorColor = menuSeparatorColor ? menuSeparatorColor : tertiaryColor;
	this.textAreaBorderColor = textAreaBorderColor ? textAreaBorderColor : activeMenuColor;
	this.titleAreaBorderColor = titleAreaBorderColor ? titleAreaBorderColor : tertiaryColor;
	this.menuBorderColor = menuBorderColor ? menuBorderColor : tertiaryColor;
	ColorScheme.Registry[id] = this;
	ColorScheme.schemes.push(this);	
}

ColorScheme.init = function(id, textAreaColor, titleAreaColor, activeMenuColor, inActiveMenuColor, menuSeparatorColor, textAreaBorderColor, titleAreaBorderColor, menuBorderColor)
{
	new ColorScheme(id, textAreaColor, titleAreaColor, activeMenuColor, inActiveMenuColor, menuSeparatorColor, textAreaBorderColor, titleAreaBorderColor, menuBorderColor);
}

/**
 * we don't leave it entirely up to chance...
 * a random menu can't have the same color as the last one.
 */
ColorScheme.getRandomColorScheme = function()
{
	var id = Math.floor(Math.random() * ColorScheme.schemes.length);
	while(id == ColorScheme.lastColorSchemeId)
	{
		id = Math.floor(Math.random() * ColorScheme.schemes.length);
	}
	ColorScheme.lastColorSchemeId = id;
	return ColorScheme.schemes[id];
};

ColorScheme.getColorSchemeById = function(id)
{
	var c = ColorScheme.Registry[id];
	if(c == null)
	{
		c = ColorScheme.getRandomColorScheme();
	}
	ColorScheme.lastColorSchemeId = c.id;
	return c;
}