joo.classLoader.prepare("package joo.sound",[""],
"public interface SoundBridge2",function($jooPublic,$jooPrivate){with(joo.sound)with($jooPublic)with($jooPrivate)return[

,

,

];},[]
);joo.classLoader.prepare(


















"package joo.sound",[

"import joo.html.Browser",
"import joo.html.Document2",
"import joo.html.Element2",
"import joo.util.TimedExecutor",
"import swfobject",""],

"public class Sound",function($jooPublic,$jooPrivate){with(joo.sound)with($jooPublic)with($jooPrivate)return[function(){joo.classLoader.init(Browser);},

"private static const",{DEBUG:false},
"private static const",{FLASH_CONTAINER:function(){return((Browser.ENGINE==Browser.ENGINE_IE6||Browser.ENGINE==Browser.ENGINE_IE7||Browser.ENGINE==Browser.ENGINE_OPERA
?window:window.document));}},
"private static const",{SWF_LOCATION:"SoundBridge2.swf"},
"private static const",{SWF_ID:"__SoundBridge__"},
"private static var",{INSTANCES:function(){return([]);}},
"private static var",{soundBridge: undefined},
"private static var",{soundAvailable: undefined},

"public static function init",function(onInit){
if(soundAvailable!==undefined){
onInit(soundAvailable);
return;
}
var soundElement=Document2.getInstance().createElement("div");
soundElement.setId(SWF_ID);
Document2.getInstance().getBody().appendChild(soundElement);
swfobject.embedSWF(SWF_LOCATION,SWF_ID,"0","0","8.0.0","",{id:SWF_ID},{allowScriptAccess:"always"});

new TimedExecutor(function(){
trace("Waiting for SoundBridge...");
soundBridge=FLASH_CONTAINER[SWF_ID];
if(!soundBridge||"nodeName"in soundBridge&&soundBridge["nodeName"]["toLowerCase"]()=="div"
||typeof soundBridge["data"]=="string"&&soundBridge["data"]["substring"](0,4)=="file"){
trace("SoundBridge not found!");
soundAvailable=false;
onInit(false);
return false;
}
if(typeof soundBridge.proxyMethods!="function")
return undefined;
soundAvailable=true;
if(DEBUG)
trace("SoundBridge initialized, calling onLoad handler!");
if(typeof onInit=="function")
onInit(true);
return false;
},100).start();
},

"public static function isAvailable",function(){
return soundAvailable;
},

"public function Sound",function(url,startImmediately){if(arguments.length<2){startImmediately=false;}
this[$super]();
this[$index]=soundBridge.newSound();
INSTANCES[this[$index]]=this;
if(url){
this.loadSound(url,false);
if(startImmediately){
this.start();
}
}
},

"private function call",function(name,arguments){
if(soundBridge){
if(DEBUG)
trace("Sound#call "+name+" on sound #"+this[$index]);
return soundBridge.proxyMethods(this[$index],name,arguments);
}
return undefined;
},

"public function loadSound",function(url,streaming){
this[$call]("loadSound",[url,streaming]);
},

"public function start",function(secondOffset,loops){
if(this[$loaded]){
this[$call]("start",secondOffset===undefined?[]:[secondOffset,loops]);
}else{
this[$startOnLoad]=function(){
this.start(secondOffset,loops);
}.bind(this);
}
},

"public function stop",function(){
this[$call]("stop",[]);
},

"public function fade",function(duration,targetVolume){
var startVolume=this.getVolume();
var volumeDelta=targetVolume-startVolume;

var sound=this;
var startTime=new Date().getTime();
this[$fader]=new TimedExecutor(function(){
var timeOffset=new Date().getTime()-startTime;
var volume=startVolume+volumeDelta*timeOffset/duration;

var result=undefined;
if(volumeDelta<0?volume<=targetVolume:volume>=targetVolume){
if(targetVolume==0){
sound.stop();
volume=startVolume;
}else{
volume=targetVolume;
}
result=false;
}
sound.setVolume(volume);
return result;
},100);
this[$fader].start();
},

"public function getId3",function(){
return this[$call]("id3",[]);
},

"public function getPan",function(){
return this[$call]("getPan",[]);
},

"public function getTransform",function(){
return this[$call]("getTransform",[]);
},

"public function getVolume",function(){
return this[$call]("getVolume",[]);
},

"public function setPan",function(value){
this[$call]("setPan",[value]);
return this;
},

"public function setTransform",function(transformObject){
this[$call]("setTransform",[transformObject]);
return this;
},

"public function setVolume",function(value){
this[$call]("setVolume",[value]);
return this;
},

"public function getDuration",function(){
return this[$call]("getDuration",[]);
},

"public function getPosition",function(){
return this[$call]("getPosition",[]);
},

"public function getBytesLoaded",function(){
return this[$call]("getBytesLoaded",[]);
},

"public function getBytesTotal",function(){
return this[$call]("getBytesTotal",[]);
},

"public var",{onLoad:function(){return((function onLoad(success){
}));}},

"public function internalOnLoad",function(success){
this[$loaded]=true;
if(typeof this[$startOnLoad]=="function"){
this[$startOnLoad]();
}
this.onLoad(success);
},

"private static function getInstance",function(index){
return INSTANCES[index];
},

"public static function callbackOnLoad",function(index,success){
trace("Sound.onLoad("+success+") index="+index);
getInstance(index).internalOnLoad(success);
},

"public var",{onSoundComplete:function(){return((function onSoundComplete(){
}));}},

"public static function callbackOnSoundComplete",function(index){
trace("Sound:onSoundComplete() event triggered");
getInstance(index).onSoundComplete();
},

"public function onID3",function(){
},

"public static function callbackOnID3",function(index){
trace("Sound:onID3() event triggered");
getInstance(index).onID3();
},

"private static function trace",function(value){
if(DEBUG){
trace(value);
}
},

"private var",{index: undefined},
"private var",{loaded:false},
"private var",{startOnLoad: undefined},
"private var",{fader: undefined},
];},["init","isAvailable","callbackOnLoad","callbackOnSoundComplete","callbackOnID3"]
);