function slideSwitch(ergo_id) { 
  var $active = $('#'+ergo_id+' IMG.active');
    
    if ( $active.length == 0 ){ 
      $active = $('#'+ergo_id+' IMG:last');
      
    }
    var $next =  $active.next().length ? $active.next()
        : $('#'+ergo_id+' IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
document.writeln('<link rel="stylesheet" type="text/css" href="http://www.ergoux.com/social/css/embed_player.css"/>');
document.writeln('<link rel="stylesheet" type="text/css" href="http://www.ergoux.com/social/css/soapbox.css"/>');
document.writeln('<script type="text/javascript" src="http://www.ergoux.com/social/js/ergo_player.js"></script>');
document.writeln('<script type="text/javascript" src="http://www.ergoux.com/social/js/soapbox.js"></script>');
document.writeln('<p class="ergo_click">Click Para Ver ! </p>');
document.writeln('<div id="container_'+ergo_id+'" class="ergo_player_container">');
document.writeln('<div class="ergo_gallery">');
document.writeln('</div>');
document.writeln('<div class="ergo_text_container">');
document.writeln('<h1>');
document.writeln('</h1>');
document.writeln(description);
document.writeln('</div>');
document.writeln('</div>');
if( (typeof embeds) == "undefined") {
  var embeds = new Array();
  var embed_titles = new Array();

}
embeds.push( ergo_id );
embed_titles.push( title );

$(document).ready(
function(){
  ergo_id = embeds[0];
  embeds.splice(0,1);
  title = embed_titles[0];
  embed_titles.splice(0,1);
  $("#"+ergo_id+" img:first").addClass("active").css("display","block");
  var pwd_by = $("#"+ergo_id).parent().next().clone();
  var tmp = $('#'+ergo_id).parent().clone();
  $('#'+ergo_id).parent().remove();
  $('#container_'+ergo_id+' .ergo_gallery').append(tmp);
  tmp = $('a[title="'+title+'"]').clone();
  $('a[title="'+title+'"]').remove();
	$('#container_'+ergo_id+' .ergo_text_container h1').append(tmp);
	$('#'+ergo_id).parent().next().remove();
	$('#container_'+ergo_id+' .ergo_text_container').append(pwd_by);
	$("#container_"+ergo_id+" * , #container"+ergo_id+".ergo_player_container").soapbox({ width: "945px",height :"680px", url:embed_url }).css("cursor","pointer");
	setInterval( "slideSwitch('"+ergo_id+"')", 5000 );
}
);

