<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

function block_alphabar($params) {
  global $dbConn;

  if (!$params['template']) {
    $params['template'] = 'block.alphabar.html';
  }

  $tpl = new Template;

  $alpha_key = "key";
  if (isset($params['alpha_key'])) {
    $alpha_key = $params['alpha_key'];
  }

  $alpha_str = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  if (isset($params['alpha_str'])) {
    $alpha_str = $params['alpha_str'];
  }

  $cmd = "global \$$alpha_key;";
  eval($cmd);
  $cmd = "\$alpha_selected = \$$alpha_key;";
  eval($cmd);

  $url = $_SERVER['REQUEST_URI'];
  $url = str_replace(strstr($url, "&$alpha_key"), "", $url);
  $url = preg_replace("|pg_which=\w*|", "", $url);

  $tpl->assign("alpha_str", $alpha_str);
  $tpl->assign("alpha_length", strlen($alpha_str));
  $tpl->assign("alpha_key", $alpha_key);
  $tpl->assign("alpha_selected", $alpha_selected);
  $tpl->assign("url", $url);
  $tpl->display("blocks/" . $params['template']);
}

?>
