if(typeof(podcast) == 'undefined') podcast = {}
podcast.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 = '/admin/icons/play.gif'; img.title = 'listen'
				img.height = img.width = 16
				img.align = "absmiddle"
				img.style.marginRight = '4px'
				img.style.cursor = 'pointer'
				img.onclick = podcast.Mp3.makeToggle(img, o.href)
				o.parentNode.insertBefore(img, o)
	}}},
	toggle: function(img, url) {
		if (podcast.Mp3.playimg == img) podcast.Mp3.destroy()
		else {
			if (podcast.Mp3.playimg) podcast.Mp3.destroy()
			var a = img.nextSibling
			img.src = '/admin/icons/stop.gif'; podcast.Mp3.playimg = img;
			podcast.Mp3.player = document.createElement('span')
			podcast.Mp3.player.innerHTML = '<object style="vertical-align:bottom;margin-right:0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
			'width="100" height="14" id="player" align="middle">' +
			'<param name="wmode" value="transparent" />' +
			'<param name="allowScriptAccess" value="sameDomain" />' +
			'<param name="flashVars" value="theLink='+url+'" />' +
			'<param name="movie" value="/swf/podcast.swf" /><param name="quality" value="high" />' +
			'<embed style="vertical-align:bottom;margin-right:0.2em" src="/swf/podcast.swf" flashVars="theLink='+url+'"'+
			'quality="high" wmode="transparent" width="100" height="14" name="player"' +
			'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' +
			' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
			img.parentNode.insertBefore(podcast.Mp3.player, img.nextSibling)
	}},
	destroy: function() {
		podcast.Mp3.playimg.src = '/admin/icons/play.gif'; podcast.Mp3.playimg = null
		podcast.Mp3.player.removeChild(podcast.Mp3.player.firstChild); podcast.Mp3.player.parentNode.removeChild(podcast.Mp3.player); podcast.Mp3.player = null
	},
	makeToggle: function(img, url) { return function(){ podcast.Mp3.toggle(img, url) }}
}

podcast.addLoadEvent = function(f) { var old = window.onload
	if (typeof old != 'function') window.onload = f
	else { window.onload = function() { old(); f() }}
}

podcast.addLoadEvent(podcast.Mp3.go)

