// JavaScript Document

function Link( key, value, image, owner )
{
	this.key = key;
	this.value = value;
	if ( image != null )
	{
		this.button = new Button( key, value, image );
		this.button.preLoad();
	}
	this.owner = owner;
}

Link.prototype.setAction = function( action )
{
	if ( this.button != null )
	{
		this.button.setAction( action );
	}
}

Link.prototype.setStyle = function( style )
{
	if ( this.button != null )
	{
		this.button.setStyle( style );
	}
}

Link.prototype.setMap = function( map )
{
	if ( this.button != null )
	{
		this.button.setMap( map );
	}
}

Link.prototype.toMarkup = function( down, show )
{
	var markup = "";
	
	if ( this.button != null )
	{
		// button
		if ( show )
		{
			if ( down )
			{
				markup = this.button.toDown();
			}
			else
			{
				markup = this.button.toUp();
			}
		}
		else
		{
			markup = this.button.toDisabled();
		}
	}
	else
	{
		// link
		markup = "L:" + this.key;
	}
	
	return markup;
}

Link.prototype.toString = function()
{
	return "[Link object]: key:" + this.key + ";";
}


