/* #################################################
# Project 	: Play Flash Stream Runtime
# Stand     : 09.07.06
# Autor		: Daniel Zander, Source-Media.com
#################################################### 
*/

var dir_ico = 'elm/ico/';
var url_pre = '/cnt/snd/';
var url_pst = '.mp3';

var uid = new Date().getTime();
var flashProxy = new FlashProxy(uid, '/elm/snd/JavaScriptFlashGateway.swf');

var tag = new FlashTag('/elm/snd/playsound.swf', 1, 1);
tag.setFlashvars('lcId='+uid);
tag.write(document);

var playing = false;
var fileid;


function play(id, url)
{
	if (fileid == id && playing)
	{
		flashProxy.call('stop');
		document.getElementById('snd'+fileid).src = dir_ico+"music2.gif";
		playing = false;
	} 
	
	else 
	{
		if (fileid && fileid != id)
			document.getElementById('snd'+fileid).src = dir_ico+"music0.gif";
			
 		// 1st argument: url of mp3 file
 		// 2nd argument: identifier for callback (playcomplete(id))
 		// 3rd argument: volume (0-100)
 		// 4th argument: loop (0, 1)
 		
 		if (url)
			flashProxy.call('playurl', url_pre+url+url_pst, id, 75, 1);
 		else
			flashProxy.call('playurl', 'prev.php?id='+id, id, 75, 1);
		
		document.getElementById('snd'+id).src = dir_ico+"music1.gif";
		fileid = id;
		playing = true;
	}
}


function playcomplete(id)
{
	document.getElementById('snd'+id).src = dir_ico+"music0.gif";
	playing = false;
	fileid = undefined;
}
