// globale variabler
	var tab;
	var thisCommand = "1"; 
	
	function initDocument() {
		tab = DynarchRB.setup("rollbar", { changeLocation: true, tabs: false, noInit: true, animation: [ vSpeed, 100 ]});
		tab.addEventListener("onAnimation", updatePercent);
		tab.addEventListener("onChangeEnd", updatePercent);
		tab.addEventListener("onAnimation", updateSite);
		tab.addEventListener("onInit", loadSite);
		tab.init();
	}
	
	function updatePercent(prev, curr, a) {
		var val;
		if (this.event == "onAnimation") {
			var p1 = Math.round(100 / (this.sections.length - 1) * prev);
			var p2 = Math.round(100 / (this.sections.length - 1) * curr * a.percent / 100);
			val = Math.round(a.comp(p1, p2));
		} else {
			val = Math.round(100 / (this.sections.length - 1) * curr);
			document.getElementById("prevlink").style.visibility = val == 0 ? "visible" : "visible";
			document.getElementById("nextlink").style.visibility = val == 100 ? "visible" : "visible";
		}
		document.getElementById("percent").innerHTML = val + "%";
	}
	
	function updateSite(prev, curr, a) {
		if ((eval(curr+1)) > 9) {
				$number = eval(curr+1);
		} else {
				$number = "0"+eval(curr+1);
		}
		
		if (countTabs > 9) {
			$number2 = countTabs;
		} else {
			$number2 = "0"+countTabs;
		}
		
		window.parent.document.getElementById("site").innerHTML = $number + " / " + $number2;
	}
	
	function loadSite(prev, curr, a) {
		if (countTabs > 9) {
			$number2 = countTabs;
		} else {
			$number2 = "0"+countTabs;
		}
		
		window.parent.document.getElementById("site").innerHTML = "01 / " + $number2;
		document.getElementById("auto").innerHTML = "<a href=\"javascript:startAutomatisk()\">Start Automatisk ("+eval(vTimeout/1000)+" sekunder)</a>";
	}
	
	function theNext() {
		if (document.getElementById("percent").innerHTML == "0%") {
			thisCommand = "1";
		} 
		
		if (document.getElementById("percent").innerHTML == "100%") {
			thisCommand = "2";
		} 
		
		if (thisCommand == "1") {
			tab.next();
		}
		
		if (thisCommand == "2") {
			tab.prev();
		}
		
		v1 = window.setTimeout("theNext()", vTimeout);
	}
	
	function nextTab() {
		clearTimeout(v1);
		tab.next();
		v1 = window.setTimeout("theNext()", vTimeout);
	}
	
	function prevTab() {
		clearTimeout(v1);
		tab.prev();
		v1 = window.setTimeout("theNext()", vTimeout);
	}
	
	function stopAutomatisk() {
		document.getElementById("auto").innerHTML = "<a href=\"javascript:startAutomatisk()\">Start Automatisk ("+eval(vTimeout/1000)+" sekunder)</a>";
		clearTimeout(v1);
	}
	
	function startAutomatisk() {
		document.getElementById("auto").innerHTML = "<a href=\"javascript:stopAutomatisk()\">Stop Automatisk</a>";
		theNext();
	}
