/*
	File: flashplayer.js
	About: This plugin replaces the link to the podcast with an embedable flash player. Thanks to Alsacreations for this great player: http://www.alsacreations.fr/mp3-dewplayer.html
	Logahead Version: Beta 1.0
	Licence: GPL
    Autor: Victor Pimentel http://lapapelera.org
*/

//This function replaces the link to the podcast with an embedable flash player.
function addplayer()
{
	// Specify the old string pattern (constant)
	var pattern = /^(.+)(href=")([^"]+)(.+)$/ig;
	
	// In this variable we will save the anchors we have to check.
	var anchor = '';
	
	// Search in all anchors tags with class="listen" and replaces text with the player
	for (i=0;i<document.getElementsByTagName('a').length;i++)
	{
		anchor = document.getElementsByTagName('a').item(i);
		aparent = anchor.parentNode;
		if (anchor.className == 'listen') {
			aparent.innerHTML = aparent.innerHTML.replace (pattern, "<object class=\"listen\" type=\"application/x-shockwave-flash\" data=\"extras/plugins/flashplayer/dewplayer.swf?mp3=$3&bgcolor=f7f8fb\" width=\"150\" height=\"20\" style=\"width:150px;height:20px;left:310px;\" ><param name=\"movie\" value=\"extras/plugins/flashplayer/dewplayer.swf?mp3=$3&bgcolor=f7f8fb\" /></object>");
		}
		
	}
	
}

//With this function 'addplayer' will be called when the pages loads.
addLoadEvent(addplayer);