<?php

##################################################
##################################################

// HTML CODE - functions that generate HTML

##################################################
##################################################

function show_example_icons () {

    global $NETJUKE_SESSION_VARS;

    // Grab five icons from the current icon set and display them
    $icon_set = FS_PATH . "/var/html/icons/" . $NETJUKE_SESSION_VARS["icon_set"];
    $html = "";
    $count = 0;

    if ($dir = @opendir ($icon_set)) {

        while (($file = readdir ($dir)) !== false) {

            if ($file != "." && $file != ".."
                && is_file ($icon_set . '/' . $file)
                && substr ($file, -4) == '.gif'
                && substr ($file, 0, 5) == 'icon.') {

                $ending = substr ($file, -7);

                // Handle inverted icons...
                if ($NETJUKE_SESSION_VARS['inv_icn'] == 't') {
                    if ($ending == "inv.gif") {

                        $html .= "<img src=\"".WEB_PATH.'/var/html/icons/'.$NETJUKE_SESSION_VARS["icon_set"].'/'.$file."\">&nbsp;&nbsp;";
                        $count++;

                    }
                } else {
                    if ($ending != "inv.gif") {

                        $html .= "<img src=\"".WEB_PATH.'/var/html/icons/'.$NETJUKE_SESSION_VARS["icon_set"].'/'.$file."\">&nbsp;&nbsp;";
                        $count++;

                    }

                }

            }

            if ($count >= 5) {

                break;

            }

        }

        closedir ($dir);

    }

    return ($html);

}

##################################################

function icon_set_menu ($name, $selected_val="", $onchange="") {

  $html = "<select name=\"$name\" onchange=\"$onchange\" class=input_content>";

  // Get all icon sets in etc/locale/icons and exclude stragglers (CVS, etc).
  if ($dir = @opendir (FS_PATH . "/var/html/icons/")) {

      while (($file = readdir ($dir)) !== false) {

          if ($file != "CVS" && $file != "." && $file != ".."
              && is_dir (FS_PATH . "/var/html/icons/" . $file)) {

            $values[$file] = $file;

          }

      }

      closedir ($dir);

  }

  if (count ($values) > 0) {

    foreach ($values as $key => $value) {

      if ($key == $selected_val) {
        $selected = "selected";
      } else {
        $selected = "";
      }

      $html .= "<option value=\"$key\" $selected>$value</option>";

    }

  }

  $html .= "</select>";

  return $html;

}

##################################################

function themes_menu ($name, $selected_val="", $onchange="") {

  GLOBAL $NETJUKE_THEME_LIST;

  $html = "<select name=\"$name\" onchange=\"$onchange\" class=input_content>";
	$values = array ();
	$selected = '';

  foreach ($NETJUKE_THEME_LIST as $file => $theme) {
    $values[$file] = $theme->getMetaData('name');
  }

  asort($values);

  if (count ($values) > 0) {

    foreach ($values as $key => $value) {

      if ($key == $selected_val) {
        $selected = "selected";
      } else {
        $selected = "";
      }

      $html .= "<option value=\"$key\" $selected>$value</option>";

    }

  }

  $html .= "</select>";

  return $html;

}

##################################################

function buildButton($link = "", $title = "", $icon = "", $target = "", $in_header = false) {
        global $ICONS, $NETJUKE_THEME;
        $output = "";
        $remote = "";
        $url = "";

        if (! isset ($ICONS[$icon])) $ICONS[$icon] = array ('x' => 0, 'y' => 0, 'url' => '');

        $url = $ICONS[$icon]['url'];

        // Handle reverse inversion
        if ($in_header == true && is_object ($NETJUKE_THEME) && $NETJUKE_THEME->getMetaData ('icon_header_rev') == 't') {
          if (strstr ($ICONS[$icon]['url'], 'inv.gif')) {
            $url = substr ($ICONS[$icon]['url'], 0, -8) . '.gif';
          } else {
            $url = substr ($ICONS[$icon]['url'], 0, -4) . '.inv.gif';
          }
        }

        if ($icon) {
                $output = "<img class=\"icon\" alt=\"$title\" src=\"".$url."\" width=\"".
		$ICONS[$icon]['x']."\" height=\"".$ICONS[$icon]['y'].
		"\" border=0 align=absmiddle hspace=0 vspace=0>";
        }
        if ($target) {
                $remote = " TARGET=\"$target\" onClick=\"window.open('','$target','width=500,height=575,".
		"top=0,left=0,menubar=no,scrollbars=yes,resizable=yes');\"";
        }
        if ($link) {
                $output = "<a href=\"$link\" title=\"$title\"$remote>$output</a>";
        }
        return $output;
}

