var player = {
	sound: 'dlg',
	status: false,
	ready: false,
	play: function(){
		if (!this.ready || this.status == 'playing' || this.status == 'paused') return false;
		soundManager.play(this.sound);
		this.updateStatus('playing');
	},
	pause: function(){
		if (!this.ready || !this.status == 'playing') return false;
		soundManager.pause(this.sound);
		this.updateStatus('paused');
	},
	resume: function(){
		if (!this.ready || !this.status == 'paused') return false;
		soundManager.resume(this.sound);
		this.updateStatus('playing');
	},
	toggle: function(){
		if (!this.ready) return false;
		if (this.status == 'paused') return this.resume(this.sound);
		else if (this.status == 'playing') return this.pause(this.sound);
	},
	stop: function(){
		if (!this.ready) return false;
		soundManager.stopAll();
		this.updateStatus('stopped');
	},
	updateStatus: function(status){
		this.status = status;
		['playing','paused','stopped'].each(function(stat){
			if (this.status == stat) $('player').addClassName(stat);
			else $('player').removeClassName(stat);
		}.bind(this));
	}
}

soundManager.flashVersion = 8;
soundManager.waitForWindowLoad = true;
soundManager.defaultOptions.volume = 33;
soundManager.debugMode = false;
soundManager.onfinish = function(){ player.updateStatus('stopped'); };
soundManager.onload = function(){
	soundManager.createSound('dlg', 'music/dlg.mp3');
	player.ready = true;
	player.sound = 'dlg';
	player.play();
};
