var PT = {
	playimg: null,
	player: null,
	go: function() {
		var all = document.getElementsByTagName('a');
		for (var i = 0, a; a = all[i]; i++) {
			if (a.href.match(/\.mp3$/i)) {
				a.innerHTML = "<img src='/images/pt_play.gif' border='0' alt='mp3' title='play' />";
				a.style.border = '0';
				a.style.marginRight = '1px';
				a.style.outline = '0';
				a.getElementsByTagName('img')[0].style.verticalAlign = 'middle';
				a.onclick = PT.makeToggle(a);
			}
		}
	},
	toggle: function(a) {
		if (a == PT.playLink) 
			PT.destroy();
		else {
			if (PT.playLink) 
				PT.destroy();
			var i = a.getElementsByTagName('img')[0];
			i.src = '/images/pt_stop.gif';
			i.title = 'stop';
			a.style.marginRight = '0px';
			PT.playLink = a;
			PT.player = document.createElement('span');
			PT.player.innerHTML = '<object style="vertical-align:bottom" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1" height="1" id="player" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="flashVars" value="theLink=' + encodeURIComponent(a.href) + '&amp;fontColor=#000000" /><param name="movie" value="/pt.swf" /><param name="quality" value="high" /><embed style="vertical-align:bottom" src="/pt.swf" flashVars="theLink=' + encodeURIComponent(a.href) + '&amp;fontColor=#000000" quality="high" wmode="transparent" width="1" height="1" name="player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			a.parentNode.insertBefore(PT.player, a.nextSibling);
		}
	},
	destroy: function() {
		var i = PT.playLink.getElementsByTagName('img')[0];
		i.src = '/images/pt_play.gif';
		i.title = 'play';
		PT.playLink.style.marginRight = '1px';
		PT.playLink = null;
		PT.player.removeChild(PT.player.firstChild); /* for IE */
		PT.player.parentNode.removeChild(PT.player);
		PT.player = null;
	},
	makeToggle: function(a) { 
		return function() {
			PT.toggle(a);
			return false;
		}
	}
};

(function () {
	var oo = window.onload;
	window.onload = function () {
		oo && oo();
		PT.go();
	};
})();
