function deletePlayer(theWrapper, thePlaceholder, thePlayerId) { 
        swfobject.removeSWF(thePlayerId);
        var tmp=document.getElementById(theWrapper);
        if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; }
}


function createPlayer(thePlaceholder, thePlayerId, theFile) {
        var flashvars = {
                file:theFile, 
                autostart:"true",
                playlist:"",
				type:"sound",
				skin:"player_SkinSnel",
				window:"opaque"
        }
        var params = {
                allowfullscreen:"false", 
                allowscriptaccess:"always"
        }
        var attributes = {
                id:thePlayerId,  
                name:thePlayerId
        }
        swfobject.embedSWF("player.swf", thePlaceholder, "300", "30", "9.0.115", false, flashvars, params, attributes);
}

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

function initPlayer(theFile) { 
        deletePlayer('player1wrapper', 'placeholder1', 'player1'); 
        createPlayer('placeholder1', 'player1', encodeURIComponent(theFile));
}


function getWhatVersion(){ 
  // ie 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 


function launchAlert(){
	var version = getWhatVersion().split(',').shift(); 
	if(version < 10){ 
	  //alert("To hear the content at WildWhirled.com, you must upgrade your flash player.");
	  popUp('flash.html','console',230,350);return false;
	}else{ 
	  initPlayer();
	  //alert(""); 
	}
}

var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
 		if (newWin != null && !newWin.closed)
   			newWin.close();
			
 		var strOptions="";
 		if (strType=="console")
   			strOptions="resizable,height="+strHeight+",width="+strWidth;
			
 		if (strType=="fixed")
  			strOptions="status,height="+strHeight+",width="+strWidth;
			
 		if (strType=="elastic")
   			strOptions="toolbar,menubar,scrollbars,"+"resizable,location,height="+strHeight+",width="+strWidth;
			 newWin = window.open(strURL, 'newWin', strOptions);
			 newWin.focus();
}



function updatePlaylist(theID, theURL, theCat, theDisc, theTitle) { 
      var plist=document.getElementById(theID);
	  var content=plist.innerHTML;
	  var theAction='LOAD';
	  var theEncodedURL=encodeURIComponent(theURL);
	  var theNowPlayingId='nowplaying'
	  var thePTitle= ' ' + theCat + ' Disc ' + theDisc + ': ' + theTitle;

        if (plist) {
			//plist.innerHTML = content + '&nbsp;&bull;<a href ="javascript:;" onClick="var url=\'' + theURL  + '\';player.sendEvent(\'' + theAction + '\',url)\" class="playerlink">'+ theTitle +'</a><br/>';
			plist.innerHTML = content + '&nbsp;&bull;<a href ="javascript:;" onClick="var url=\'' + theURL  + '\';player.sendEvent(\'' + theAction + '\',url);updateNowPlaying(\'' + theNowPlayingId + '\',\'' + thePTitle + '\')\" class="playerlink">'+ thePTitle +'</a><br/>';
			//alert('<a href ="javascript:;" onClick="var url=\'' + theURL  + '\';player.sendEvent(\'' + theAction + '\',url)\" class="playerlink">'+ theTitle +'</a>');
			//alert('&nbsp;&bull;<a href ="javascript:;" onClick="var url=\'' + theURL  + '\';player.sendEvent(\'' + theAction + '\',url);updateNowPlaying(\'' + theNowPlayingId + '\',\'' + thePTitle + '\')\" class="playerlink">'+ thePTitle +'</a><br/>');
			}
}

function updatePlaylistStatic(theID, theURL, theTitle) { 
      var plist=document.getElementById(theID);
	  var content=plist.innerHTML;
	  var theAction='LOAD';
	  var theEncodedURL=encodeURIComponent(theURL);
	  var theNowPlayingId='nowplaying'

        if (plist) {

			plist.innerHTML = content + '&nbsp;&bull;<a href ="javascript:;" onClick="var url=\'' + theURL  + '\';player.sendEvent(\'' + theAction + '\',url);updateNowPlaying(\'' + theNowPlayingId + '\',\'' + theTitle + '\')\" class="playerlink">'+ theTitle +'</a><br/>';
			}
}

function updateNowPlaying(theID,theNPTitle) { 
      var nplaying=document.getElementById(theID);

        if (nplaying) {
			nplaying.innerHTML = '&nbsp;T&nbsp;&rArr;&nbsp;' + theNPTitle;
			}
}


