// 2006/12/4 Josef Kubin <jkubin[at]redhat[dot]com>
var News={
  delay     : 5000,        // delay between each news
  steps     : 50,          // number of steps for fading 1<x<(255-gray) make sense
  stepdelay : 40,      // how fast step
  gray      : 50,           // final gray color 0 = black
  url       : '/news/',      // if url isn't passed with third parameter then use default url
  // ***** internal variables *****
  ie4       : document.all&&!document.getElementById,  // detection of MSIE disaster
  msg       : [],
  i         : 0,
  ida       : null,
  id        : null,
  Init:function(title,data){
      document.write('<div id="fnews" style="color:#fff;"></div>');
      with(News){
        for(i in data)
            msg[i]='<strong>'+title+':</strong> '+data[i][0]+' &mdash; <a href="'+(data[i][2]?data[i][2]:url)+'" style="color:#fff;" id="fnewsa">'+data[i][1]+'</a>';
    i=0;
        if(ie4){
        id=document.all('fnews');
        window.onload=function(){
      News.Fading(0);
        };
    }
    else{
        id=document.getElementById('fnews');
        Fading(0);
    }
      }
      },Fading:function(step){
      function col(c){
    return 255-Math.round((255-c)/News.steps)*Math.abs(step);
      }
      with(News)
        if(Math.abs(step)<=steps&&step!=0){
        var x=col(gray);
        ida.style.color='rgb('+col(0)+','+col(102)+','+col(204)+')';//Red Hat css: a:visited{color:#69c;} a:link{color:#06c;}
            id.style.color='rgb('+x+','+x+','+x+')';
            setTimeout('News.Fading('+(++step)+')',stepdelay);
        }
        else
        if(step>steps)
          setTimeout('News.Fading(-News.steps)',delay);
        else{
          if(i==msg.length)
            i=0;
          id.innerHTML=msg[i++];
          ida=ie4?document.all('fnewsa'):id.getElementsByTagName('a')[0];
          Fading(1);
        }
  }
}

