function Concert( date, headline )
{
	this.date = date;
	this.headline = headline;

	this.toString = function() {
		return this.date + ": " + this.headline
	}

	this.display = function( headlineLbl, dateLbl ) {
		headlineLbl.innerHTML = this.headline;
		dateLbl.innerHTML = dateAsText( this.date );
	}
}

// Create array of concert objects
var concerts = new Array();
	var date = new Date( 2008, 10, 15, 19, 30, 0, 0 );
	concerts[0] = new Concert( date, "Vaughan Williams: <em>Dona Nobis Pacem</em><br/>Durufle: <em>Requiem</em>" );

	date = new Date( 2008, 11, 13, 19, 30, 0, 0 )
	concerts[1] = new Concert( date, "Handel: <em>Messiah</em>" );

	date = new Date( 2009, 1, 28, 20, 0, 0, 0 );
	concerts[2] = new Concert( date, "Ruth Fazal: <em>Terezin Oratorio</em>" );
	
	date = new Date( 2009, 2, 28, 19, 30, 0, 0 )
	concerts[3] = new Concert( date, "Melissa Hui: <em>Night on Earth</em><br/>Mendelssohn: <em>A Midsummer Night's Dream</em>" );

	date = new Date( 2009, 4, 2, 19, 30, 0, 0 )
	concerts[4] = new Concert( date, "Mendelssohn: <em>Lobgesang (Symphony No. 2)</em><br/>Mendelssohn: <em>Psalm 42 (As pants the hart)</em>" );

// Identify default concert item
var curConcertIdx = 0;

function previousConcert()
{
	document.getElementById( 'nextConcertBtn' ).disabled = false;

	if( curConcertIdx == 0  )
		return;

	concerts[ --curConcertIdx ].display( document.getElementById( 'headlineLbl' ), document.getElementById( 'dateLbl' ) );

	if( curConcertIdx == 0 )
		document.getElementById( 'prevConcertBtn' ).disabled = true;
}

function nextConcert()
{
	document.getElementById( 'prevConcertBtn' ).disabled = false;

	if( curConcertIdx == concerts.length - 1 )
		return;

	concerts[ ++curConcertIdx ].display( document.getElementById( 'headlineLbl' ), document.getElementById( 'dateLbl' ) );

	if( curConcertIdx == concerts.length - 1 )
		document.getElementById( 'nextConcertBtn' ).disabled = true;
}

function determineNextDate( datedItems )
{
	// Return index of next date (from now)
	// The parameter must be an array of objects with a 'date' property
	var now = new Date();

	for( var i in datedItems )
		if( datedItems[i].date > now )
			return i;
}
