function SWFSoundPlayer() {
	try {
		if (!SWFSoundPlayer.inited) SWFSoundPlayer._setupSWFPlayer();
		SWFSoundPlayer.inited = true;
	} catch(err){debug("SWFSoundPlayer: "+err)};
};
SWFSoundPlayer.useStreaming = true;
SWFSoundPlayer.targetElement = document.body;
SWFSoundPlayer.nameDIV = "swfSoundPlayerDIV";
SWFSoundPlayer.sourceSWF = "swf/SoundPlayer.swf";
SWFSoundPlayer.prototype.onProgress = null;
SWFSoundPlayer.prototype.onTimecode = null;
SWFSoundPlayer.prototype.onLoadProgress = null;
SWFSoundPlayer.prototype.onStartPlay = null;
SWFSoundPlayer.prototype.onCancelPlay = null;
SWFSoundPlayer.prototype.onFinishPlay = null;
SWFSoundPlayer.prototype.onStartLoad = null;
SWFSoundPlayer.prototype.onFinishLoad = null;

// public vars
SWFSoundPlayer.setup = function(id) {
	if (!SWFSoundPlayer.inited) SWFSoundPlayer._setupSWFPlayer();
	SWFSoundPlayer.inited = true;
}


// private vars
SWFSoundPlayer._swfObject = null;
SWFSoundPlayer._swfDIV = null;
SWFSoundPlayer.inited = false;
SWFSoundPlayer._lastInstance = null;

// public methods
SWFSoundPlayer.prototype.play = function(src) {
	// call playMP3
	if (SWFSoundPlayer._lastInstance != this) {
		if (SWFSoundPlayer._lastInstance) {
			SWFSoundPlayer._lastInstance.stop();
		}
	}
	SWFSoundPlayer._lastInstance = this;
	SWFSoundPlayer._swfObject.playMP3(src);
}
SWFSoundPlayer.prototype.plays = function(src) {
	return SWFSoundPlayer._swfObject.playsMP3(src);
}
SWFSoundPlayer.prototype.stop = function() {
	// call stopMP3
	SWFSoundPlayer._swfObject.stopMP3();
}

// private methods
SWFSoundPlayer._setupSWFPlayer = function() {
	// setup DIV
	SWFSoundPlayer._swfDIV = document.createElement("div");
	SWFSoundPlayer._swfDIV.setAttribute("id",SWFSoundPlayer.nameDIV);
	SWFSoundPlayer._swfDIV.style.visibility = "visible";
	SWFSoundPlayer._swfDIV.style.position = "absolute";
	SWFSoundPlayer._swfDIV.style.bottom = "0px";
	SWFSoundPlayer._swfDIV.style.right = "0px";
	SWFSoundPlayer.targetElement.appendChild(SWFSoundPlayer._swfDIV);
	// setup sound player
	var so = new SWFObject(SWFSoundPlayer.sourceSWF,"_swfSoundPlayerSWF","1","1","8","#ff0000");
	so.addParam("menu","false");
	so.addParam("allowscriptaccess","always");
	so.addParam("wmode","transparent");
	so.addVariable("useStreaming", SWFSoundPlayer.useStreaming ? "1" : "0");
	so.write(SWFSoundPlayer.nameDIV);
	SWFSoundPlayer._swfObject = document.getElementById("_swfSoundPlayerSWF");
	SWFSoundPlayer.inited = true;
}

// listeners
SWFSoundPlayer._onProgress = function(progress,src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onProgress) return;
	SWFSoundPlayer._lastInstance.onProgress(progress,src);
}
SWFSoundPlayer._onTimecode = function(time,src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onTimecode) return;
	SWFSoundPlayer._lastInstance.onTimecode(time,src);
}
SWFSoundPlayer._onLoadProgress = function(progress,src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onLoadProgress) return;
	SWFSoundPlayer._lastInstance.onLoadProgress(progress,src);
}
SWFSoundPlayer._onStartPlay = function(src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onStartPlay) return;
	SWFSoundPlayer._lastInstance.onStartPlay(src);
}
SWFSoundPlayer._onFinishPlay = function(src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onFinishPlay) return;
	SWFSoundPlayer._lastInstance.onFinishPlay(src);
}
SWFSoundPlayer._onCancelPlay = function(src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onCancelPlay) return;
	SWFSoundPlayer._lastInstance.onCancelPlay(src);
}
SWFSoundPlayer._onStartLoad = function(src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onStartLoad) return;
	SWFSoundPlayer._lastInstance.onStartLoad(src);
}
SWFSoundPlayer._onFinishLoad = function(src) {
	if (!SWFSoundPlayer._lastInstance) return;
	if (!SWFSoundPlayer._lastInstance.onFinishLoad) return;
	SWFSoundPlayer._lastInstance.onFinishLoad(src);
}
