function loadswf(file, id, width, height, bgcolor, flashvars)
{
	var str = "<embed ";
	str += "id='player_swf2' ";
	str += "src='/swf/player.swf' "; 
	str += "flashvars='flashvars=&xmlfile=/config.xml' ";
	str += "quality='high' bgcolor=''#333399' ";
	str += "WIDTH='0' HEIGHT='0' ";
	str += "NAME='player' ";
	str += "ALIGN='' ";
	str += "TYPE='application/x-shockwave-flash' "; 
	str += "PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'>";
	
	$("#player").html(str);
	
	/*
	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()
{	
	loadAds();
}

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_swf2").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_swf2").volumeDown();
	else document.getElementById("player").Settings.volume -= 10;
	return false;
}

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

function setVolume(value){
	
	if (jQuery("div#player")[0] != null) document.getElementById("player_swf2").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_swf2").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_swf2").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);

}