function loadswf(file, id, width, height, bgcolor, flashvars)
{
	var so = new SWFObject(file, id + "_swf", width, height, 8, bgcolor);
	so.addParam("wmode", "transparent");
	so.addParam("allowFullScreen", "true");
	so.addVariable("flashvars", flashvars);
	so.write(id);

}
var estado_player = 'Detenido';
function play()
{	
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").play();
	else document.getElementById("player").controls.play();	
	jQuery('#play_button').addClass('active_play');
	jQuery('#play_button_mini').addClass('play_mini_active').hide();
	jQuery('#stop_button_mini').show();
	jQuery('.reproduciendo').show();
	jQuery('#volume_status').attr('src', '/images/volume_on.png');
	if(izquierda !== '0px') jQuery('#control_slider').css( {left: izquierda } );
	changeVolume(selected_volume);
	if(estado_player !== "Reproduciendo"){
	jQuery("div.status").html('Almacenando...');
	jQuery('.reproduciendo').hide();
	jQuery('.reproduciendo_fondo').fadeIn();
	estado_player = 'Almacenando...';
	reproduciendo();
	}
	
	return false;

}

function reproduciendo(){
if(jQuery("div.status").html() == "Reproduciendo"){
clearTimeout(revisarReproduciendo);
jQuery('.reproduciendo').fadeIn('slow');
icono.cambiar("http://"+Sonarroot+"/favicon2.gif");
estado_player = "Reproduciendo";
}
else 
{
revisarReproduciendo = setTimeout(function(){ reproduciendo(); },500);
}
}

function stop()
{
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").stop();
	else document.getElementById("player").controls.stop();
	estado_player = 'Detenido';
	jQuery("div.status").html('Detenido');
	jQuery('#play_button').removeClass('active_play');
	jQuery('#play_button_mini').removeClass('play_mini_active').show();
	jQuery('#stop_button_mini').hide();
	icono.cambiar("http://"+Sonarroot+"/favicon.ico");
	jQuery('.reproduciendo').fadeOut();
	jQuery('.reproduciendo_fondo').fadeOut('slow');
	return false;
}

function volumeDown()
{
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").volumeDown();
	else document.getElementById("player").Settings.volume -= 10;
	return false;
}

function volumeUp()
{
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").volumeUp();
	else document.getElementById("player").Settings.volume += 10;
	return false;
}

function setVolume(value){
	
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").volumeUp();
	else document.getElementById("player").Settings.volume = value;
	jQuery("div.status").html(estado_player);
	return false;
	
}

function mute()
{
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf").mute();
	else document.getElementById("player").Settings.mute = !document.getElementById("player").Settings.mute;
	return false;
}

function changeVolume(valor){
	var value = parseInt(valor);
	value += 1;

	if(value == 0){
		mute();
		return;
	}
	
	if (jQuery("div#player")[0] != null){ 		
		value *= 2;	
		document.getElementById("player_swf").changeVolume(value);
	
	}else{ 
		value *= 20;
		document.getElementById("player").Settings.volume = value;
	}
	
	selected_volume = valor;
	jQuery("div.status").html(estado_player);
}

function setStatus(msg)
{
	if (jQuery("div#player")[0] == null)
	{
		switch (document.getElementById("player").playstate)
		{
			case 1:
				msg = 'Cargando...';
				estado_player = 'Cargando...';
				break;
			case 3:
				msg = 'Reproduciendo';
				estado_player = 'Reproduciendo';
				break;
			case 6:
				msg = 'Almacenando...';
				estado_player = 'Almacenando...';
				break;
			case 11:
				msg = 'Reconectando';
				estado_player = 'Reconectando';
				break;
			default :
				msg = 'Reproduciendo';
				break;
		}
	}
	if(msg == 'Conectando...') {
	jQuery('.reproduciendo_fondo, .reproduciendo').fadeOut();
	icono.cambiar("http://"+Sonarroot+"/favicon.ico");
	setTimeout(function(){ stop(); },3000);
	iniciarControlVolumen();
	setTimeout(function(){ play(); },6000);
	}
	jQuery("div.status").html(msg);

}