//Copyright (C) Ben Parbury - All Rights Reserved. Unauthorized copying of this file, via any medium is strictly prohibited. Written by Ben Parbury <ben@gridlockinteractive.com> 2014

function OptionsButton()
{
	this.__proto__ = new TripleButton("options");
	this.buttons = new Array();
	
	this.buttons.push(new Button("Visual", function(){ gOptionsMenu.optionsButtons.Select(0); }));
	this.buttons.push(new Button("Audio", function(){ gOptionsMenu.optionsButtons.Select(1); }));
	this.buttons.push(new Button("Input", function(){ gOptionsMenu.optionsButtons.Select(2); }));
	this.buttons.push(new Button("Game", function(){ gOptionsMenu.optionsButtons.Select(3); }));
	
	this.currentlyLoaded = 1;
	this.highlightSound = gSounds.Get("menuHighlight");
	
	this.PlayHighlightSound = function()
	{
		this.highlightSound.Play();
	}
	
	this.SelectedItem = function()
	{
		this.highlightSound.Play();
	}
	
	this.SetPosition = function(x, y)
	{
		var width = this.buttons[0].width;
		var gap = kTileSize/2;
		var xStep = width + gap;
		var xStart = x - (1.5 * xStep);
		for(var i = 0; i < this.buttons.length; i++)
		{
			this.buttons[i].SetPosition(xStart + (i * xStep), y);
		}
	}

	this.SetSize = function(width, height)
	{
		var itemWidth = width * 0.666;
		for(var i = 0; i < this.buttons.length; i++)
		{
			this.buttons[i].SetSize(itemWidth, height);
		}
	}
	
	this.Interact = function()
	{
	}
	
	this.SelectLeft = function()
	{
		this.Select(this.selectedItem - 1);
	}
	
	this.SelectRight = function()
	{
		this.Select(this.selectedItem + 1);
	}
	
	this.Select = function(index)
	{
		if (index >= 0 && index <= 3)
		{
			if(this.currentlyLoaded != index)
			{
				switch (index)
				{
					case 0:
						gOptionsMenu.SetVisual();
						break;
					case 1:
						gOptionsMenu.SetAudio();
						break;
					case 2:
						gOptionsMenu.SetInput();
						break;
					case 3:
						gOptionsMenu.SetMisc();
						break;
				}
				this.currentlyLoaded = index;
				this.highlightSound.Play();
			}
			this.selectedItem = index;
		}
	}
}
