var ro_id=1;
var ro_target=1;
var ro_counter=0;
var ro_opacity=100;
var ro_busy=0;

function roStartTimer(total) {
	ro_total = total;
	roTimerInterval = setInterval(roTimer, 500);
	if(document.getElementById("ro_number") != undefined) {
		document.getElementById("ro_number").innerHTML = ro_id+" / "+ro_total;
	}
}
function roTimer() {
	if(ro_counter >= 10 && ro_busy == 0) {
		roNextDiv(ro_total);
		ro_counter = 0;
	} 
	ro_counter++;
}

function roNextDiv(total) {
	ro_total = total;
	ro_counter = 0;
	ro_next = 1;
	if(ro_busy == 0) {
		roHideInterval = setInterval(roHideDiv, 50);
	}
	ro_busy = 1;
}
function roPreviousDiv(total) {
	ro_total = total;
	ro_counter = 0;
	ro_next = 0;
	if(ro_busy == 0) {
		roHideInterval = setInterval(roHideDiv, 50);
	}
	ro_busy = 1;
}
function roGetDiv(target) {
	ro_target = target;
	ro_counter = 0;
	ro_next = 3;
	if(ro_busy == 0) {
		roHideInterval = setInterval(roHideDiv, 50);
	}
	ro_busy = 1;
}

function roHideDiv() {
	if(ro_opacity <=0) {
		clearInterval(roHideInterval);
		ro_opacity = 0;
		document.getElementById("ro_beeld_"+ro_id).style.display = "none";
		if(document.getElementById("ro_tekst_"+ro_id) != undefined) {
			document.getElementById("ro_tekst_"+ro_id).style.display = "none";
		}
		if(document.getElementById("ro_get_"+ro_id) != undefined) {
			document.getElementById("ro_get_"+ro_id).style.border = "1px solid #ccc";
		}
		if(ro_next == 1) {
			if(ro_id == ro_total) {
				ro_id=1;
			} else {
				ro_id++;
			}
		} else if(ro_next == 0) {
			if(ro_id == 1) {
				ro_id=ro_total;
			} else {
				ro_id--;
			}
		} else {
			ro_id = ro_target;
		}
		if(document.getElementById("ro_tekst_"+ro_id) != undefined) {
			document.getElementById("ro_tekst_"+ro_id).style.display = "inline";
		}
		if(document.getElementById("ro_get_"+ro_id) != undefined) {
			document.getElementById("ro_get_"+ro_id).style.border = "1px solid #000";
		}
		roShowInterval = setInterval(roShowDiv, 50);
	} else {
		roOpacity();
		ro_opacity = ro_opacity-10;
	}
}

function roShowDiv() {
	if(ro_opacity >= 100) {
		clearInterval(roShowInterval);
		ro_opacity = 100;
		ro_busy = 0;
	} else {
		roOpacity();
		document.getElementById("ro_beeld_"+ro_id).style.display = "inline";
		if(document.getElementById("ro_number") != undefined) {
			document.getElementById("ro_number").innerHTML = ro_id+" / "+ro_total;
		}
		ro_opacity = ro_opacity+10;
	}
}

function roOpacity() {
	if (navigator.appName!="Microsoft Internet Explorer") {
		document.getElementById("ro_beeld_"+ro_id).style.opacity = (ro_opacity/100);
	} else {
		if (navigator.appVersion>=8) {
			document.getElementById("ro_beeld_"+ro_id).object.filters.item("DXImageTransform.Microsoft.Fade").ro_opacity;
		} else {
			document.getElementById("ro_beeld_"+ro_id).style.filter = "alpha(opacity="+ro_opacity+")";
		}
	}
}