
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','sounder/play/typewww/no0/st1/pid'+soundProductId+'/listen.mp3');
			soundManager.play('muzoSound', {onfinish:doStopSm, volume:100});
			soundImg.src = "/player/time.gif";
	}
}

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

	}
}


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/graj.gif";
		} else {
			/* maly obrazek */	
			soundImg.src="/player/nutka.png";

		}
	}
}

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

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

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

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

function stopp() {
	if(playerLoaded) {
		var soundImg = document.getElementById(playingSoundId);
		if(playingSound) {
			playingSound = false;
			doStopSound();		
			
				/* ten sam plik, wiec konczymy */
				playingSoundId=null;
				return;
			
		}
	}
}