var filesadded="" //list of files already added
var timertje = null;
var pagina  = "";

function ajaxpage(keyPage) {
	 
//Effect.Fade($("welkomcontainer"), {duration: 0.3, from: 1.0, to: 0.1} );
 	pagina = keyPage;

	setTimeout ( ajaxpage_laden, 5000); 
	
}


function ajaxpage_laden() {
 	if(timertje)
	{
		window.clearTimeout(timertje);
		timertje = null;
	}
	keyPage = pagina;

    // Use AJAX to load other pages
    var pageContent;
    teller=Math.floor(Math.random()*1000000);

	keyPage = keyPage + '&teller=' + teller;
    // Check if the browser knows the standard request
    if(window.XMLHttpRequest) {
        // Mozilla etc
        pageContent = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        // Internet Explorer 6
        pageContent = new ActiveXObject("Microsoft.XMLHTTP");            
    // It doesn't know any, so give an error    
    } else {
        alert('Browser doesn\'t support AJAX'); 
    }

    // Open the file
    pageContent.onreadystatechange = StateChange;
	
	pageContent.open('GET', keyPage, true);
	pageContent.send(null);

    // Listen for a change state
    function StateChange() {
    
//0: Request has not been initialized yet.
//1: The request is made.
//2: The request is sent.
//3: The request is handled by the server.
//4: The request is done.
		if(pageContent.readyState == 1) {
				
				StartProgress();
				//document.getElementById("loader").style.display = "block";
		}
        // The state is changed, but is it 4?
        if(pageContent.readyState == 4) {
			ges_item = pageContent.responseText.substring(0,1);
		

			document.getElementById("ajaxcontainer").innerHTML = pageContent.responseText.substring(1);
			EndProgress();
        	init_dw_Scroll2(ges_item);
	 
			ajaxpage(pagina); 
        }
        
    }

}


var progressTimer = 0;
var progress = false;
var a,b;

function StartProgress() {
	progress = true;
	if (progressTimer != null)
		window.clearTimeout(progressTimer);
	
	progressTimer = window.setTimeout(showProgress, 220);
} // ajax.StartProgress


// hide any progress indicator soon.
function EndProgress() {
  progress = false;
  if (progressTimer != null)
    window.clearTimeout(progressTimer);
  
  progressTimer = window.setTimeout(showProgress, 20);
} // ajax.EndProgress

function showProgress()
{
	progressTimer = null;
	var a = document.getElementById("ajaxloader");
	
	if (progress && (a != null)) {
		// just display the existing object
		a.style.top = "100px";
		a.style.display = "";
		//b.style.display = "";
	}else if (progress){
		a = document.createElement("div");
		a.id = "ajaxloader";
		a.style.position = "absolute";
		a.style.top = "100px";
		a.style.left = "150px";
		a.style.width = "99%";
		a.style.height = "100px"
		 a.style.margin = "0px";
		a.style.padding = "0px";
		a.style.verticalalign = "bottom";
		a.style.textAlign = "center";
		// style="vertical-align:bottom
		a.innerHTML = "<img  src='./assets/images/ajax-loader.gif'> even geduld...";
		document.body.appendChild(a);
 	
		
	}else if (a) {
	 	a.style.display = "none";
		//b.style.display = "none";
	}
    
	
}


 
