//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 ApplyBackButton(applyFunc, backFunc)
{
	this.__proto__ = new TripleButton("Back");
	this.buttons = new Array();
	
	this.buttons.push(new Button("Apply", applyFunc));
	
	this.buttons.push(new Button("Back", backFunc));
	
	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 - (xStep * 0.5);
		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.75;
		for(var i = 0; i < this.buttons.length; i++)
		{
			this.buttons[i].SetSize(itemWidth, height);
		}
	}
	
	this.Interact = function(back)
	{
		if(back)
		{
			this.buttons[1].Interact();
		}
		else
		{
			this.buttons[this.selectedItem].Interact();
		}
	}
	
	this.SelectLeft = function()
	{
		this.selectedItem = 0;
		this.buttons[0].SetHighlighted();
		this.buttons[0].redraw = true;
	}
	
	this.SelectRight = function()
	{
		this.selectedItem = 1;
		this.buttons[1].SetHighlighted();
		this.buttons[1].redraw = true;
	}
}
