//Original Ticker By Dynamic Drive (http://www.dynamicdrive.com) -- Edits by AC & SH 
var ie4=document.all
var curindex=0
var totalcontent=0
var running = true;
var rotation_timer=5000;

function get_total(){
if (ie4){
while (eval("document.all.content"+totalcontent))
totalcontent++
}
else{
while (document.getElementById("content"+totalcontent))
totalcontent++
}
}

function contract_all(){
for (y=0;y<totalcontent;y++){
if (ie4)
eval("document.all.content"+y).style.display="none"
else
document.getElementById("content"+y).style.display="none"
}
}

function expand_one(which){
contract_all()
if (ie4)
eval("document.all.content"+which).style.display="inline"
else
document.getElementById("content"+which).style.display="inline"
}

function content_advance() {
	if (running) {
		curindex=(curindex<totalcontent-1)? curindex+1: 0
		display_content()
	}
}

function display_content() {
	if(brow=="Safari") { //only showing "content0" div for Safari, as rotation doesn't work properly on that browser
		get_total()
		contract_all()
		expand_one(curindex)
		document.getElementById("switch_controls").style.display="none"
	}
	else {
		if (running) {
		get_total()
		contract_all()
		expand_one(curindex)
		setTimeout("content_advance()", rotation_timer)
		}
		else {
		running=true
		display_content()
		document.getElementById("div1").innerHTML='<a href="#" name="link4" onclick="stop_content()"><img src="//media.highlights.com/img-parents-slideshownav/Stop.gif" name="Image2" alt="Stop Slideshow"></a>'
		}
	}
}

function stop_content() {
	if (running) {
	running=false
	document.getElementById("div1").innerHTML='<a href="#" name="link3" onclick="display_content()"><img src="//media.highlights.com/img-parents-slideshownav/Play.gif" name="Image1" alt="Play Slideshow"></a>'
	}
}

function display_next() {
	stop_content()
	get_total()
	contract_all()
	next_calc()
	expand_one(curindex)
}

function display_previous() {
	stop_content()
	get_total()
	contract_all()
	previous_calc()
	expand_one(curindex)
}

function next_calc(){
	curindex=curindex+1
	if (curindex==3) {
	curindex=0
	}
}

function previous_calc() {
	curindex=curindex-1
	if (curindex==-1) {
	curindex=2
	}
}

window.onload=display_content