var switchtime = 3000;  //2 sec in millisec
var boolContinue = true;
var id = 0;

function ajaxFunction(id) {
  var xmlHttp;
  try {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  } catch (e) {
  // Internet Explorer
     try {
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
       try {
         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {
         alert("Uw browser ondersteunt geen AJAX!");
         return false;
       }
    }
  }
  this.id = id;
  xmlHttp.onreadystatechange=function() {
    if(xmlHttp.readyState==4) {
     document.getElementById("FRONT_AB").innerHTML = xmlHttp.responseText;
     for(i = 1; i <= 4; i++) {
       document.getElementById("top" + i).className = "";
     }
     document.getElementById("top" + id).className = "active";

    }
  }
  xmlHttp.open("GET","logic/getfrontab.php?id=" + id,true);
  xmlHttp.send(null);
}

function loopTabs(){
	if(id == undefined){
		id = 1;
	}
	
	if( boolContinue ){
		if(id >= 4){
				id = 1;
			} else {
				id++;
			}
	
		ajaxFunction(id);
	}
	setTimeout("loopTabs(" + id + ")" , switchtime);
}

function tabOver(){
	boolContinue = false;
}

function tabOut(){
	if(!boolContinue){
		boolContinue = true;
	}
}