Array.prototype.shuffle = function (){ 
	for(var rnd, tmp, i=this.length; i; rnd=parseInt(Math.random()*i), tmp=this[--i], this[i]=this[rnd], this[rnd]=tmp);
};

function do_video()
{
	//build player_parameter
	player_parameter='videofile=' + videofile + '&assetTab=ov/' + assetTab + '&assetURL=' + courseURL;
	if (prerolls.length) 
	{
		if (prerolls.length>1) prerolls.shuffle();
		player_parameter += '&preroll=' + prerolls[0][0];
	}
	if (postrolls.length) 
	{
		if (postrolls.length>1) postrolls.shuffle();
		player_parameter += '&postroll=' + postrolls[0][0];
	}
	//add optional argument (usually prewait)
	if (arguments[0]) player_parameter += "&" + arguments[0];
	//build flash
	ret = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="440" height="310" id="embed_player" align="middle">';
	ret += '<param name="allowScriptAccess" value="sameDomain" />';
	ret += '<param name="movie" value="427player.swf?' + player_parameter + '" />';
	ret += '<param name="quality" value="high" />';
	ret += '<param name="bgcolor" value="#FFFFFF" />';
	ret += '<param name="allowFullScreen" value="true" />';
	ret += '<param name=FlashVars value="ident=85.png&anim_default=anim.swf">';
	ret += '<embed src="427player.swf?' + player_parameter + '" FlashVars="ident=85.png&anim_default=anim.swf" quality="high" bgcolor="#FFFFFF" allowfullscreen="true" width="440" height="310" id="embed_player" name="embed_player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	ret += '</object>';
	document.getElementById('player_holder').innerHTML = ret;
}

function do_jam()
{
	ret = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="440" height="310" id="embed_player" align="middle">';
	ret += '<param name="allowScriptAccess" value="sameDomain" />';
	ret += '<param name="movie" value="427player_mp3.swf?f=gj/' + mp3 + '&bg_img=JAMBACK2.jpg" />';
	ret += '<param name="quality" value="high" />';
	ret += '<param name="bgcolor" value="#FFFFFF" />';
	ret += '<param name="allowFullScreen" value="true" />';
	ret += '<param name=FlashVars value="">';
	ret += '<embed src="427player_mp3.swf?f=gj/' + mp3 + '&bg_img=JAMBACK2.jpg" FlashVars="" quality="high" bgcolor="#FFFFFF" allowfullscreen="true" width="440" height="310" id="embed_player" name="embed_player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	ret += '</object>';
	document.getElementById('player_holder').innerHTML = ret;
}

function do_chart()
{
	document.getElementById('player_holder').style.verticalAlign='top'
	document.getElementById('player_holder').innerHTML = "<table id='chart_table'><tr><td><div id='chart_div'><b>Today’s Lesson Chart</b><p>If you already have Adobe Reader, click the icon below to open today's lesson chart.<p><a href=http://adobe.com TARGET=_blank><U>Download a free version</U></a> of Adobe Reader.<P><A HREF='" + pdf + "'><SMALL><U>Click to open the chart now!</U></SMALL><P><IMG BORDER=0 SRC=images/clickopen.gif></a></div></td></tr></table>";
}

function do_ptab()
{
	document.getElementById('player_holder').style.verticalAlign='top'
	document.getElementById('player_holder').innerHTML = "<table id='ptab_table'><tr><td><div id='ptab_div'><b>Today’s Power Tab File</b><p>If you have Power Tab installed, then simply click the icon to open today's Power Tab now.</p><p><a href=http://www.power-tab.net/guitar.php target=_blank>Download a free version</a> of Power Tab for PC.</p><p>Mac users can download the Power Tab file, but must use <a href=http://truefire.com/list.html?store=software_gear&item=6697 target=_blank>Guitar Pro</a> to import and play the file.</p><p><a href='" + tab + "'><small>Click to open the Power Tab now!</small></p><p><img border=0 src=images/clickopen.gif></a></p></div></td></tr></table>";
}

function do_text()
{
	document.getElementById('player_holder').innerHTML = "<table id='text_table'><tr><td><div id='text_div'><b>"+lessonname+"</B><P>"+text +"</div></td></tr></table>";
}


function all_done()
{
//
}

function attach_toggle_color(divname) {
 var section_div = document.getElementById(divname);
 var section_links = section_div.getElementsByTagName("a");
 for(i = 0; i < section_links.length; i++) {
   section_links[i].onclick=function(){
    var section_div = document.getElementById(divname);
    var section_links = section_div.getElementsByTagName("a");
    if(this.href.indexOf("javascript:do_")!=-1){
     for(i = 0; i < section_links.length; i++)
      section_links[i].className='color_off';
     this.className = 'color_on';
    }
   }
 }
}

function hideHelp()
{
	help_win.close();
}

function showHelp()
{
	help_win=window.open('http://truefiretv.net/tfhome/help.html', 'help_window', 'scrollbars=yes,width=300,height=300'); 
	help_win.focus();
}

// ======
do_video("prewait=true");
