dojo.require("dijit.Dialog");

// prepare popup
var showDetailsPopup;
dojo.addOnLoad( 
	function()
	{
	    // create the dijit dialog:
	    showDetailsPopup = new dijit.Dialog( {
	        style: "width: 400px"
	    } );
	
		// ensure we have tundra on body
		dojo.addClass( dojo.query( 'body' )[0], 'tundra' );
	}
);


function showVenueDetails( url, title, id )
{
	//console.log( url + '?xhr_source=spit_performance&show=venue_popup&id=' + id );
	
	var xhrArgs = {
		url: url + '?xhr_source=spit_performance&show=venue_popup&id=' + id,
		handleAs: 'text',
		load: function( data )
		{
			showDetailsPopup.attr( 'title', title );
			showDetailsPopup.attr( 'content', data );
			showDetailsPopup.show();
		},
		error: function( error )
		{
			showDetailsPopup.attr( 'title', 'Error' );
			showDetailsPopup.attr( 'content', 'Performance details cannot be retrieved at this time. Please try later. ' + error );
			showDetailsPopup.show();
		}
	}

    // Call the asynchronous xhrGet
    var deferred = dojo.xhrGet( xhrArgs );

}

function showPerformanceDetails( title, description )
{
	showDetailsPopup.attr( 'title', title );
	showDetailsPopup.attr( 'content', description );
	showDetailsPopup.show();
}
