// Change these two lines to modify your PLAY and STOP buttons.
var mp3PlayButton = "http://www.healthalerts.com.au/css/images/listen.gif";
var mp3StopButton = "http://www.healthalerts.com.au/images/stop2.gif";
// Change these two lines to modify the "playing..." font and size.
var mp3PlayingFont = "Verdana";
var mp3PlayingSize = "8pt";
//var mp3PlayButton = "http://www.healthalerts.com.au/images/play.png";
//var mp3StopButton = "http://www.healthalerts.com.au/images/pause.png";
if(typeof(TagTooga) == 'undefined')
TagTooga = {}
TagTooga.Mp3 =
{
playimg: null,
player: null,
go: function()
{
var all = document.getElementsByTagName('a');
for (var i = 0, o; o = all[i]; i++)
{
if(o.href.match(/\.mp3$/i))
{
var img = document.createElement('img');
img.src = mp3PlayButton;
img.title = 'Listen Now';
img.height = 14;
img.width = 17;
//img.height = img.width = 12;
img.style.marginRight = '0.5em';
img.style.cursor = 'pointer';
img.onclick = TagTooga.Mp3.makeToggle(img, o.href);
o.parentNode.insertBefore(img, o);
}
}
},
toggle: function(img, url)
{
if (TagTooga.Mp3.playimg == img)
TagTooga.Mp3.destroy();
else
{
if (TagTooga.Mp3.playimg)
TagTooga.Mp3.destroy();
var a = img.nextSibling;
img.src = mp3StopButton;
img.title = 'Stop Now';
img.height = img.width = 12;
TagTooga.Mp3.playimg = img;
TagTooga.Mp3.player = document.createElement('span');
TagTooga.Mp3.player.innerHTML = 'Now Playing...';
img.parentNode.insertBefore(TagTooga.Mp3.player, img.nextSibling);
}
},
destroy: function()
{
TagTooga.Mp3.playimg.src = mp3PlayButton;
TagTooga.Mp3.playimg.title = 'Listen Now';
TagTooga.Mp3.playimg.height = 14;
TagTooga.Mp3.playimg.width = 17;
TagTooga.Mp3.playimg = null;
TagTooga.Mp3.player.removeChild(TagTooga.Mp3.player.firstChild);
TagTooga.Mp3.player.removeChild(TagTooga.Mp3.player.firstChild);
TagTooga.Mp3.player.parentNode.removeChild(TagTooga.Mp3.player);
TagTooga.Mp3.player = null;
},
makeToggle: function(img, url)
{
return function()
{
TagTooga.Mp3.toggle(img, url);
}
}
}
TagTooga.addLoadEvent = function(f)
{
var old = window.onload;
if (typeof old != 'function')
window.onload = f;
else
{
window.onload = function() { old(); f() }
}
}
TagTooga.addLoadEvent(TagTooga.Mp3.go);