/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Fang | http://www.webdeveloper.com/forum/showthread.php?t=191419Licensed under: Public Domain
 */



function postNews() {
  aLI=document.getElementById('news').getElementsByTagName('li');
  for(var i=0; i<aLI.length; i++)  {
    aLI[i].style.display="none";
    aLI[i].getElementsByTagName('p')[0];
  }

  aLI2=document.getElementById('news2').getElementsByTagName('li');

  for(var i=0; i<aLI2.length; i++)  {
    aLI2[i].style.display="none";
    aLI2[i].getElementsByTagName('p')[0];
  }


  rotate(aLI.length-1,aLI2.length-1);

};

var aLI=[];
var aLI2=[];
var timerRUN=null;
var Speed=5000; // change as required

function rotate(idx,idx2) {



  aLI[idx].style.display="none";
  idx=(idx<aLI.length-1)? ++idx : 0;
  aLI[idx].style.display="block";

  aLI2[idx2].style.display="none";
  idx2=(idx2<aLI2.length-1)? ++idx2 : 0;
  aLI2[idx2].style.display="block";


  timerRUN=setTimeout('rotate('+idx+','+idx2+')', Speed);


}

function inView() {
  var newsItem=0;

  for(var i=0; i<aLI.length; i++) {
    if(aLI[i].style.display=="block") {newsItem= i;}
  }


  return newsItem;
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  postNews();
});


