// an array of movie tuples:
//	movieID is passed in from the onclick event of the button on the active HTML page
//  moviePath is the path (from the active page) to where the Flash movie resides
//  movieInfo is the path (from the active page) to where the Information image resides
var movieList = new Array ( 
						    'mountainID','videos/MountainGoats','vid_info/mountainGoats.jpg','',
							'declareID','videos/Voting','vid_info/declareVoting.jpg','',
							'morningsID','videos/Mornings','vid_info/mornings.jpg','',
							'riseAgainstID','videos/RiseAgainst','vid_info/riseAgainst.jpg','',
							'godsID','videos/GodsRadio','vid_info/godsRadio.jpg','',
							'aesopID','videos/AesopRock','vid_info/aesopRock.jpg','',
							'wyomingID','videos/Wyoming','vid_info/wyoming.jpg','',
							'bloc2ID','videos/BlocParty2','vid_info/blocParty2.jpg','',
							'duhksID','videos/Duhks','vid_info/duhks.jpg','',
						    'cokeID','videos/Coke','vid_info/coke.jpg','',
						    'gusterID','videos/Guster','vid_info/guster.jpg','',
						    'pharrellID','videos/Pharrell','vid_info/pharrell.jpg','',
							'teddyBearsID','videos/Teddy','vid_info/teddyBears.jpg','',
						    'filmographyID','videos/FilmographyMovieTest.swf','vid_info/sounds.jpg','',
							'voltage2ID','videos/Voltage2','vid_info/01.jpg','',
						    'voltageID','videos/Voltage','vid_info/01.jpg','',
						    'soonID','videos/ComingSoon','images/HOME6-18_r4_c3.jpg','',
							'reelID','videos/FinalReel','bogus','bogus',
							'theSubwaysID','videos/TheSubways','vid_info/subways.jpg','',
							'lionFeverID','videos/LionFever','vid_info/lionFever.jpg','',
							'unbunnyID','videos/Unbunny','vid_info/casserole.jpg','',
							'tellierID','videos/Tellier','vid_info/tellier.jpg','',
							'smooshID','videos/FindAway','vid_info/find.jpg','',
							'tahiti80ID','videos/Chinatown','vid_info/chinatown.jpg','',
							'theFaintID','videos/TheFaint','vid_info/faint.jpg','',
							'theSoundsID','videos/TheSounds','vid_info/sounds.jpg','',
							'brilliantID','videos/BrilliantRedLights','vid_info/brilliant.jpg','',
							'americanID','videos/AmericanRejects','vid_info/rejects.jpg','',
							'blocPartyID','videos/BlocParty','vid_info/blocParty.jpg','',
							'makeBelieveID','videos/MakeBelieve','vid_info/makeBelieve.jpg','',
							'willowzID','videos/UlcerSoul','vid_info/ulcerSoul.jpg','',
							'willowz2ID','videos/HornSong','vid_info/hornSong.jpg','',
							'willowz3ID','videos/ConsAndTricks','vid_info/ConsAndTricks.jpg','',
							'willowz4ID','videos/LockMeOut','vid_info/lockOut.jpg','',
							'deathC1ID','videos/DeathCabCrookedTeeth','vid_info/DeathCab_CrookedTeeth.jpg','',
							'deathC2ID','videos/DeathCabSomeday','vid_info/DeathCab_Someday.jpg','',
							'deathCab_1_ID','videos/DeathCab_CrookedTeeth','vid_info/DeathCab_CrookedTeeth.jpg','images/selectionButtonImages/CrookedTeeth2.gif',
							'deathCab_2_ID','videos/DeathCab_Someday','vid_info/DeathCab_Someday.jpg','images/selectionButtonImages/SomedayYouWill2.gif');
var moviePathOffset = 1;	// offset to add to movieID location in movieList Array to get a movie's path
var movieInfoImgOffset = 2;	// offset to add to movieID location in movieList Array to get a movie's info image
var movieSelectionImgOffset = 3;	// If a movie is part of a group, this is the offset to the path of the group button
									// NOTE: if a movie is not a part of a group an empty string MUST BE SPECIFIED ('')

var movieGroupList = new Array ( ['deathCabID','deathCab_1_ID','deathCab_2_ID'] );

