/**
* Catalog ThemeRoller
* Developed by Duane A Comeaaux
* Handle all buttons with class "catalog-button"
* add hover states to input type buttons
*/

$(function()
{
	var $This = this;	//only for scope resolution
	this.catalogButton = function()
	{
		var $this = this;		//only for scope resolution
		this._members = new Array();

		this.apply = function()
		{
			$($this._members)
			.each(function()
			{
				$(this)
				.css(
				{
					color: $This.theme.normalColor,
					backgroundColor: $This.theme.backgroundColor ,
					borderColor: $This.theme.borderColor
				})
				.hover(
					function()
					{
						$(this).css(
						{
							color: $This.theme.hoverColor,
							borderColor: $This.theme.hoverColor,
							cursor: 'pointer'
						});
					},
					function()
					{
						$(this).css(
						{
							color: $This.theme.normalColor,
							borderColor: $This.theme.borderColor
						});
					}
				);
			});
		}

		this.addMember = function(obj)
		{
			if( obj instanceof Array )
			{
				if( obj.length > 0 )
				{
					for( x in obj )
						$this._members.push(obj[x]);
				}
				else
				{
					alert("This Theme has no members.\nPlease enter at least one member");
					return;
				}
			}
			else
				$this._members.push(obj);
		}
	}

	this.theme = new Theme();

	if( !this.theme instanceof Function )
	{
		alert("A theme can not be applied.\nIt seems that the Javacsctipt\nfunction 'Theme' is not present\nor it is not an instance of Function\nPlease ensure that it is added.\nRef:catalog_catalogpage.php");
		return;
	}

	this.members = new Array();
	this.members[0] = $('input.catalog-button');
	this.members[1] = $('a.catalog-button');
	this.button = new this.catalogButton();
	this.button.addMember(this.members);
	this.button.apply();
});
