var DynaSound = new Class({
	sounds: new Array(),
	disabled: false,
	flashWorking: false,

	initialize: function(url, snds){
		this.sounds = snds;
		this.flashWorking=false;
		this.mySwiff = new Swiff(url,{
			width: 1, 
			height: 1, 
			container: $('swfContainer'), 
			swLiveConnect: true,
			callBacks: {
				load: this.initSounds
			}
		});
	},
	
	initSounds: function() {
		this.sound = this.mySwiff.toElement();

		if((Browser.ie && this.sound.data.indexOf('dynasound.swf')!=-1) || (Browser.ie && this.sound.innerHTML.indexOf('dynasound.swf')!=-1)) {
			this.flashWorking=true;
		}

		if (this.sounds) {
			for (var cs=0; cs<this.sounds.length; cs++) {
				Swiff.remote(this.sound,'loadSound',this.sounds[cs],this.sounds[cs]);
			}
		}
	},
	
	playBombExplosionSound: function() {
		if (this.flashWorking && !this.disabled)
			Swiff.remote(this.sound,'playSound','bomb4');
	},
	
	playBGSound: function() {
		if (this.flashWorking && !this.disabled)
			Swiff.remote(this.sound,'playSoundManyTimes','bgsound',999);
	},
	
	playSound: function(soundName) {
		if (this.flashWorking && !this.disabled)
			Swiff.remote(this.sound,'playSound',soundName);
	},
	
	stopBGSound: function() {
		if (this.flashWorking)
			Swiff.remote(this.sound,'stopSound','bgsound');
	},
	
	stopBombSound: function() {
		if (this.flashWorking)
			Swiff.remote(this.sound,'stopSound','bomb');
	},
	
	setVolume: function(volume) { // volume between 0 and 100
		if (volume<0 || volume>100)
			return;
		
		if (this.flashWorking){
			Swiff.remote(this.sound,'setVolume','bomb',volume/100);
			Swiff.remote(this.sound,'setVolume','bgsound',volume/100);
		}
	},
	
	disable: function() {
		this.disabled = true;
	},
	
	enable: function() {
		this.disabled = false;
	}
});