function jsStartMovie(id)
{
	var movInnerHTML = "";
	var placeHolder = document.getElementById('moviePlaceHolder');
	placeHolder.style.top = "0px";
	placeHolder.style.left = "0px";
	
	// if id is a movie Group, create the group, otherwise show the movie
	if( getMovieGroupIndex(id) != null) {
		jsShowSelections(id);
	}
	else {
		var movieIdx = getMovieIndex(id);
		if( movieIdx != null ) {
			if( movieList[movieIdx + moviePathOffset] != "" &&  movieList[movieIdx + movieInfoImgOffset] != "" ) {
				try {
					movInnerHTML = AC_FL_CreateContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
														'width','480','height','360','id','FLVPlayer','src','FLVPlayer_Progressive','flashvars',
														'&MM_ComponentVersion=1&skinName=Clear_Skin_1&streamName=' +  
														movieList[movieIdx + moviePathOffset] + 
														'&autoPlay=true&autoRewind=false',
														'quality','high','scale','noscale','name','FLVPlayer','salign','lt','pluginspage',
														'http://www.macromedia.com/go/getflashplayer','movie','FLVPlayer_Progressive' );		
					if( movInnerHTML != "" && placeHolder != null) placeHolder.innerHTML = movInnerHTML;
					jsCreateImg( movieList[movieIdx + movieInfoImgOffset]);
				}
				catch(evt)
				{
				}
			}
		}
	}
}
// utility to find movie in array
function getMovieIndex(movieID)
{
	var i;
	for( i = 0; i < movieList.length; i++)
	{
		if( movieList[i] == movieID) {
			break;
		}
	}
	if( i == movieList.length) return null;
	return i;
}
// utility to find movie in array
function getMovieGroupIndex(groupID)
{
	var i;
	for( i = 0; i < movieGroupList.length; i++)
	{
		if( movieGroupList[i][0] == groupID) {
			break;
		}
	}
	if( i == movieGroupList.length) return null;
	return i;
}

function jsCreateImg(imgPath)
{
	var imgRaw = '<img src=\"IMAGE_PATH\" width="360px" height="24px" border=\"0\" alt=\"\">';
	var imgHTML = imgRaw.replace('IMAGE_PATH',imgPath);
	var imgPlace = document.getElementById('videoInfoPlaceHolderID');
	if(imgPlace != null) {
		imgPlace.innerHTML = imgHTML;
	}
}
function jsShowSelections(selectId)
{
	var i = 0;
	var tableRaw = '<table>ROW_DATA</table>';
	var rowRaw =  '<tr><td>BTN_DATA</td></tr>ROW_DATA';
	var imgRaw = "<img src='IMAGE_PATH' width=\"300px\" height=\"16px\" border=\"0\" alt=\"\" onmouseover='this.style.cursor=\"pointer\"' onmouseout='this.style.cursor=\"default\"' onclick=\"MOVIE_ID\">";
	var tblHTML = tableRaw;
	var imgButton = imgRaw;
	var curRow = rowRaw;
	var placeHolder = document.getElementById('moviePlaceHolder');
	placeHolder.style.top = "16px";
	placeHolder.style.left = "90px";
	jsCreateImg('images/vidInfo.jpg');
	
	var grpIdx = getMovieGroupIndex(selectId);
	if( grpIdx != null ) {
		for( i = 0; i <  movieGroupList[grpIdx].length ; i++)
		{
			try {
				var movieIdx = getMovieIndex(movieGroupList[grpIdx][i]);
				if(movieIdx != null )
				{
					curRow = rowRaw;
					imgButton = imgRaw;
					imgButton = imgRaw;
					imgButton = imgButton.replace('IMAGE_PATH', movieList[movieIdx+movieSelectionImgOffset]);
					imgButton = imgButton.replace('MOVIE_ID',"jsStartMovie('" + movieGroupList[grpIdx][i] + "')");		// 
					curRow = curRow.replace('BTN_DATA', imgButton);
					// add to table
					tblHTML = tblHTML.replace('ROW_DATA',curRow);
				}
			}
			catch(evt)
			{
			}
		}
	}
	tblHTML = tblHTML.replace('ROW_DATA',''); // strip away the remaining row keys
	var imgPlace = document.getElementById('moviePlaceHolder');
	if(imgPlace != null) {
		imgPlace.innerHTML = tblHTML;
	}			
}

function jsFillPlaceHolder(imgPath)
{
	//<img name="FilmographyBox" src="images/FilmographyBox.gif" width="480" height="360" border="0" usemap="#m_FilmographyBox" alt="">
	jsCreateImg('images/vidInfo.jpg');
	var imgRaw = '<img src=\"IMAGE_PATH\" width="480px" height="360px" border=\"0\" usemap=\"#m_FilmographyBox\" alt=\"\">';
	var imgHTML = imgRaw.replace('IMAGE_PATH',imgPath);
	var imgPlace = document.getElementById('moviePlaceHolder');
	if(imgPlace != null) {
		imgPlace.innerHTML = imgHTML;
	}
}