##################################################

function SummaryHeader() {

  $tr_cnt = getCount('tr');
  $ar_cnt = getCount('ar',' where track_cnt > 0 ');
  $al_cnt = getCount('al',' where track_cnt > 0 ');
  $ge_cnt = getCount('ge',' where track_cnt > 0 ');
  list($ti_cnt, $sz_cnt) = getTimeSize();

  echo "

    <table width='100%' border=0 cellspacing=0 cellpadding=0>
      <tr>
       <td width=\"25%\" align='left' valign='top' nowrap>

           <table width='95%' height=\"100%\" border=0 cellspacing=1 cellpadding=3 class=\"border\">
           <tr>
             <td class=\"header\" nowrap><B>". COMMON_SUMHEAD_QS_HEADER ."</B></td>
           </tr>
           <form action='search.php' method=get name='searchForm'>
           <input type=hidden name='do' value='search'>
           <tr>
             <td class=\"content\" align=center nowrap align=center>
               <select name='col' style=\"margin-bottom: 2px;\" class=input_content>
                 <option value='ar.name'>". COMMON_SUMHEAD_QS_OPT_AR ."</option>
                 <option value='tr.name'>". COMMON_SUMHEAD_QS_OPT_TR ."</option>
                 <option value='al.name'>". COMMON_SUMHEAD_QS_OPT_AL ."</option>
                 <option value='ge.name'>". COMMON_SUMHEAD_QS_OPT_GE ."</option>
                 <option value='tr.time'>". COMMON_SUMHEAD_QS_OPT_TI ."</option>
               </select>
               <br>
               <input type=text name='val' size='18' maxlength='50' value='' class=input_content>
               <input type=submit value='". COMMON_SUMHEAD_QS_BTN ."' class='btn_content'>
             </td>
           </tr>
           </form>
           </table>

       </td>
       <td width=\"25%\" align='right' valign='top' nowrap>

           <table width='95%' height=\"100%\" border=0 cellspacing=1 cellpadding=3 class=\"border\">
           <tr>
             <td class=\"header\" nowrap colspan=3><B>". COMMON_SUMHEAD_SUMM_HEADER ."</B></td>
           </tr>
           <tr>
             <td class=\"content\" align=center nowrap>".$tr_cnt." ". COMMON_SUMHEAD_SUMM_TR ."</td>
             <td class=\"content\" align=center nowrap>".$ar_cnt." ". COMMON_SUMHEAD_SUMM_AR ."</td>
             <td class=\"content\" align=center nowrap>".$ti_cnt."</td>
           </tr>
           <tr>
             <td class=\"content\" align=center nowrap>".$al_cnt." ". COMMON_SUMHEAD_SUMM_AL ."</td>
             <td class=\"content\" align=center nowrap>".$ge_cnt." ". COMMON_SUMHEAD_SUMM_GE ."</td>
             <td class=\"content\" align=center nowrap>".$sz_cnt."</td>
            </td>
           </tr>
           </table>

       </td>
       <td width=\"25%\" align='right' valign='top'>

        <table width='90%' height=\"100%\" border=0 cellspacing=1 cellpadding=3 class=\"border\">
        <form>
        <tr>
          <td class=\"header\" nowrap>
            <table border=0 width=100% cellspacing=0 cellpadding=0><tr><td align=left class=\"header\" nowrap>
              ". COMMON_SUMHEAD_ALPHA_AR_HEADER ." A-Z (". $ar_cnt .")
            </td><td align=right>
              <input type=button value='". COMMON_SUMHEAD_ALL_LINK ."'  onClick=\"window.open('alphabet.php?do=alpha.artists','NetjukeRemote','width=500,height=575,top=0,left=0,menubar=no,scrollbars=yes,resizable=yes');\" class='btn_header' title=\"".  COMMON_SUMHEAD_ALL_TITLE ."\">
            </td></tr></table>
          </td>
        </tr>
        <tr>
          <td class=\"content\" align=\"center\">
            ". alphabet('artists') ."
          </td>
        </tr>
        </form>
        </table>

       </td>
       <td width=\"25%\" align='right' valign='top'>

        <table width='90%' height=\"100%\" border=0 cellspacing=1 cellpadding=3 class=\"border\">
        <form>
        <tr>
          <td class=\"header\" nowrap>
            <table border=0 width=100% cellspacing=0 cellpadding=0><tr><td align=left class=\"header\" nowrap>
              ". COMMON_SUMHEAD_ALPHA_AL_HEADER ." A-Z (". $al_cnt .")
            </td><td align=right>
              <input type=button value='". COMMON_SUMHEAD_ALL_LINK ."'  onClick=\"window.open('alphabet.php?do=alpha.albums','NetjukeRemote','width=500,height=575,top=0,left=0,menubar=no,scrollbars=yes,resizable=yes');\" class='btn_header' title=\"".  COMMON_SUMHEAD_ALL_TITLE ."\">
            </td></tr></table>
          </td>
        </tr>
        <tr>
          <td class=\"content\" align=\"center\">
            ". alphabet('albums') ."
          </td>
        </tr>
        </form>
        </table>

       </td>
     </tr>
    </table>

    <br>

  ";

}

