var selectedDivID= new RegExp("s","g");
selectedDivID=15;
function createPlayer() {
	var flashvars = {
		file : "http://kayakfishingtales.oncourss.com/wp-content/plugins/wordtube/myextractXML.php?id=2",
		volume : "80",
		bufferlength : "5",
		stretching : "fill",
		quality : "false",
		controlbar : "over",
		playlist : "none",
		shuffle : "false",
		autostart: "false",
		item: "24"
	}
	var params = {
		wmode : "transparent",
		allowscriptaccess : "always",
		allownetworking : "all"
	}
	var attributes = {
		id : "wtPlayer",
		name : "wtPlayer"
	}
	swfobject.embedSWF("http://kayakfishingtales.oncourss.com/wp-content/plugins/wordtube/player.swf", "wtPlayerPlaceholder", "480", "270", "9.0.115", false, flashvars, params, attributes);
}

var player = null; 
function playerReady(wtPlayer) { 
	player = window.document[wtPlayer.id]; 
	printPlaylistData();
}

function printPlaylistData() {
	var plst = null;
	plst = player.getPlaylist();
	if (plst) {
		playListItem = new Array();
		playListDataTitle = new Array();
		playListDataAuthor = new Array();
		playListDataDescription = new Array();
		playListDataEmbed = new Array();
		for(var itm in plst) { 
			playListDataTitle[itm] = plst[itm].title;
			playListDataAuthor[itm] = plst[itm].author;
			playListDataDescription[itm] = plst[itm].description;
			playListDataEmbed[itm] = plst[itm].file;
			if(itm=='15') {
				playListItemWelcome = '<div id="wtPlayListItem'+itm+'" onclick="player.sendEvent(';
				playListItemWelcome += "'LOAD', '"+plst[itm].file+"');JavaScript:player.sendEvent('PLAY');Javascript:showDescription('"+itm+"');selectPlayList('"+itm+"')";
				playListItemWelcome += '" onmouseover="hoverPlayList('+itm+')"';
				playListItemWelcome += '" onmouseout="unHoverPlayList('+itm+')">';
				playListItemWelcome += '<img src="'+plst[itm].image+'" />';
				playListItemWelcome += plst[itm].title;
				playListItemWelcome += '<br /><span class="author">'+plst[itm].author+'</span>';
				playListItemWelcome += '</div>';
				showDescription(itm);
			} else {
				playListItem[itm] = '<div id="wtPlayListItem'+itm+'" onclick="player.sendEvent(';
				playListItem[itm] += "'LOAD', '"+plst[itm].file+"');JavaScript:player.sendEvent('PLAY');Javascript:showDescription('"+itm+"');selectPlayList('"+itm+"')";
				playListItem[itm] += '" onmouseover="hoverPlayList('+itm+')"';
				playListItem[itm] += '" onmouseout="unHoverPlayList('+itm+')">';
				playListItem[itm] += '<img src="'+plst[itm].image+'" />';
				playListItem[itm] += plst[itm].title;
				playListItem[itm] += '<br /><span class="author">'+plst[itm].author+'</span>';
				playListItem[itm] += '</div>';
			}
		}
		var fullPlayList = '';
		fullPlayList += playListItemWelcome;
		for (i=playListItem.length-1; i > -1; i--)
		{
			if(i != 15){
				fullPlayList += playListItem[i];
			}
		}
		var tmp = document.getElementById("wtPlayList");
		if (tmp) { 
			tmp.innerHTML = fullPlayList;
			player.sendEvent('LOAD', 'http://oncourss.1bigidea.com/0-intro.flv');
			player.sendEvent('PLAY');
 			buildPlayListStyles();
		}
	} else {
		setTimeout("printPlaylistData()",100);
	}	
}

function showDescription(descID) {
	document.getElementById('theTitle').innerHTML=playListDataTitle[descID];
	document.getElementById('theDescription').innerHTML=playListDataDescription[descID];
}

function buildPlayListStyles(){
	for(i=0;i<=playListDataTitle.length;i++){
		currentDiv="wtPlayListItem"+i;
		document.getElementById(currentDiv).style.float="left";
		document.getElementById(currentDiv).style.clear="left";
		if(navigator.appName!="Microsoft Internet Explorer"){
			if(playListDataTitle.length<=6){
				document.getElementById(currentDiv).style.width="224px";
			} else {
				document.getElementById(currentDiv).style.width="207px";
			}
		}
		document.getElementById(currentDiv).style.height="59px";
		document.getElementById(currentDiv).style.margin="1px";
		document.getElementById(currentDiv).style.fontFamily="Arial";
		document.getElementById(currentDiv).style.fontWeight="bold";
		document.getElementById(currentDiv).style.fontSize=".7em";
		document.getElementById(currentDiv).style.color="#221e1f";
		document.getElementById(currentDiv).style.backgroundColor="#bfbfbf";
		if(i==15) {
			document.getElementById(currentDiv).style.color="#221e1f";
			document.getElementById(currentDiv).style.backgroundColor="#ffffff";
		}
		document.getElementById(currentDiv).style.cursor="default";
	}
}

function hoverPlayList(divID){
	if(selectedDivID!=divID){
		currentDiv="wtPlayListItem"+divID;
		document.getElementById(currentDiv).style.color="#bfbfbf";
		document.getElementById(currentDiv).style.backgroundColor="#221e1f";
	}
}

function unHoverPlayList(divID){
	if(selectedDivID!=divID){
		currentDiv="wtPlayListItem"+divID;
		document.getElementById(currentDiv).style.color="#221e1f";
		document.getElementById(currentDiv).style.backgroundColor="#bfbfbf";
	}
}

function selectPlayList(divID){
	if(selectedDivID!=-1){
		currentDiv="wtPlayListItem"+selectedDivID;
		document.getElementById(currentDiv).style.color="#221e1f";
		document.getElementById(currentDiv).style.backgroundColor="#bfbfbf";
	}
	selectedDivID=divID;
	currentDiv="wtPlayListItem"+divID;
	document.getElementById(currentDiv).style.color="#221e1f";
	document.getElementById(currentDiv).style.backgroundColor="#ffffff";
	if(document.getElementById('embed').style.display=="block"){
		displayEmbed();
	}
}

function displayEmbed(){
	if(selectedDivID != -1){
		document.getElementById('embed').innerHTML='To embed &#147;'+playListDataTitle[selectedDivID]+'&#148;, simply copy and paste this into your html code: <br /> <textarea><embed width="480" height="270" flashvars="file='+playListDataEmbed[selectedDivID]+'" quality="high" scale="noscale" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://kayakfishingtales.oncourss.com/wp-content/plugins/wordtube/player.swf" wmode="transparent"></embed></textarea><a href="JavaScript:void[0]" onclick="hideEmbed();">CLOSE</a>';
	} else {
		document.getElementById('embed').innerHTML='To embed &#147;'+playListDataTitle[0]+'&#148;, simply copy and paste this into your html code: <br /> <textarea><embed width="480" height="270" flashvars="file='+playListDataEmbed[0]+'" quality="high" scale="noscale" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://kayakfishingtales.oncourss.com/wp-content/plugins/wordtube/player.swf" wmode="transparent"></embed></textarea><a href="JavaScript:void[0]" onclick="hideEmbed();">CLOSE</a>';
	}
	document.getElementById('embed').style.display="block";
}

function hideEmbed(){
	document.getElementById('embed').style.display="none";
}

