var top_content = document.getElementById('top_content');
var slides = getElementsByClassName('switchcontent', 'div', top_content);
var count = slides != null ? slides.length : 0;
var option = new Array();
var intervalID = null;

for(var i=0; i<count; i++) {
	option[i] = 'slide' + (i+1);
}

// extra slideshow_1 in the options variable is to fix bug on NEXT when viewing slideshow 5
option[count] = 'slide1';

var iDiv = 0;

function switch1(div, iSlide) {
	for(var i=0; i<count; i++) {
		if (document.getElementById(option[i])) {
        	obj=document.getElementById(option[i]);
        	obj.style.display=(option[i]==div)? "block" : "none";
       }
    }
	iDiv = iSlide;
	
	// we want to rotate the slide after XX number of milliseconds
	if(intervalID != null && intervalID > 0) {
		window.clearTimeout(intervalID);
	}
	intervalID = window.setTimeout('next()', 7000);	
}

function next () {
	// if someone hit the next button, we want to reset the timer
	window.clearTimeout(intervalID);
	
	var div = option[iDiv];
	switch1(div,iDiv);
	if (iDiv < count - 1) {
		iDiv = iDiv + 1;
	} 
	else {
    	iDiv = 0;
	}
}
 
window.onload=function () {switch1('slide1',1);}
