  var direction   = 0;
  var speed       = 24;
  var speed_coeff = 0;
  var ftHeight    = 165;
  var ffCount     = 0;
  var suppress_pause  = false;
  var position  = new Array();
  position[0]   = 0;
  position[1]   = 1*ftHeight;
  position[2]   = 2*ftHeight;
  position[3]   = 3*ftHeight;
  position[4]   = 4*ftHeight;
  var firstFeature  = 0;
  var nextIndex     = (hotpicks_img.length < 6) ? 0 : 5;

  var pre_mover;
  function mouseover_item(whichItem) {
    pre_mover = direction;
    document.getElementById('featureItem_'+whichItem).className = 'featureItem_over';
    stopLoop();
    return true;
  }
  function mouseout_item (whichItem) {
    document.getElementById('featureItem_'+whichItem).className = 'featureItem';
    if (pre_mover < 0)  playLoop();
    else                reverseLoop();
    return true;
  }
  function select_item (whichItem) {
    document.getElementById('featureItem_'+whichItem).className = 'featureItem_select';
    location.href = "/view_full_record"+HREF_APPEND+".php?id="+document.getElementById('fi_id_'+whichItem).value+"&ref=2";
  }

  var timer;
  var timer_int = 1;
  function scroll_features (newdir) {
    if (newdir != undefined)  direction = newdir;
    switch (direction) {
      case 0 :
        return;
        break;
      case -1 :
        if (position[firstFeature] <= ftHeight*-1) {
          position[firstFeature]  = 4*ftHeight;
          document.getElementById('fi_img_'+firstFeature).src             = hotpicks_img[nextIndex];
          document.getElementById('fi_name_'+firstFeature).innerHTML      = hotpicks_name[nextIndex];
//           document.getElementById('fi_location_'+firstFeature).innerHTML  = hotpicks_location[nextIndex];
          document.getElementById('fi_id_'+firstFeature).value            = hotpicks_id[nextIndex];
          document.getElementById('featureItem_'+firstFeature).style.top  = position[firstFeature]+'px';

          firstFeature  = (firstFeature == (position.length-1))   ? 0 : firstFeature+1;
          nextIndex     = (nextIndex == (hotpicks_name.length-1)) ? 0 : nextIndex+1;
          if (!suppress_pause)    timer_int = 1000;
          else if (ffCount > 1)   ffCount--;
          else if (ffCount == 1)  {
            speed_coeff     = 0;
            suppress_pause  = false;
            document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
            document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOff.gif";
            document.getElementById('reverseButton').src      = "/stat/buttonBackOff.gif";
            document.getElementById('playButton').src         = "/stat/buttonPlayOn.gif";
            document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOff.gif"
            clearTimeout(timer);
            timer_int   = 1000;


          }
          // End if firstFeature gone off top
        } else if (timer_int == 1000) timer_int = speed;

        if (position.length > 1) for (i=0;i<position.length;i++) {
          position[i] -= (1+speed_coeff);
          document.getElementById('featureItem_'+i).style.top = position[i]+'px';
        }

        timer = setTimeout('scroll_features()',timer_int);
        break;

      case 1 :
        if (position[firstFeature] >= ftHeight*4) {
          position[firstFeature]  = ftHeight*-1;
          document.getElementById('fi_img_'+firstFeature).src             = hotpicks_img[nextIndex];
          document.getElementById('fi_name_'+firstFeature).innerHTML      = hotpicks_name[nextIndex];
          document.getElementById('fi_location_'+firstFeature).innerHTML  = hotpicks_location[nextIndex];
          document.getElementById('featureItem_'+firstFeature).style.top  = position[firstFeature]+'px';

          firstFeature  = (firstFeature == 0) ? position.length-1       : firstFeature-1;
          nextIndex     = (nextIndex == 0)    ? hotpicks_name.length-1  : nextIndex-1;

          if (!suppress_pause)    timer_int = 1000;
          else if (ffCount > 1)   ffCount--;
          else if (ffCount == 1)  {
            speed_coeff     = 0;
            suppress_pause  = false;
            document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
            document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOff.gif";
            document.getElementById('reverseButton').src      = "/stat/buttonBackOn.gif";
            document.getElementById('playButton').src         = "/stat/buttonPlayOff.gif";
            document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOff.gif";
            clearTimeout(timer);
            timer_int       = 1000;
          }
        } else if (timer_int === 1000) timer_int = speed;

        if (position.length > 1) for (i=0;i<position.length;i++) {
          position[i] += (1+speed_coeff);
          document.getElementById('featureItem_'+i).style.top = position[i]+'px';
        }

        timer = setTimeout('scroll_features()',timer_int);
        break;
    }
  }

  function stopLoop(nochange) {
    document.getElementById('stopButton').src = "/stat/buttonStopOn.gif";
    document.getElementById('fastrewindButton').src = "/stat/buttonFastReverseOff.gif";
    document.getElementById('reverseButton').src = "/stat/buttonBackOff.gif";
    document.getElementById('playButton').src = "/stat/buttonPlayOff.gif";
    document.getElementById('fastforwardButton').src = "/stat/buttonForwardOff.gif";

    scroll_features(0);
    return true;
  }

  var ind;
  function playLoop(nochange,ff) {
    ind = 661;
    for (i=0;i<position.length;i++) if (position[i] < ind) {
      ind = position[i];
      firstFeature = i;
    }
    if (nextIndex == hotpicks_name.length-1)  nextIndex = 0;
    else                                      nextIndex++;
    if (timer != undefined) clearTimeout(timer);
    document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
    document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOff.gif";
    document.getElementById('reverseButton').src      = "/stat/buttonBackOff.gif";
    document.getElementById('playButton').src         = "/stat/buttonPlayOn.gif";
    document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOff.gif";
    scroll_features(-1);
    return true;
  }

  function reverseLoop(nochange) {
    ind = -166;
    for (i=0;i<position.length;i++) if (position[i] > ind) {
      ind = position[i];
      firstFeature = i;
    }
    if (nextIndex == 0) nextIndex = hotpicks_name.length-1;
    else                nextIndex--;
    if (timer != undefined) clearTimeout(timer);
    document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
    document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOff.gif";
    document.getElementById('reverseButton').src      = "/stat/buttonBackOn.gif";
    document.getElementById('playButton').src         = "/stat/buttonPlayOff.gif";
    document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOff.gif";
    scroll_features(1);
    return true;
  }

  function fastForwardLoop() {
    suppress_pause  = true;
    speed_coeff     = 30;
    ind             = 661;
    ffCount         = 3;
    for (i=0;i<position.length;i++) if (position[i] < ind) {
      ind = position[i];
      firstFeature = i;
    }
//     for (i=0;i<3;i++) {
      if (nextIndex == hotpicks_name.length-1)  nextIndex = 0;
      else                                      nextIndex++;
//     }
    if (timer != undefined) clearTimeout(timer);
    document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
    document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOff.gif";
    document.getElementById('reverseButton').src      = "/stat/buttonBackOff.gif";
    document.getElementById('playButton').src         = "/stat/buttonPlayOff.gif";
    document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOn.gif";
    scroll_features(-1);
    return true;
  }

  function fastRewindLoop() {
    suppress_pause  = true;
    speed_coeff     = 30;
    ind             = -166;
    ffCount         = 3;
    for (i=0;i<position.length;i++) if (position[i] > ind) {
      ind = position[i];
      firstFeature = i;
    }
    for (i=0;i<3;i++) {
      if (nextIndex == 0) nextIndex = hotpicks_name.length-1;
      else                nextIndex--;
    }
    if (timer != undefined) clearTimeout(timer);
    document.getElementById('stopButton').src         = "/stat/buttonStopOff.gif";
    document.getElementById('fastrewindButton').src   = "/stat/buttonFastReverseOn.gif";
    document.getElementById('reverseButton').src      = "/stat/buttonBackOff.gif";
    document.getElementById('playButton').src         = "/stat/buttonPlayOff.gif";
    document.getElementById('fastforwardButton').src  = "/stat/buttonForwardOff.gif";
    scroll_features(1);
    return true;
  }

  function doOnload () {
    document.getElementById('featureScreen').style.display = 'block';
    document.getElementById('featureLoading').style.display = 'none';
    scroll_features(-1);
  }

  window.onload = doOnload;