
var playingSound = false;
var playingSoundId ;

var playerLoaded = false;


function playerLoadedFun() {
  playerLoaded = true;
  return true;
}


function playSound(soundId) {
	if(playerLoaded) {
		var soundImg = document.getElementById(soundId);
		if(playingSound) {
			playingSound = false;
			doStopSound();
			if(soundId == playingSoundId) {
				/* ten sam plik, wiec konczymy */
				return;
			}
		}
			playingSoundId = soundId;
			playingSound = true;
			var soundProductId = soundId.replace(/^snd/, '');		
			/*soundManager.createSound('muzoSound','http://www1.plus.pl/muzodajnia/sounder/play/typewww/no0/st1/pid'+soundProductId+'/listen.mp3');*/
			soundManager.createSound('muzoSound','../sounder/play/typewww/no0/st1/pid'+soundProductId+'/listen.mp3');
			soundManager.play('muzoSound', {onfinish:doStopSm, volume:100});
			soundImg.src = "../player/stop.gif";
	}
}

function playSoundSmall(soundId) {
	if(playerLoaded) {
		var soundImg = document.getElementById(soundId);
		if(playingSound) {
			playingSound = false;
			doStopSound();		
			if(soundId == playingSoundId) {
				/* ten sam plik, wiec konczymy */
				return;
			}
		}
			playingSoundId = soundId;
			playingSound = true;
			var soundProductId = soundId.replace(/^ssnd/, '');		
			/*soundManager.createSound('muzoSound','http://www1.plus.pl/muzodajnia/sounder/play/typewww/no0/st1/pid'+soundProductId+'/listen.mp3');*/
			soundManager.createSound('muzoSound','../sounder/play/typewww/no0/st1/pid'+soundProductId+'/listen.mp3');
			soundManager.play('muzoSound', {onfinish:doStopSmSmall, volume:100});
			soundImg.src = "../player/stopSmall.gif";
		
	}
}


function doStopSound() {
	soundManager.stopAll();
	soundManager.destroySound('muzoSound');
	if(playingSoundId) {
		var soundImg = document.getElementById(playingSoundId);
		var subSection = playingSoundId.substr(0,3);
		if(subSection == 'snd' ) {		
			/* duzy obrazek */
			soundImg.src = "../player/play.gif";
		} else {
			/* maly obrazek */
			soundImg.src = "../player/playSmall.gif";
		}
	}
}

function doStopSm() {
	soundManager.destroySound('muzoSound');

	if(playingSoundId) {
		var soundImg = document.getElementById(playingSoundId);
		soundImg.src = "../player/play.gif";
	}
}

function doStopSmSmall() {
	soundManager.destroySound('muzoSound');

	if(playingSoundId) {
		var soundImg = document.getElementById(playingSoundId);
		soundImg.src = "../player/playSmall.gif";
	}
}