##################################################

function SpecialEditTB() {

  GLOBAL $NETJUKE_SESSION_VARS;

  $html = "";
  $colspan = 0;

  $batch_html = "";
  $batch_colspan = 0;

  $radio_html = "";
  $radio_colspan = 0;

  $row_html = "";

  $jukebox_html = "";
  $jukebox_colspan = 0;

  if ($NETJUKE_SESSION_VARS['gr_id'] <= 2) {

    // we have an admin or an editor

    if (defined('RADIO_TYPE')) {

      if ( (RADIO_TYPE != '') && (RADIO_PLIST != '') ) {

        if (@file_exists(RADIO_PLIST)) {

          // display radio edit tools

          $radio_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('radio', 'add', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_RADIOADD_HELP ."\">". COMMON_BEDIT_TB_RADIOADD ."</A></B></td>";
          $radio_colspan++;

          $radio_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('radio', 'replace', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_RADIOREP_HELP ."\">". COMMON_BEDIT_TB_RADIOREP ."</A></B></td>";
          $radio_colspan++;

          $radio_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"".WEB_PATH."/admin/pl-view.php?do=radio\" target=\"NetJukePlView\" onClick=\"window.open('','NetJukePlView','width=640,height=550,top=5,left=5,menubar=no,scrollbars=yes,resizable=yes');\" title=\"". COMMON_BEDIT_TB_RADIOPLVIEW_HELP ."\">". COMMON_BEDIT_TB_RADIOPLVIEW ."</A></B></td>";
          $radio_colspan++;

        }

      }

    }

    if (defined('JUKEBOX_PLAYER')) {

      if ( ((JUKEBOX_PLAYER != '') && (JUKEBOX_PLIST != '')) || (JUKEBOX_PLAYER == 'httpQ' || JUKEBOX_PLAYER == 'iNetCtrl')) {

        if (@file_exists(JUKEBOX_PLIST)) {

          // display jukebox edit tools

          $jukebox_html .= "</tr><tr>";

          $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"".WEB_PATH."/admin/jukebox-edit.php?do=start\" title=\"". COMMON_BEDIT_TB_JUKEBOXSTART_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXSTART ."</A></B></td>";
          $jukebox_colspan++;

          $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"".WEB_PATH."/admin/jukebox-edit.php?do=stop\" title=\"". COMMON_BEDIT_TB_JUKEBOXSTOP_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXSTOP ."</A></B></td>";
          $jukebox_colspan++;

          if (JUKEBOX_PLAYER != 'ogg123') {

            // show both add & replace playlist options if not ogg123

            $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('jukebox', 'add', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_JUKEBOXADD_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXADD ."</A></B></td>";
            $jukebox_colspan++;
            $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('jukebox', 'replace', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_JUKEBOXREP_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXREP ."</A></B></td>";
            $jukebox_colspan++;

          } else {

            // if ogg123

            if ($radio_html == '') {
              // radio is off, colspan = 1
              $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('jukebox', 'replace', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_JUKEBOXREP_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXREP ."</A></B></td>";
              $jukebox_colspan++;
            } else {
              // radio is on, colspan = 2
              $jukebox_html .= "<td colspan=2 class=\"content\" align=center nowrap><B><A HREF=\"Javascript:TextPlistEdit('jukebox', 'replace', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_JUKEBOXREP_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXREP ."</A></B></td>";
              $jukebox_colspan++;
            }

          }

          $jukebox_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"".WEB_PATH."/admin/pl-view.php?do=jukebox\" target=\"NetJukePlView\" onClick=\"window.open('','NetJukePlView','width=640,height=550,top=5,left=5,menubar=no,scrollbars=yes,resizable=yes');\" title=\"". COMMON_BEDIT_TB_JUKEBOXPLVIEW_HELP ."\">". COMMON_BEDIT_TB_JUKEBOXPLVIEW ."</A></B></td>";
          $jukebox_colspan++;

        }

      }

    }

    if ( ($radio_html == '') && ($jukebox_html != '') ) {

      // if we have radio off and jukebox on

      if (JUKEBOX_PLAYER != 'ogg123') {
        // replace feature is on so colspan = 3
        $batch_html .= "<td colspan=\"3\" class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('edit', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHEDIT_HELP ."\">". COMMON_BEDIT_TB_BATCHEDIT ."</A></B></td>";
        $batch_colspan++;
      } else {
        // replace feature is off so colspan = 2
        $batch_html .= "<td colspan=\"2\" class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('edit', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHEDIT_HELP ."\">". COMMON_BEDIT_TB_BATCHEDIT ."</A></B></td>";
        $batch_colspan++;
      }

      $batch_html .= "<td colspan=\"2\" class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('del_tr', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHDEL_HELP ."\">". COMMON_BEDIT_TB_BATCHDEL ."</A></B></td>";
      $batch_colspan++;

    } else {

      // radio is on, no need for colspan hacking

      $batch_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('edit', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHEDIT_HELP ."\">". COMMON_BEDIT_TB_BATCHEDIT ."</A></B></td>";
      $batch_colspan++;

      $batch_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('del_tr', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHDEL_HELP ."\">". COMMON_BEDIT_TB_BATCHDEL ."</A></B></td>";
      $batch_colspan++;

      $batch_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('refresh', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHREFRESH_HELP ."\">". COMMON_BEDIT_TB_BATCHREFRESH ."</A></B></td>";
      $batch_colspan++;

      $batch_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('organize', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHORGANIZE_HELP ."\">". COMMON_BEDIT_TB_BATCHORGANIZE ."</A></B></td>";
      $batch_colspan++;

      $batch_html .= "<td class=\"content\" align=center nowrap><B><A HREF=\"Javascript:BatchEdit('report', document.playForm, 'val[]');\" title=\"". COMMON_BEDIT_TB_BATCHSHOW_HELP ."\">". COMMON_BEDIT_TB_BATCHSHOW ."</A></B></td>";
      $batch_colspan++;

    }

    $html = $batch_html.$radio_html.$row_html.$jukebox_html;

    if ($jukebox_html == '') {
      // if no jukebox, use batch + radio colspan
      $colspan = $batch_colspan + $radio_colspan;
    } else {
      // jukebox is on
      if (JUKEBOX_PLAYER != 'ogg123') {
        $colspan = $jukebox_colspan;
      } else {
        // cope with lack of replace feature with ogg
        $colspan = $jukebox_colspan + 1;
      }
    }

    return "
        <br>
        <table width='100%' border=0 cellspacing=1 cellpadding=3 class='border'>
         <tr>
           <td class=\"header\" nowrap colspan=$colspan>
             <B>". COMMON_BEDIT_HEADER ."</B>
           </td>
         </tr>
         <tr>

         $html

      </tr>
      </table>
    ";

  } else {

    return "";

  }

}

##################################################

function image_icon($file = "") {

  GLOBAL $ICONS;

  $file = check_image($file);

  if (strlen($file) > 0) {

    $file = "<a href='".$file."' target=\"NetJukeImage\" onClick=\"window.open('','NetJukeImage','width=550,height=550,top=50,left=50,menubar=no,scrollbars=yes,resizable=yes');\" title=\"".COMMON_CHECK_IMAGE_HELP."\"><img alt='".COMMON_CHECK_IMAGE_HELP."' src='".$ICONS['image']['url']."' border=0 width=10 height=8 align=absmiddle hspace=0 vspace=0></a>";

  } else {

    $file = "";

  }

  return $file;

}

##################################################

function pairSelect($table='netjuke_artists',$name='ar_id',$selected=0,$onchange="",$include_blank=0,$extra_clause='') {

  global $dbconn;

  $dbrs = $dbconn->Execute("SELECT id, name FROM $table where track_cnt > 0  or id = 1 $extra_clause order by upper(name) asc");

  $html = "<select name='$name' class=input_content onchange='$onchange'>";

  $rows = $dbrs->RecordCount();

  if (is_string ($include_blank)) {
    $html .= "<OPTION VALUE='0' >";
    $html .= format_for_display ($include_blank);
    $html .= "</OPTION>";
  }

  if ($rows > 0) {

    while (!$dbrs->EOF) {

      if ($dbrs->fields[0] == $selected) {
         $indeed = "SELECTED";
      } else {
         $indeed = "";
      }

      $html .= "<OPTION VALUE='".$dbrs->fields[0]."' $indeed>";
      $html .= substr(format_for_display($dbrs->fields[1]),0,32);
      if (strlen($dbrs->fields[1]) > 32) $html .= "...";
      $html .= "</OPTION>";

      $dbrs->MoveNext();

    }

  }

  $dbrs->Close();

  $html .= "</SELECT>";

  return $html;

}

##################################################

function alert ($msg = "Blah") {

  echo '
    <HTML>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset='.LANG_CHARSET .'">
    <SCRIPT LANGUAGE="Javascript">
    <!--
      alert("'.$msg.'");
      self.history.go(-1);
    //-->
    </SCRIPT>
    </HTML>
  ';

  exit;

}

##################################################

function javascript ($code = "alert('Blah');") {

  print '
    <HTML>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset='.LANG_CHARSET .'">
    <SCRIPT LANGUAGE="Javascript">
    <!--
      '.$code.'
    //-->
    </SCRIPT>
    </HTML>
    ';

}

##################################################

function plistSelect ($user_email,$selected) {

  GLOBAL $dbconn;

  $dbrs = $dbconn->Execute("SELECT id, title FROM netjuke_plists WHERE us_email = '$user_email' order by upper(title) asc");

  $html = "<SELECT NAME='pl_id' class=input_content>";

  $html .= "<OPTION VALUE=''>".COMMON_PLISTSELECT_1."</OPTION>";

  $rows = $dbrs->RecordCount();

  if ($rows > 0) {

    $html .= "<OPTION VALUE=''>------------</OPTION>";

    while (!$dbrs->EOF) {

      if ($dbrs->fields[0] == $selected) {
         $indeed = "SELECTED";
      } else {
         $indeed = "";
      }

      $html .= "<OPTION VALUE='".$dbrs->fields[0]."' $indeed>".$dbrs->fields[1]."</OPTION>";

      $dbrs->MoveNext();

    }

  }

  $dbrs->Close();

  $html .= "</SELECT>";

  return $html;

}

##################################################

function alphabet($type = "artists") {

   if ($type == 'artists') {
     $type_help = COMMON_ALPHABET_AR_HELP;
   } else {
     $type == 'albums';
     $type_help = COMMON_ALPHABET_AL_HELP;
   }

   $html = "\n";

   $html .= "<table border=0 cellpadding=0 cellspacing=0>\n";

   $html .= "  <tr>\n";

   $html .= "    <td align=center valign=middle nowrap>\n";

   $html .= "<pre>";

   // split the rows on |

   $rows = explode('|',ALPHA_ARRAY);

   $row_total = count($rows);

   $row_cnt = 0;

   foreach ($rows as $cells) {

     // split the groups of chars on ;

     $clusters = explode(';',$cells);

     foreach ($clusters as $this_cluster) {

       // split individual chars on ,

       $chars = explode(',', $this_cluster);

       $html .= "&nbsp;";

       foreach ($chars as $this_char) {

         $html .= "<a href=\"alphabet.php?do=alpha.${type}&val=${this_char}\" target=\"NetjukeRemote\" onClick=\"window.open('','NetjukeRemote','width=500,height=575,top=0,left=0,menubar=no,scrollbars=yes,resizable=yes');\" title=\"${type_help} ${this_char}\">${this_char}</a>";

       }

     }

     if ($row_cnt < $row_total) $html .= "\n";

     $row_cnt++;

   }

   $html .= "</pre>\n";

   $html .= "    </td>\n";

   $html .= "  </tr>\n";

   $html .= "</table>\n";

   $html .= "\n";

   return $html;

}

function GetLatestHTML ($type, $row_cnt) {

  global $NETJUKE_SESSION_VARS;

  if ($type == 'ar') {
    $latest = GetLatestArtists ($row_cnt);
    $play = BRWS_PLAY_AR_HELP;
    $randplay = BRWS_PLAY_RANDAR_HELP;
    $filter = BRWS_FILTER_AR_HELP;
    $browse = BRWS_AR_HELP;
    $edit = BRWS_EDIT_AR_HELP;
    $group = "albums";
  } else {
    $latest = GetLatestAlbums ($row_cnt);
    $play = BRWS_PLAY_AL_HELP;
    $randplay = BRWS_PLAY_RANDAL_HELP;
    $filter = BRWS_FILTER_AL_HELP;
    $browse = BRWS_AL_HELP;
    $edit = BRWS_EDIT_AL_HELP;
    $group = "artists";
  }

  $html = '';

  foreach ($latest as $item) {
    $html .= "<TR><td class='content'>";

    $html .= buildButton("./play.php?do=play_all&random=0&type=".$type."&id=".$item[0], $play, 'play')
             .  " ".BuildButton("./play.php?do=play_all&random=1&type=".$type."&id=".$item[0], $randplay, 'randplay')
             .  " ".BuildButton("./filter.php?do=list.".$group."&search_do=list.tracks&col=".$type."_id&val=".$item[0], $filter, 'info', 'NetjukeRemote')
	     .  " ".(($NETJUKE_SESSION_VARS['gr_id'] <= 2) ? buildButton("./admin/md-edit.php?do=edit&type=".$type."&id=".$item[0], $edit, 'edit', 'NetjukeRemote') : "")
             .  " <A HREF='search.php?do=list.tracks&col=".$type."_id&val=".$item[0]."&sort=".$type."' title=\"".$browse."\">"
             .  format_for_display($item[1])."</A>"
             .  " (".$item[3].")"
             .  "&nbsp;".image_icon($item[2]);

    $html .= "</td></tr>\n";
  }

  return ($html);

}

function GetLatestArtistsHTML ($row_cnt) {
  return (GetLatestHTML ('ar', $row_cnt));
}

function GetLatestAlbumsHTML ($row_cnt) {
  return (GetLatestHTML ('al', $row_cnt));
}

function GetLicenseSelect ($selected = 0, $onChange = '') {

  global $NETJUKE_LICENSES;

  $select = 0;

  if ($onChange != '')
    $on = "onChange = \"".$onChange."\"";
  else
    $on = '';

  $html = "<SELECT NAME='li_id' class='input_content' $on id='license'>\n";
  if ($selected == 0) $select = 'SELECTED';
  $html .= "<OPTION VALUE='0' $select>N/A</OPTION>\n";
  $id = 1;

  foreach ($NETJUKE_LICENSES as $license) {
    if (is_object ($license)) {
      $select = '';
      if ($license->short_name != '') {
        if ($selected === $id || $selected === $license->uri || $selected === $license->full_text)
          $select = 'SELECTED';
        $html .= "<OPTION VALUE='".$id."' $select>".$license->short_name."</OPTION>\n";
        $id++;
      }
    }
  }

  $html .= "</SELECT>\n";

  return $html;

}

function GetCCLicenseSymbols ($symbols, $logo = '', $link = '') {
  if (! is_array ($symbols))
    return;

  $html = "<table BORDER=\"0\" WIDTH=\"100\" CELLSPACING=\"0\" CELLPADDING=\"4\"><tr><td>";

  if ($logo != '') {
    if ($link != '')
      $html .= "<a href=\"".$link."\">";
    $html .= "<img class=\"icon\" src=\"".$logo."\"></td></tr><tr><td align=\"center\">";
    if ($link != '')
      $html .= "</a>";
  }

  foreach ($symbols as $symbol) {
    $html .= "<img class=\"icon\" src=\"".$symbol."\">&nbsp;";
  }

  $html .= "</td></tr></table>";

  return ($html);
}

?>
