// store show images and URLs
var shows = new Array();
var showImagePrefix = "/images/home_shows/home_";
var showImageSuffix = ".jpg";
var showLandingPrefix = "/shows/";

// list of shows to randomly display on the front page
shows[0]="acoustic_spotlight";
shows[1]="faculty_lounge";
shows[2]="for_your_health";
shows[3]="global_perspectives";
shows[4]="ucf_in_print";
shows[5]="profiles";
shows[6]="short_flix";
shows[7]="ucf_on_the_issues";
shows[8]="ucf_performs";
shows[9]="ucf_presents";
shows[10]="ucf_reports";
shows[11]="zenith";
shows[12]="gallery";
shows[13]="naturally_central_florida";
shows[14]="expressions";
shows[15]="money_talks";
shows[16]="public_affairs_today";
shows[17]="ucf_sports_today_football";
shows[18]="ucf_sports_today_basketball";
shows[19]="uknighted";
shows[20]="loufrey";
shows[21]="luminaryseries";
shows[22]="opportunityminutes";
shows[23]="connection"; 


// generate a unique random sequence of show images and links
function genRandomShowsMarkup(maxShows)
{
	maxShows++;
	// pick shows
	selectedShows = new Array();
	for (i=0;i< maxShows;i++)
	{
		aShow =pickRandomShow();
		// check previously picked shows
		for (z=0;z<selectedShows.length; z++)
		{		
			// have we already picked this show?
			if (aShow == selectedShows[z])
			{
				//  pick a differnt show
				aShow = pickRandomShow();
				// restart at the begining;
				z=-1;
			}
		}		
		selectedShows[i]= aShow;
	}	
	
	// generate show image and link markup
	showsMarkup = '';
	
	for (i=0;i< maxShows;i++)
	{
		showsMarkup+="<a href='"+showLandingPrefix+shows[selectedShows[i]]+"'><img src='"+showImagePrefix+shows[selectedShows[i]]+showImageSuffix+"' /></a>";
	}
	
	return showsMarkup;	
}


// return a random show
function pickRandomShow ()
{
	return Math.round((Math.random() * (shows.length -1)));
}

// play a particular episode
function playEpisode(filename)
{
	movieName='flashPlayer';
	if (movieIsLoaded(thisMovie(movieName))) 
	{
		// replace the current episode
		thisMovie(movieName).SetVariable("arg1",filename);
		thisMovie(movieName).TGotoLabel("/js","replaceMediaVideo");
    }
    
    return false;
}

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  }	else {
    return document[movieName]
  }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
    return theMovie.PercentLoaded() == 100;
  } else {
    return false;
  }
}