$(function(){if(typeof(swfobject)!="undefined"){if($("#playerContainer").length==0){$("body").append($('<div id="playerContainer"></div>').css("position","absolute").css("top","0px").css("left","0px").css("margin-right","-1px").css("margin-bottom","-1px").css("font-size","0px").css("width","1px").css("height","1px").css("background-color","#ff0000"))}var a={};var c={menu:false,wmode:"transparent",allowscriptaccess:"always",allowfullscreen:false};var b={id:"ply",name:"ply"};swfobject.embedSWF("/MyMusicShop/player.swf","playerContainer","1","1","9.0.0","/deploy/expressInstall.swf",a,c,b)}else{alert("Couldn't load the SWFobject for prelisten.")}});var isPlaying=null;var lastPlayed=null;var player;function playerReady(a){player=document.getElementById($(a).attr("id"));addListeners()}function bindPrelisten(a){a.prelistenButtonDefaultState().click(function(){$(".prelisten.playing").removeClass("playing");doPlay($(this));return false})}function doPlay(a){var b=a.attr("id");var c=null;if($(a)[0].tagName.toLowerCase()=="img"){c=a.attr("alt")}else{c=a.attr("rel")}if(c==""){alert("Prelisten error: File path must not be empty")}else{if($.inArray("mp3",c.toLowerCase().split("."))==-1){alert("Prelisten error: Could not detect mp3 extension in the file path")}else{if(c.indexOf("http://")==-1){alert("Prelisten error: Could not detect host name in the file path")}else{if(!isPlaying||isPlaying==null){if(lastPlayed!=b){player.sendEvent("LOAD",{file:c})}$(a).prelistenButtonDefaultState();isPlaying=b;player.sendEvent("PLAY")}else{player.sendEvent("PLAY");if(isPlaying==b){isPlaying=null;lastPlayed=b;$(a).prelistenButtonDefaultState()}else{$(a).prelistenButtonPlayingState();$("#"+isPlaying).prelistenButtonDefaultState();isPlaying=b;player.sendEvent("LOAD",{file:c});player.sendEvent("PLAY")}}}}}}$.fn.prelistenButtonPlayingState=function(){return $(this).each(function(){if($(this)[0].tagName.toLowerCase()=="img"){$(this).attr("src","/images/control_pause.gif").mouseover(function(){$(this).attr("src","/images/control_pause_h.gif")}).mouseout(function(){$(this).attr("src","/images/control_pause.gif")})}})};$.fn.prelistenButtonLoadingState=function(){return $(this).each(function(){$(this).addClass("loading").addClass("hidden").after('<img src="/images/indicator_arrows.gif" id="songLoading"/>')})};$.fn.prelistenButtonDefaultState=function(){return $(this).each(function(){if($(this)[0].tagName.toLowerCase()=="img"){$(this).attr("src","/images/control_play.gif").mouseover(function(){$(this).attr("src","/images/control_play_h.gif")}).mouseout(function(){$(this).attr("src","/images/control_play.gif")})}})};function addListeners(){if(player){player.addModelListener("STATE","stateListener")}else{setTimeout("addListeners()",100)}}function stateListener(b){var a=b.newstate;if(isPlaying!=null){if(a=="BUFFERING"){if($("#"+isPlaying).length>0){$("#"+isPlaying).prelistenButtonLoadingState()}}if(a=="PLAYING"){$("#songLoading").remove();$("#"+isPlaying.toString()).removeClass("loading").addClass("playing").removeClass("hidden").prelistenButtonPlayingState();if($(".prelisten.loading").length>0){$(".prelisten.loading").removeClass("loading")}}if(a=="PAUSED"){$("#"+isPlaying.toString()).removeClass("playing")}if(a=="COMPLETED"){$("#"+isPlaying.toString()).removeClass("playing").prelistenButtonDefaultState();isPlaying=null}}};
