
function Play( strTargetDesc )
{
  var iIndex = -1;
  for( var iEntry = 0; iEntry < SongList.length; iEntry += iSongListPitch )
  {
    var strDesc = SongList[iEntry];
    if( strDesc != "" )
    {
      if( strDesc == strTargetDesc )
      {
        iIndex = iEntry/iSongListPitch;
        break;
      }
    }
  }  
  if( iIndex != -1 )
  {
    parent.frames[0].PlayByIndex( iIndex );
  }
}   

function PlayMusic()
{
  parent.frames[0].flashProxy.call('js_wimpy_play');
}

function StopMusic()
{
  parent.frames[0].flashProxy.call('js_wimpy_stop');
}

function NextTrack()
{
  parent.frames[0].flashProxy.call('js_wimpy_next');
}

function PrintSongs( strTargetPlace )
{
  var iNumSongs = 0;
  if( typeof SongList != "undefined" )
  {
    for( var iEntry = 0; iEntry < SongList.length; iEntry += iSongListPitch )
    {
      var strDesc = SongList[iEntry];
      if( strDesc != "" )
      {
        var strPlace = SongList[iEntry + 1];
        if( strPlace == strTargetPlace )
        {  
          var strFilepath = SongList[iEntry + 2];
          var strEscapedDesc = strDesc.split("'").join("\\\'");

          document.writeln( '<tr><td><font><a href="javascript:Play( ' + "'" + strEscapedDesc + "'" + ' )"><img align=absmiddle src="images/icon_play_on_blue.gif" width=28 height=26>' + strDesc + '</a></font></td></tr>' );
          iNumSongs++;
        }
      }
    }
  }  
  if( iNumSongs == 0 )
  {
    document.writeln( '<tr><td><font><b>Sorry.</b> No tracks are available at this time.</font></td></tr>' );
  }  
}

function PrintAllSongs()
{
  var iNumSongs = 0;
  if( typeof SongList != "undefined" )
  {
    for( var iEntry = 0; iEntry < SongList.length; iEntry += iSongListPitch )
    {
      var strDesc = SongList[iEntry];
      if( strDesc != "" )
      {
        var strFilename = SongList[iEntry + 2];
        var strColor = (iEntry % (4*iSongListPitch) < (2*iSongListPitch)) ? "#000030" : "#000010";
        var strEscapedDesc = strDesc.split("'").join("\\\'");
        var bAllowDownload = SongList[iEntry + 4];
        
        document.writeln( '<tr><td><font style="font-size:11px"><a href="javascript:Play( ' + "'" + strEscapedDesc + "'" + ' )">' + strDesc + '</a></font></td></tr>' );
        
        iNumSongs++;
      }
    }
  }
  if( iNumSongs == 0 )
  {
    document.writeln( '<b>Sorry.</b> No tracks are available at this time.' );
  }
}

function BuildSongList()
{
  var strSongListString = "";

  var iNumSongs = 0;
  if( typeof SongList != "undefined" )
  {
    for( var iEntry = 0; iEntry < SongList.length; iEntry += iSongListPitch )
    {
      var strDesc = SongList[iEntry];
      if( strDesc != "" )
      {
        if( iNumSongs > 0 )
        {
          strSongListString += "|";
        }
        var strNormalFilepath = SongList[iEntry + 2];
        var strWimpyFriendlyFilepath = SongList[iEntry + 3];
        var strFilepath = strWimpyFriendlyFilepath != "" ? strWimpyFriendlyFilepath : strNormalFilepath;
        //strSongListString += "../songs/" + strFilepath; // use local copies of songs for streaming
        strSongListString += "http://alisongist.fileburst.com/playsongs" + str + "/" + strFilepath; // use remote copies
        iNumSongs++;
      }
    }
  }
  return strSongListString;
}

function PrintThumbnails( strTargetPlace )
{
  var iNumPhotos = 0;
  var iThumbWidth = 90;
  var iThumbHeight = 130;
  if( typeof PhotoList != "undefined" )
  {
    for( var iEntry = 0; iEntry < PhotoList.length && iNumPhotos < 6; iEntry += 3 )
    {
      var strPlace = PhotoList[iEntry];
      if( strPlace != "" )
      {
        if( strPlace == strTargetPlace )
        {  
          var strFilename = PhotoList[iEntry + 1];
          var strThumbFilename = PhotoList[iEntry + 2];
          var strThumbFilepath;
          
          if( strThumbFilename == "" )
          {
            strThumbFilepath = 'http://www.alisongist.com/phpthumb/phpThumb.php?src=../photos/' + strFilename + '&w=' + iThumbWidth + '&h=' + iThumbHeight + '&zc=1';
          }
          else
          {
            strThumbFilepath = 'photos/' + strThumbFilename;
          }

          if( iNumPhotos % 2 == 0 )
          {
            document.writeln( '<tr>' );
          }
          document.writeln( '<td><font><a href="viewer.htm?photos/' + strFilename + '"><img src="' + strThumbFilepath + '" width=' + iThumbWidth + ' height=' + iThumbHeight + '></a></td>' );
          if( iNumPhotos % 2 == 1 )
          {
            document.writeln( '</tr>' );
          }
          iNumPhotos++;
        }
      }
    }
  }
  for( iNumPhotos; iNumPhotos < 6; iNumPhotos++ )
  {
    if( iNumPhotos % 2 == 0 )
    {
      document.writeln( '<tr>' );
    }
    document.writeln( '<td><img src="images/invispix.gif" width=' + iThumbWidth + ' height=' + iThumbHeight + '></td>' );
    if( iNumPhotos % 2 == 1 )
    {
      document.writeln( '</tr>' );
    }
    iNumPhotos++;
  }
}