var isScriptIncluded=0;
function audioGetFullObject(url,auto,loop,invisible)
{return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-mplayer2" data="'+url+'"'+(invisible?' style="position:absolute; height:0px; width:0px"':'')+'><param name="url" value="'+url+'" /><param name="autostart" value="true" /><param name="playCount" value="'+(!loop?1:100)+'" />'+(invisible?'<param name="uiMode" value="invisible" />':'')+'<param name="volume" value="'+(auto?this.volume:0)+'" /></object>'}
function audioGetWMPObject(url,auto,loop,invisible)
{return audioGetFullObject(url,auto,loop,invisible).replace(' type="application/x-mplayer2"',"").replace(' data="'+url+'"',"")}
function audioGetQTObject(url,auto,loop,invisible)
{return audioGetFullObject(url,auto,loop,invisible).replace(' data="'+url+'"',"")}
function audioGetObject(plugin,url,auto,loop,invisible)
{return plugin=="qt"?audioGetQTObject(url,auto,loop,invisible):audioGetWMPObject(url,auto,loop,invisible)}
function fAudio(url,auto,loop,invisible,forcePlugin)
{this.url=url;
this.id=url.replace(/[^A-Za-z\d_]/g,"-");
this.auto=auto;
this.loop=loop;
this.invisible=invisible;
this.playState=auto;
this.volume=100;
var ua=navigator.userAgent;
this.browser=ua.indexOf("MSIE")!=-1?"IE":ua.indexOf("Chrome")!=-1?"Chrome":ua.indexOf("Safari")!=-1?(ua.indexOf("Macintosh")!=-1?"SafariMac":"SafariWin"):ua.indexOf("Opera")!=-1?"Opera":ua.indexOf("Firefox")!=-1?"Firefox":"other";
this.plugin=this.browser=="IE"?"wmp":this.browser=="SafariMac"?"qt":"flash";
if(forcePlugin){this.plugin=forcePlugin}
if(window.ActiveXObject&&this.plugin!="flash"){this.plugin="wmp"}
if(url.indexOf(".")==-1)
{if(this.plugin=="wmp"){this.url+=".wma"}
else{this.url+=".mp3"}}
if(false&&this.browser!="IE"&&this.url.match(/\.mp3$/i))
{var html5Audio=document.createElement("audio");
if(html5Audio&&html5Audio.canPlayType){var cpt=html5Audio.canPlayType("audio/mpeg");if(cpt!="no"&&cpt!=""){this.plugin="html5"}}}
this.fAudioObj(this.auto)}
fAudio.prototype.fAudioObj=function(autoArg)
{if(this.obj){this.remove()}
this.playState=0;
this.obj=this.plugin!="html5"?document.createElement("div"):document.createElement("audio");
this.obj.id=this.id;
if(this.invisible)
{this.obj.style.position="absolute";
//this.obj.style.top="-1000px";
this.obj.style.height="0px";
this.obj.style.width="0px";
this.obj.style.visibility="hidden"}
document.body.appendChild(this.obj);
if(this.plugin=="html5")
{this.getPlayerObj().autobuffer=true;this.getPlayerObj().autoplay=autoArg;this.getPlayerObj().controls=!this.invisible?true:false;this.getPlayerObj().src=this.url}
else if(this.plugin!="flash"){this.writePlayerHTML(autoArg)}
else{if(!isScriptIncluded)
{var script=document.createElement("script");
script.type="text/javascript";
script.src="audio_player/audio-player.js";
document.getElementsByTagName("head")[0].appendChild(script);
isScriptIncluded=1}
var tempThis=this;
function timeoutTask()
{if(tempThis.playState==0)
{var names=new Array("movie","allowfullscreen","allowscriptaccess","flashvars","wmode");
var values=new Array("audio_player/player.swf","false","always","soundFile="+tempThis.url+"&autostart=yes&loop="+(tempThis.loop?"yes":"no")+"&initialvolume="+(autoArg?tempThis.volume:0)+"&bufferlength=1","transparent");
var params="";
for(var i=0;i<names.length;i++)
{params+='<param name="'+names[i]+'" value="'+values[i]+'" />'}
//var styleHTML=' style="'+(tempThis.invisible?'position:absolute; z-index:1; top:0px; height:1px; width:1px':'height:24px; width:290px')+'"';
var styleHTML=' style="'+(tempThis.invisible?'':'height:24px; width:290px')+'"';
tempThis.obj.innerHTML='<object id="player" name="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+styleHTML+'>'+params+'<object type="application/x-shockwave-flash" data="audio_player/player.swf"'+styleHTML+'>'+params+'</object></object>';
tempThis.playState=autoArg;
}}
//setTimeout(timeoutTask,1000)
timeoutTask();
}}
fAudio.prototype.writePlayerHTML=function(autoArg)
{document.getElementById(this.id).innerHTML=audioGetObject(this.plugin,this.url,autoArg,this.loop,this.invisible)}
fAudio.prototype.getPlayerObj=function()
{return this.plugin!="html5"?this.obj.getElementsByTagName("object")[0]:this.obj}
fAudio.prototype.play=function()
{if(this.playState==-1){this.fAudioObj(1)}
else{if(this.playState==0&&(this.plugin=="wmp"||this.plugin=="flash"))
{this.setPosition(0);
this.setVolume(this.volume)}
if(this.plugin=="wmp"){this.getPlayerObj().controls.play()}
else if(this.plugin=="html5"){this.getPlayerObj().play()}
else if(this.plugin=="flash"){this.fAudioObj(1)/*this.getPlayerObj().sendEvent("PLAY","true")*/}//FIX
else{this.writePlayerHTML(1)}}
this.playState=1}
fAudio.prototype.pause=function()
{if(this.playState==1)
{if(this.plugin=="wmp"){this.getPlayerObj().controls.pause()}
else if(this.plugin=="html5"){this.getPlayerObj().pause()}
else if(this.plugin=="flash"){/*this.getPlayerObj().sendEvent("PLAY","false")*/}//FIX
this.playState=.5}}
fAudio.prototype.getDuration=function()
{if(this.plugin=="wmp"){return this.getPlayerObj().currentMedia.duration}
else if(this.plugin=="html5"){return this.getPlayerObj().duration}
else if(this.plugin="flash"){return -1/*this.getPlayerObj().getPlaylist()[0].duration*/}//FIX
else{return -1}}
fAudio.prototype.setPosition=function(time)
{if(this.plugin=="wmp"){this.getPlayerObj().controls.currentPosition=time}
else if(this.plugin=="html5"){this.getPlayerObj().currentTime=time}
else if(this.plugin=="flash"){/*this.getPlayerObj().sendEvent("SEEK",time)*/}}//FIX
fAudio.prototype.setPositionByDecimal=function(arg)
{this.setPosition(arg*this.getDuration())}
fAudio.prototype.setVolume=function(volume)
{this.volume=volume;
if(this.plugin=="wmp"){this.getPlayerObj().settings.volume=volume}
else if(this.plugin=="flash"){/*this.getPlayerObj().sendEvent("VOLUME",volume)*/}}//FIX
fAudio.prototype.stop=function()
{if(this.playState==1||this.playState==.5)
{if(this.plugin=="wmp"){this.getPlayerObj().controls.stop();this.playState=0}
else if(this.plugin=="html5"){this.getPlayerObj().stop();this.playState=0}
//else if(this.plugin=="flash"){this.getPlayerObj().sendEvent("STOP","true");this.playState=0}//FIX
else{this.remove()}}}
fAudio.prototype.remove=function()
{this.playState=-1;
this.obj.innerHTML="";
this.obj.parentNode.removeChild(this.obj)}