$(document).ready(function() {
	var permalink = $('#permalink').attr('href');
	if(permalink != document.location) document.location = permalink;
	$('a.symbol').click(symbolClick);
});

function symbolClick()
{
	var tr = $(this).parents('tr:first');
	if($(tr).next('tr').is('.chart')) //chart already loaded; toggle show/hide
	{
		$(tr).next('tr').toggle();
	}
	else // chart not yet loaded; add row for the chart
	{
		$(tr).after('<tr class="chart"><td colspan="30"><div></div></td></tr>');
		var nextTr = $(tr).next('tr');
		$(nextTr).find('div').load('/tools/stock_service.php?action=chart_embed_html&symbol=' + $(this).text());
	}
	
	return false; // don't go to href URL
}
