// 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<(224-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){
    with(News){
      for(i in data)
        msg[i]='<strong>'+title+':</strong> '+data[i][0]+': <a href="'+(data[i][2]?data[i][2]:url)+'" style="color:#4b4b4b;" 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 224-Math.round((224-c)/News.steps)*Math.abs(step);
    }
    with(News)
      if(Math.abs(step)<=steps&&step!=0){
        var x=0;
        ida.style.color='rgb('+x+','+x+','+x+')';//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);
        }
    }
  }
}


