// Trim-Functions

String.prototype.trim = function()
{
  return this.replace(/^\s+|\s+$/g, "");
}


String.prototype.ltrim = function()
{
  return this.replace(/^\s+/, "");
}


String.prototype.rtrim = function()
{
  return this.replace(/\s+$/, "");
}



// AudioPlayer

function AudioPlayer (sIDAudioTmp, sIDTitleTmp, sPathTmp, sFilesTmp)
{
  var i=0;
  var sIDAudio = sIDAudioTmp;
  var sIDTitle = sIDTitleTmp;
  var sPath    = sPathTmp;
  var sFiles   = sFilesTmp.split(",");


  this.Prev = function ()
  {
    i = (i-1+sFiles.length) % sFiles.length;
    Show();
  }

  
  this.Play = function ()
  {
    Show();
  }
  

  this.Stop = function ()
  {
    //document.getElementById(sIDAudio).innerHTML = "";
    parent[sIDAudio].location.href = "";
  }


  this.Next = function ()
  {
    i = (i+1) % sFiles.length;
    Show();
  }


  this.PlayIndex = function (sIndex)
  {
    i = (sIndex-1);
    Show();
  }


  function Show ()
  {
    var sValue = sFiles[i].split(":");
    //var sResult = "";
    document.getElementById(sIDTitle).innerHTML = "\"" + sValue[0].trim() + "\"";
    //sResult += "<object width=\"1\" height=\"1\"><param name=\"salign\" value=\"lt\"><param name=\"quality\" value=\"high\"><param name=\"scale\" value=\"noscale\"><param name=\"wmode\" value=\"transparent\"><param name=\"movie\" value=\""+sPath+sValue[1]+"\"><param name=\"FlashVars\" value=\"&autoPlay=true&autoRewind=false\">";
    //sResult += "<embed width=\"1\" height=\"1\" flashvars=\"&autoPlay=true&autoRewind=false\" quality=\"high\" scale=\"noscale\" salign=\"LT\" type=\"application/x-shockwave-flash\" src=\""+sPath+sValue[1]+"\" wmode=\"transparent\"></embed>";
    //sResult += "</object>";
    //document.getElementById(sIDAudio).innerHTML = sResult;
    parent[sIDAudio].location.href = sPath + sValue[1];
  }

}
