function getFlashObject()
{
    return document.getElementById("audioDiv");
}

function play(reset) {
    if (myListener.position == 0 || reset) {
        getFlashObject().SetVariable("method:setUrl", playlist[currentTrack]['url']);
    }
    getFlashObject().SetVariable("method:play", "");
    getFlashObject().SetVariable("enabled", "true");
}
function pause()
{
    getFlashObject().SetVariable("method:pause", "");
}
function stop()
{
    getFlashObject().SetVariable("method:stop", "");
}
function ffwd() {
    currentTrack = (currentTrack+1 > playlist.length-1) ? 1 : currentTrack+1;
    setSong(currentTrack, true);
}

function rewind() {
    currentTrack = (currentTrack-1 == 0 ) ? playlist.length-1 : currentTrack-1;
    setSong(currentTrack, true);
}
function setPosition()
{
    var position = document.getElementById("inputPosition").value;
    getFlashObject().SetVariable("method:setPosition", position);
}
function setVolume(volume)
{
/*     var volume = document.getElementById("inputVolume").value; */
    getFlashObject().SetVariable("method:setVolume", volume);
}
function setSong(tracknumber, autoplay) {
  $oldsong = jQuery('#playlist .active').attr('id');
  old = ($oldsong === undefined) ? false : $oldsong;
  currentTrack = tracknumber;
  if (autoplay) {
    play(true);
  }
  if (old) jQuery('#playlist #' + old).removeClass('active');
  jQuery('#playlist #track_' + currentTrack).addClass('active');
}