function peekok_buy_songs(widgetForm) {
  var url = "https://www.peekok.com/checkout/checkout?keepThis=true";
  var count = 0;
  for(var i=0; i< widgetForm.elements.length; i++) {
    if(!widgetForm.elements[i].disabled && widgetForm.elements[i].checked) {
      url += "&" + widgetForm.elements[i].name + "=" + widgetForm.elements[i].value;
      count++;
    }
  }
  url += "&widget_id=" + widgetForm.widget_id.value;
  url += "&TB_iframe=true&height=560&width=470";
  if(count > 0) {
    p_lightbox.launchLightbox(url);
  }
}

function peekok_buy_album(id, widgetId) {
  var url = "https://www.peekok.com/checkout/checkout?keepThis=true";
  url += "&widget_id=" + widgetId;
  url += "&playlist_id[]=" + id;
  url += "&TB_iframe=true&height=560&width=470";
  p_lightbox.launchLightbox(url);
}

var currentId = "";
function peekok_playSong(id, url) {
  var playbuttondiv = 'play' + id;
  var stopbuttondiv = 'stop' + id;
  if(niftyplayer('peekokPlayer').getState() == 'playing' || niftyplayer('peekokPlayer').getState() == 'loading') {
    peekok_stopSong(currentId);
  }
  niftyplayer('peekokPlayer').registerEvent('onSongOver', 'peekok_stopSong(' + id + ')');
  niftyplayer('peekokPlayer').loadAndPlay(url);
  document.getElementById(playbuttondiv).style.display = "none";
  document.getElementById(stopbuttondiv).style.display = "inline";
  currentId = id;
}

function peekok_stopSong(id) {
  var playbuttondiv = 'play' + id;
  var stopbuttondiv = 'stop' + id;

  niftyplayer('peekokPlayer').stop();
  document.getElementById(playbuttondiv).style.display = "inline";
  document.getElementById(stopbuttondiv).style.display = "none";
}



