// USATunes Javascript functions
// Assumes that Prototype is installed!
// Written by Dougie Henderson

function startMusic(mp3File, bandName, songTitle)
{
	var flash;
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		flash = window.usatunesMP3Player;
	}
	else
	{
		flash = window.document.usatunesMP3Player;
	}
	flash.jsStart(mp3File, bandName, songTitle);
}

function stopMusic()
{
	var flash;
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		flash = window.usatunesMP3Player;
	}
	else
	{
		flash = window.document.usatunesMP3Player;
	}
	flash.jsStop();
}

function popupMP3Player()
{
	// Popup the MP3Player in a popup window
	window.open('mp3player.php', 'USATunesMP3Player', 'location=0,status=0,toolbar=0,resizable=0,scrollbars=0,width=400,height=400');
}

function embedFlash(parentDivID, className, width, height, idName, movieName, backColor)
{
	// Construct the Object and Embed tags for this Flash movie
	var objectHTML = '<object class="' + className + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	objectHTML += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	objectHTML += ' width="' + width + '" ';
	objectHTML += ' height="' + height + '" ';
	objectHTML += ' id="' + idName + '" ';
	objectHTML += ' align="middle">';
	
		objectHTML += '<param name="allowScriptAccess" value="always" />';
		objectHTML += '<param name="movie" value="' + movieName + '" />';
		objectHTML += '<param name="quality" value="high" />';
		objectHTML += '<param name="bgcolor" value="' + backColor + '" />';
		objectHTML += '<param name="wmode" value="transparent" />';

		objectHTML += '<embed ';
		objectHTML += ' src="' + movieName + '" ';
		objectHTML += ' quality="high" ';
		objectHTML += ' bgcolor="' + backColor + '" ';
		objectHTML += ' width="' + width + '" ';
		objectHTML += ' height="' + height + '" ';
		objectHTML += ' name="' + idName + '" ';
		objectHTML += ' id="' + idName + '" ';
		objectHTML += ' align="middle" ';
		objectHTML += ' allowScriptAccess="always" ';
		objectHTML += ' type="application/x-shockwave-flash" ';
		objectHTML += ' pluginspage="http://www.macromedia.com/go/getflashplayer" ';
		objectHTML += ' wmode="transparent" />';
		
	objectHTML += ' </object>';
	
	// Set the Parent Div's InnertHTML
	$(parentDivID).innerHTML = objectHTML;
	
	return true;
}
