// JavaScript Document
function Show(title, thumb, banner, url, startDate, endDate)
{
	this.title = title;
	this.thumb = thumb;
	this.banner = banner;
	this.url = url;
	this.startDate = startDate;
	this.endDate = endDate;
	
	
	
	this.getThumbHTML = function() {
		if(this.thumb.length < 1)
		{
			return "<img src=\""+ defaultThumbnail + "\" alt=\"" + this.title + "\" />";
		}
		else
		{
			return "<img src=\""+ this.thumb + "\" alt=\"" + this.title + "\" />";
		}
	}
	this.getBannerHTML = function() {
		if(this.banner.length < 1)
		{
			return "<img src=\""+ defaultBanner + "\" alt=\"" + this.title + "\" />";
		}
		else
		{
			return "<img src=\""+ this.banner + "\" alt=\"" + this.title + "\" />";
		}
	}
}

//Coming soon thumbnail 
var defaultThumbnail = "images/flock_logo_thumbnail.jpg";
var defaultBanner = "images/FlockLogoBlackBackgroundBanner.jpg";
var showInfoUrl = "show_info.php?showName=";
//If no images are available, pass empty strings
//Show(showName, thumbnailImage, bannerImage, showPath, startDate, endDate)
//new Show('The Cherry Orchard','images/cherry_orchard_thumb.png','images/cherry_orchard_banner.png',showInfoUrl+'cherry_orchard', new Date(2011,9,6,22,0,0,0), new Date(2011,9,6,22,0,0,0)),
var currentShows = [new Show('Little Women','images/little_women_thumb.jpg','images/little_women_banner.jpg',showInfoUrl+'little_women', new Date(2012,0,3,0,0,0,0), new Date(2012,0,16,0,0,0,0))];

var thumbLabels = ['Coming Soon','In The Wings','In Migration'];

function getLatestShowTitle()
{
	var showTitle = "";	//Start with a blank title
	var now = new Date();
	// Loop through the available shows
	for(var i=0; i<currentShows.length; i++)
	{
		// Put the current title into the title variable first.
		// This way we at least have the last show played even if they have all ended
		showTitle = currentShows[i].title;
		// If the show has not ended yet, this is the latest show, break the loop
		if(currentShows[i].endDate > now)
		{
			break;
		}
	}
	
	return showTitle;
}
