
YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) { 
	elCell.innerHTML = oData; 
};

var formatDate	= function( elCell, oRecord, oColumn, sData )
{
	// Use YUI to parse the date in your JSON feed as if it were coming from markup
	// For some reason, YUI skips this step if you're not parsing from HTML

	objDate				= sData;

	// Populate the cell with the proper date
	elCell.innerHTML	= ( objDate.getMonth() ) + "/" + objDate.getDate()  + "/" + objDate.getFullYear();

	// Assign the YUI date class to a var
	strClassname		= YAHOO.widget.DataTable.CLASS_DATE;
	
	// Add the YUI class to the table cell (for styling creaminess) 
	YAHOO.util.Dom.addClass( elCell, strClassname );
};

on_songListReady	= function()
{
	this.columnHeaders	= [
		{ key:"title", text:"Title", type:"link", sortable:true },
		{ key:"genre", text:"Genre", type:"string",sortable:true },
		{ key:"listens", text:"Listens", type:"number", sortable:true },
		{ key:"created", text:"Created", type:"date", sortable:true, formatter:formatDate },
		{ key:"comments", text:"Comments", type:"number", sortable:true }
	];
    this.columnSet	= new YAHOO.widget.ColumnSet( this.columnHeaders );

	var topArtists	= YAHOO.util.Dom.get( "songList" );

	this.dataTable	= new YAHOO.widget.DataTable( topArtists, this.columnSet, null, { sortedBy:{ colKey:"created", dir:"desc" }} );
};

YAHOO.util.Event.onAvailable( "songList", on_songListReady, on_songListReady, true );