/**
* Player-Only javascript
*/

/**
 * Unobtrusive Javascript
 * - Keep the views clear of javascripts by 
 *   working on the DOM when ready
 */ 
$(document).ready(function() {

  ////
	// initialize all frontend flash pieces
	///////////////////////////////////////
	initFlashElements();

});

function initFlashElements() {
  
  ////
	// popup media player
	/////////////////////
	if ($('#popupPlayer').length > 0) {
	  var parts = $('#popupPlayer').attr('rel');
	  parts = parts.split(':');
	  
	  var artistID = 0;
	  var songID = 0;
	  
	  if (parts[0] != undefined || parts[0] != 0) artistID = parts[0];
	  if (parts[1] != undefined || parts[1] != 0) songID = parts[1];
    
    if (artistID == 0 && songID == 0) {
      swfobject.embedSWF(
        "/flash/swf/popup_player.swf",
        "popupPlayer",
        "480", "425",
        "9.0.0",
        "/flash/utils/expressinstall.swf",
        {},
        {wmode: 'transparent'}
      );
      
    } else if (artistID != 0 && songID == 0) {
      swfobject.embedSWF(
        "/flash/swf/popup_player.swf",
        "popupPlayer",
        "480", "425",
        "9.0.0",
        "/flash/utils/expressinstall.swf",
        {artistID: artistID},
        {wmode: 'transparent'}
      );
      
    } else if (artistID == 0 && songID != 0) {
      swfobject.embedSWF(
        "/flash/swf/popup_player.swf",
        "popupPlayer",
        "480", "425",
        "9.0.0",
        "/flash/utils/expressinstall.swf",
        {songID: songID},
        {wmode: 'transparent'}
      );
      
    } else if (artistID != 0 && songID != 0) {
      swfobject.embedSWF(
        "/flash/swf/popup_player.swf",
        "popupPlayer",
        "480", "425",
        "9.0.0",
        "/flash/utils/expressinstall.swf",
        {artistID: artistID, songID: songID},
        {wmode: 'transparent'}
      );
    }
	}
};