divs = ['test1','test2','test3'];

function hideDivs() {
for (var i=0; i<divs.length; i++)
document.getElementById(divs[i]).style.display = 'none';
}

function showDiv() {
hideDivs(); //hide them all before we show the next one.
var randomDiv = divs[Math.floor(Math.random()*divs.length)];
var div = document.getElementById(randomDiv).style.display =
'block';

setTimeout(showDiv,500000); //set a delay before showing the next div
}



div = ['spons1','spons2','spons3','spons4','spons5'];

function hideDiv() {
for (var i=0; i<div.length; i++)
document.getElementById(div[i]).style.display = 'none';
}

function showDiv2() {
hideDiv(); //hide them all before we show the next one.
var randomDiv = div[Math.floor(Math.random()*div.length)];
var div1 = document.getElementById(randomDiv).style.display =
'block';

setTimeout(showDiv2,5000); //set a delay before showing the next div
}