var VoklePlaylist = ( typeof(VoklePlaylist) != 'undefined') ? VoklePlaylist : [];

// VoklePlaylist.push({
//   'id' : '3370',
//   'description' : 'Cory Rules'
// });
// VoklePlaylist.push({
//   'id' : '3372',
//   'description' : 'Ian rules'
// });

function vokle_playlist_next(){
  if(VoklePlaylist.length != 0){
    var lucky_winner = VoklePlaylist.shift();
    VoklePlaylist.push(lucky_winner);
    return lucky_winner;
  } else {
    return null;
  }
}

$(function(){
  var showcased_lineup = vokle_playlist_next();

  if(showcased_lineup != null){
    $('#showcased_lineup').html(
      "<div id='vokle_embed_lineup_" + showcased_lineup.id + "_container'></div>"
    );
    
    //$('#showcased_lineup_description').text(showcased_lineup.description);
    
    var VokleHomeHeadReference    = document.getElementsByTagName("head")[0];  
    var VoklePlaylistScriptTag    = document.createElement('script');
    VoklePlaylistScriptTag.src    = "http://" + Vokle.api_domain + "/embed/lineup/" + showcased_lineup.id + "?width=890&end_caps=false&borders=false";
    VoklePlaylistScriptTag.type   = 'text/javascript';

    VokleHomeHeadReference.appendChild(VoklePlaylistScriptTag);
    VokleHomeHeadReference  = null;
    VoklePlaylistScriptTag  = null;
  } else {
    $('#showcased_content').hide();
    //$('#showcased_description').hide();
    $('#home_card').show();

  }
});
