/*******************************************************************************************
/* función para poñer audios própios
/* imprescindible o ficheiro swfobject.js
/* imprescindible o ficheiro jraudioplayer.css
/*  - recorre todas as etiquetas A e engade o reporductor ás que teñan class="jrAudioPlayer"
/*  - para crear un audio deverá poñer unha etiqueta coma a seguinte

	PARAMETROS OBRIGATORIOS
/* 	<a class="jrAudioPlayer" href="media/audio_1.mp3" title="escoitar este audio">audio 1</a>
*******************************************************************************************/
swfobject.addDomLoadEvent(function(){
	
	swfobject.playerActivo = null;
	swfobject.onPause = false;
	swfobject.cargarAudio = function( playerNew ){
		if( swfobject.playerActivo && swfobject.playerActivo != playerNew ){
			document.getElementById( swfobject.playerActivo )._PAUSE();
			document.getElementById( swfobject.playerActivo ).style.zIndex = 0;
		}
		if( swfobject.playerActivo != playerNew || !swfobject.onPause ){
			document.getElementById( playerNew )._PLAY();
			document.getElementById( playerNew ).style.zIndex = 2;
			swfobject.playerActivo = playerNew;
			swfobject.onPause = true;
		}else{
			document.getElementById( playerNew )._PAUSE();
			swfobject.onPause = false;
		}
		
	};
	
	var ar_jrVideos = document.getElementsByTagName("A");
	for( var i = 0 ; i < ar_jrVideos.length ; i ++ ){
		if( ar_jrVideos[i].className.indexOf("jrAudioPlayer") != -1 ){
			var contentAudio		= ar_jrVideos[i];
			var cancion				= contentAudio.href;
			
			var newContent 			= document.createElement("DIV");
			newContent.id 			= "jrAudioPlayer_"+i;
			contentAudio.insertBefore(newContent, contentAudio.childNodes[0]);
			
			contentAudio.href  = "javascript:swfobject.cargarAudio('jrAudioPlayer_"+i+"');";
			
			var flashvars = {
				"cancion" : cancion
			};
			var params = {
				"quality"			: "high",
       			"wmode"				: "transparent",
				"allowScriptAccess" : "sameDomain",
				"allowFullScreen" 	: "true",
				"menu" 				: "false",
       			"align"				: "middle"
			};
			swfobject.embedSWF("swf/jraudioplayer.swf?random="+Math.random()*10000000, "jrAudioPlayer_"+i, "25", "13", "9.0.0.0", null, flashvars, params);
		}
	}
});
