window.addEvent("domready", function(){

Delicious = {}
Delicious.Mp3 = {
	playimg: null,
	player: null,
	go: function(titleTag) {
		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')
				if (o.title.indexOf('playable') > -1)  {
				  src = 'http://www.readthehook.com/images/interface/music/playtagplay3.jpg';
				  height = 15
          width = 15
        }
				if (o.title.indexOf('playable') == -1) {
				  //src = 'http://www.readthehook.com/images/interface/music/bodyplay.jpg';
				  src = 'http://www.readthehook.com/images/issues/2009/0819/playtag.jpg';
				  height = 15
          width = 15
          o.className = 'bodyPlayerLink'
        }
				img.height = height
				img.width = width
				img.src = src; img.title = 'listen'
				img.style.border = 'none'
				img.style.cursor = 'pointer'
				img.className = 'bodyPlayer'
				img.onclick = Delicious.Mp3.makeToggle(img, o.href, src)
				o.parentNode.insertBefore(img, o)
	}}},
	toggle: function(img, url, src) {
		if (Delicious.Mp3.playimg == img) Delicious.Mp3.destroy(src)
		else {
			if (Delicious.Mp3.playimg) Delicious.Mp3.destroy(src)
			var a = img.nextSibling, c=''
			if (document.defaultView && document.defaultView.getComputedStyle) c = document.defaultView.getComputedStyle(a,null).getPropertyValue('color')
			else if (a.currentStyle) c = a.currentStyle['color']
			c = c.replace(/^rgb|[ ()]/g, '')
			var hex = c.match(/^#?([a-f0-9]{6})$/), hexSm = c.match(/^#?([a-f0-9]{3})$/), rgb = c.match(/^([0-9]+),([0-9]+),([0-9]+)$/)
			if (rgb) { var c16 = "0123456789abcdef", c=''; for(var i=1,d;d=rgb[i];i++) { var j=d%16; c=c+c16.charAt((d-j)/16)+c16.charAt(j) } }
			else if (hex) c = hex[1]
			else if (hexSm) c = hexSm[1].charAt(0) + hexSm[1].charAt(0) + hexSm[1].charAt(1) + hexSm[1].charAt(1) + hexSm[1].charAt(2) + hexSm[1].charAt(2)
			else c = "000000"
			img.src = src; img.height = 0; img.width = 0; Delicious.Mp3.playimg = img;
			Delicious.Mp3.player = document.createElement('span')
			if (src == 'http://www.readthehook.com/images/issues/2009/0819/playtag.jpg') {
			   Delicious.Mp3.player.innerHTML ='<embed height="15" width="15" flashvars="wimpyReg=MjFjJTI3UCU3QllkbiU3RGY2U3NTNTclM0JiJTYwYyUyOUMuMGlvV3YlMjlaVEJo&amp;wimpySkin=http://www.readthehook.com/podcasts/skins/skin_buttonDef.xml&amp;startPlayingOnload=yes&amp;playlist='+url+'&amp;allowscriptaccess=always&amp;startupLogo=http://www.readthehook.com/images/interface/samplerBG.jpg" menu="false" allowfullscreen="true" allowscriptaccess="always" salign="lt" scale="noscale" quality="high" name="wimpy" id="wimpy" style="" src="http://www.readthehook.com/podcasts/rave2/rave.swf?cachebust=1242326071626" type="application/x-shockwave-flash"/>';
        
			} else {
			Delicious.Mp3.player.innerHTML ='<embed height="15" width="15" flashvars="wimpyReg=MjFjJTI3UCU3QllkbiU3RGY2U3NTNTclM0JiJTYwYyUyOUMuMGlvV3YlMjlaVEJo&amp;wimpySkin=http://www.readthehook.com/podcasts/skins/skin_buttonDef.xml&amp;startPlayingOnload=yes&amp;playlist='+url+'&amp;allowscriptaccess=always&amp;startupLogo=http://www.readthehook.com/images/interface/samplerBG.jpg" menu="false" allowfullscreen="true" allowscriptaccess="always" salign="lt" scale="noscale" quality="high" name="wimpy" id="wimpy" style="" src="http://www.readthehook.com/podcasts/rave2/rave.swf?cachebust=1242326071626" type="application/x-shockwave-flash"/>';
		  }
			img.parentNode.insertBefore(Delicious.Mp3.player, img.nextSibling)
	}},
	destroy: function(src) {
		
    if (Delicious.Mp3.playimg.src == '') {
      Delicious.Mp3.playimg.height = 24; Delicious.Mp3.playimg.width = 88;      
    } else {
      Delicious.Mp3.playimg.height = 15; Delicious.Mp3.playimg.width = 15;
    }
		Delicious.Mp3.player.removeChild(Delicious.Mp3.player.firstChild); Delicious.Mp3.player.parentNode.removeChild(Delicious.Mp3.player); Delicious.Mp3.player = null
	},
	makeToggle: function(img, url, src) { return function(){ Delicious.Mp3.toggle(img, url, src) }}
}

Delicious.addLoadEvent = function(f) { var old = window.onload
	if (typeof old != 'function') window.onload = f
	else { window.onload = function() { old();  }}
}

Delicious.addLoadEvent(Delicious.Mp3.go("playable"))

});
