// ArtistHolder 
function ArtistHolder(o)
{
	this.artist = o[0];
	this.ownsongs = o[1];
	this.covers = o[2];
}

function ArtistHolder_artistName()
{
	return this.artist[0].data.a;
}
ArtistHolder.prototype.artistName = ArtistHolder_artistName;

function ArtistHolder_describe(stackPos)
{
	res = '<table width="100%" class="zebra scheme1"><tr><th class="exp_artistName">';
	res += 'Artist: ' + this.artistName();
	res += '</th></tr></table>';

	return res;
}
ArtistHolder.prototype.describe = ArtistHolder_describe;

function ArtistHolder_describeOwnCovered()
{
	res = '<table width="100%" class="zebra scheme1">';
	
	if (this.ownsongs.length > 0)
	{
	res += '<tr><th>Songs by ' + this.artistName() + ' covered by other artists</th></tr>';
	for (index=0; index<this.ownsongs.length; index++)
		{
		orig = escape(this.ownsongs[index].data.o);
		perf = escape(this.ownsongs[index].data.p);
		track = escape(this.ownsongs[index].data.t);
		res += '<tr><td><a onclick="extendTop(\'' + orig + '\', \'' + perf + '\', \'' + track + '\')">' + unescape(perf) + " covered " + unescape(track) + "</a></td></tr>";
		}
	res += '</table>';
	}
	else
	{
		res = '<table width="100%" class="zebra scheme1"><tr><td class="Wedont">';
		res += "<i>We don't have any record of people covering songs by " + this.artistName() + ".</i>";
		res += '</td></tr></table>';
	}
	
	return res;
}
ArtistHolder.prototype.describeOwnCovered = ArtistHolder_describeOwnCovered;

function ArtistHolder_describeCovers()
{
	res = '<table width="100%" class="zebra scheme1">';

	if (this.covers.length > 0)
	{
	res += '<tr><th>Songs covered by ' + this.artistName() + '</th></tr>';
	for (index=0; index<this.covers.length; index++)
		{
		orig = escape(this.covers[index].data.o);
		perf = escape(this.covers[index].data.p);
		track = escape(this.covers[index].data.t);
		res += '<tr><td><a onclick="extendBottom(\'' + orig + '\', \'' + perf + '\', \'' + track + '\')">' + "covered " + unescape(track) + " by " + unescape(orig) + "</a></td></tr>";		
		}
	res += '</table>';		
	}
	else
	{
		res = '<table width="100%" class="zebra scheme1"><tr><td class="Wedont">';
		res += "<i>We don't have any record of covers by  " + this.artistName() + ".</i>";
		res += '</td></tr></table>';	
	}

	res += "<hr noshade>";
	
	return res;
}
ArtistHolder.prototype.describeCovers = ArtistHolder_describeCovers;


//----------------------------------------------
function TrackHolder(_orig, _perf, _track)
{
	this.orig = _orig;
	this.perf = _perf;
	this.track = _track;
}

function TrackHolder_describe(index)
{
        res = '<table width="100%" class="zebra scheme1"><tr><td class="exp_trackName">';
	res += "Track: " + unescape(this.perf) + " covered " + unescape(this.track) + " by " + unescape(this.orig);
        res += '</td></tr></table>';

	return res;
}
TrackHolder.prototype.describe = TrackHolder_describe;

function TrackHolder_describeOwnCovered()
{
	return "";
}
TrackHolder.prototype.describeOwnCovered = TrackHolder_describeOwnCovered;

function TrackHolder_describeCovers()
{
	return "";
}
TrackHolder.prototype.describeCovers = TrackHolder_describeCovers;


//----------------------------------------------
// exploreStack - a stack of explore nodes

function ExploreStack()
{
	this.nodes = new Array();
}

function ExploreStack_describe(showProcessingTop, showProcessingBottom)
{
	res = "";	
	
	res += this.tableTop();
	
	// left
	res += '<tr>';
	res += '<td STYLE="background-image: url(\'art/l.gif\');"/>';
	res += '<td>';	
	
	//content
	res += '<table cellspacing="0"><tr><td>';
		
	if (this.nodes.length > 1)
	{
		res += this.goBackTop();
	}
	
	if (showProcessingTop)
	{
		res += '<table width="100%"><tr><th class="processing">';
		res += "Processing...";
		res += '</th></tr></table>';
	}	
	
	for (i=0; i<this.nodes.length; i++)
	{
		if (i == 0)
		{
			res += this.nodes[i].describeOwnCovered();
		}
		res += this.nodes[i].describe(i);
		if (i == this.nodes.length - 1)
		{
			res += this.nodes[i].describeCovers()
		}
	}
	
	if (showProcessingBottom)
	{
		res += '<table width="100%"><tr><th class="processing">';
		res += "Processing...";
		res += '</th></tr></table>';
	}
	
	if (this.nodes.length > 1)
	{
		res += this.goBackBottom();
	}	
	
	res += "</td></tr></table>";
	// end content
	
	// right
	res += '</td>';
	res += '<td STYLE="background-image: url(\'art/r.gif\');"/>';
	res += '</tr>';	
	
	res += this.tableBottom();

	return res;
}
ExploreStack.prototype.describe = ExploreStack_describe;

function ExploreStack_addTop(o)
{
	this.nodes.unshift(o);
}
ExploreStack.prototype.addTop = ExploreStack_addTop;

function ExploreStack_addBottom(o)
{
	this.nodes.push(o);
}
ExploreStack.prototype.addBottom = ExploreStack_addBottom;

function ExploreStack_goBackTop()
{
	res = '<table width="100%" class="zebra scheme1"><tr><th class="goback">';
	res += "<a onclick='goBackTop()'>Click here to go back one artist</a>";
	res += '</th></tr></table>';
	
	return res;
}
ExploreStack.prototype.goBackTop = ExploreStack_goBackTop;

function ExploreStack_goBackBottom()
{
	res = '<table width="100%" class="zebra scheme1"><tr><th class="goback">';
	res += "<a onclick='goBackBottom()'>Click here to go back one artist</a>";
	res += '</th></tr></table>';
	
	return res;
}
ExploreStack.prototype.goBackBottom = ExploreStack_goBackBottom;

function ExploreStack_shrinkTop()
{
	this.nodes.splice(0, 2);
	return this.describe(0, 0);
}
ExploreStack.prototype.shrinkTop = ExploreStack_shrinkTop;

function ExploreStack_shrinkBottom()
{
	this.nodes.splice(this.nodes.length - 2, 2);
	return this.describe(0, 0);
}
ExploreStack.prototype.shrinkBottom = ExploreStack_shrinkBottom;

function ExploreStack_tableTop()
{	
	res = '<table border="0" cellpadding="0" cellspacing="0">';
	res += '<tr>';
	res += '<td><img src="art/t_l.gif"/></td>';
	res += '<td STYLE="background-image: url(\'art/t.gif\');"/>';
	res += '<td><img src="art/t_r.gif"/></td>';
	res += '</tr>';

	return res
}
ExploreStack.prototype.tableTop = ExploreStack_tableTop;

function ExploreStack_tableBottom()
{
	res = '<tr>';
	res += '<td><img src="art/b_l.gif"/></td>';
	res += '<td STYLE="background-image: url(\'art/b.gif\');"/>';
	res += '<td><img src="art/b_r.gif"/></td>';
	res += '</tr>';
	res += '</table>';

	return res;
}
ExploreStack.prototype.tableBottom = ExploreStack_tableBottom;
