
var featureWidth = 90;
var flickPause = 5000;
var tout = null;

var numStories;
var currentFeature;

function rotateFeature()
{
  goFeature( +1 );
}

function featureTip( evnt )
{
  var direction = arguments[1];
  var stepTo = arguments[2];
  if( typeof(ftrs) == "undefined" ) return;
  
  var tipFeature = (typeof(stepTo)!="undefined")?(stepTo):(currentFeature + direction);
  
  if( tipFeature > numStories ) tipFeature = 1;
  if( tipFeature < 1 ) tipFeature = numStories;
  
  showToolTip( ftrs[tipFeature], "featureTip", evnt )
}

function goFeature()
{
  var direction = arguments[0];
  var stepTo = arguments[1];
  if( tout != null )
  {
    clearTimeout( tout );
  }
  getElt( "feature" + currentFeature ).style.display = "none";
  getElt( "listFeature" + currentFeature ).className = "listFeature";

  currentFeature = (typeof(stepTo)!="undefined")?(stepTo):(currentFeature + direction);

  if( currentFeature > numStories ) currentFeature = 1;
  if( currentFeature < 1 ) currentFeature = numStories;

  getElt( "feature" + currentFeature ).style.display = "block";
  getElt( "listFeature" + currentFeature ).className = "listFeature active";

  tout = setTimeout( "rotateFeature()", flickPause );
}

function setupFeatures()
{
  var slider = getElt( "featureSlider" );
  numStories   = slider.childNodes.length;
  currentFeature = numStories;
  rotateFeature();
}
setupFeatures();