    var height = 5
    var width = 2
    var newsitem = 0;
    var fading = 0
    var fading_row = 0
    var fading_col = 0
    var initialfill = true;
    var initialfill_row = 0;
    var initialfill_col = 0;

    function start() {
  /*
        // get the reference for the body
        var mybody=document.getElementsByTagName("body").item(0);
        // creates an element whose tag name is TABLE
        mytable = document.createElement("TABLE");
        // creates an element whose tag name is TBODY
        mytablebody = document.createElement("TBODY");
        // creating all cells
        for(j=0; j < height; j++) {
            // creates an element whose tag name is TR
            mycurrent_row=document.createElement("TR");
            for(i=0; i < width; i++) {
                // creates an element whose tag name is TD
                mycurrent_cell=document.createElement("TD");
                // creates a Text Node
                //currenttext=document.createTextNode("cell is row "+j+", column "+i);
                currenttext=document.createTextNode("Breaking news...");
                // appends the Text Node we created into the cell TD
                mycurrent_cell.appendChild(currenttext);
                // appends the cell TD into the row TR
                mycurrent_row.appendChild(mycurrent_cell);
            }
            // appends the row TR into TBODY
            mytablebody.appendChild(mycurrent_row);
        }
        // appends TBODY into TABLE
        mytable.appendChild(mytablebody);
        // appends TABLE into BODY
        mybody.appendChild(mytable);
        // set attributes
        mytable.setAttribute("border","1");
        mytable.setAttribute("cellPadding","6");
        mytable.setAttribute("width","100%");
        mytable.style.fontFamily = "arial";
        mytable.style.borderCollapse = "collapse";
        mytable.bordercolorlight = "#C0C0C0";
        mytable.bordercolordark  = "#C0C0C0";       
*/                
        setTimeout("requestnext()", 50);
    }
    
    function replaceitem(row, col, text)
    {
        mybody=document.getElementsByTagName("body").item(0);
        mytable=mybody.getElementsByTagName("table").item(0);
        mytablebody=mytable.getElementsByTagName("tbody").item(0);
        myrow=mytablebody.getElementsByTagName("tr").item(row);
        mycell=myrow.getElementsByTagName("td").item(col);
        new_cell=document.createElement("TD");
        new_cell.vAlign = "top";

        new_cell.innerHTML = text;
        //newtext=document.createTextNode(text);
        //new_cell.appendChild(newtext)

        fading = 255
        fading_row = row
        fading_col = col
        
        new_cell.style.color = "rgb("+fading+","+fading+","+fading+")";
        new_cell.setAttribute("width", "50%");
        new_cell.setAttribute("valign", "top");
        
        myrow.replaceChild(new_cell, mycell)
        
        setTimeout("fadeitem()", 20);
    }

    function fadeitem()
    {
        if (fading > 0)
        {
            mybody=document.getElementsByTagName("body").item(0);
            mytable=mybody.getElementsByTagName("table").item(0);
            mytablebody=mytable.getElementsByTagName("tbody").item(0);
            myrow=mytablebody.getElementsByTagName("tr").item(fading_row);
            mycell=myrow.getElementsByTagName("td").item(fading_col);           
            
            mycell.style.color = "rgb("+fading+","+fading+","+fading+")";
            
            if (initialfill == true)
            {
                fading = fading - 16;
            }
            else
            {
                fading = fading - 4;
            }

            if (fading >= 0)
            {
                setTimeout("fadeitem()", 20);
            }
            else
            {
                if (initialfill == true)
                {
                    setTimeout("requestnext()", 10);
                }
                else
                {
                    setTimeout("requestnext()", 2000);
                }
            }
        }
    }

    function requestnext()
    {
        var filename = "data/news_" + newsitem + ".html";

        loadurl(filename);

        newsitem ++;
        if (newsitem >= 50)
        {
            newsitem = 0;
        }
    }
    
    function replacerandom(text)
    {
        row = Math.floor(Math.random()*(height))
        col = Math.floor(Math.random()*(width))
        
        if (row >= 0 && row < height &&
            col >= 0 && col < width)
        {
            replaceitem(row,col, text);
        }
    }

    function replace_initialfill_next(text)
    {
        replaceitem(initialfill_row, initialfill_col, text);

        initialfill_col ++;

        if (initialfill_col >= width)
        {
            initialfill_row ++;
            initialfill_col = 0;
        }

        if (initialfill_row >= height)
        {
            // finished doing initial fill, switch to regular delays.
            initialfill = false;
        }
    }

    function loadurl(dest) {
     
         try 
         {
          
             // Moz supports XMLHttpRequest. IE uses ActiveX. 
             // browser detction is bad. object detection works for any browser
             xmlhttp = window.XMLHttpRequest ?
                          new XMLHttpRequest() :
                               new ActiveXObject("Microsoft.XMLHTTP");
          
         }
         catch (e) 
         {
           // browser doesn't support ajax. handle however you want
         }
         
         // the xmlhttp object triggers an event everytime the status changes
         // triggered() function handles the events
         xmlhttp.onreadystatechange = triggered;
         
         // open takes in the HTTP method and url.
         xmlhttp.open("GET", dest);
         
         // send the request. if this is a POST request we would have
         // sent post variables: send("name=aleem&gender=male)
         // Moz is fine with just send(); but
         // IE expects a value here, hence we do send(null);
         xmlhttp.send(null);
         
         //triggered();
     
    }

    function triggered() {
     
      // if the readyState code is 4 (Completed)
      // and http status is 200 (OK) we go ahead and get the responseText
      // other readyState codes:
      // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
      if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      
          // xmlhttp.responseText object contains the response.
          text = xmlhttp.responseText;
          
          if (initialfill == true)
          {
              replace_initialfill_next(text);
          }
          else
          {
              replacerandom(text);
          }
       }
       
       //replacerandom("blah");
     
    }
