// voorbereiden accordion list en links h6
var accordion = "internalnav";
var ContentHeight = 380;
var TimeToSlide = 500.0;
var openAccordion = '';
function prepareInternalnav() {
	var clss, links, sectionId, txtId, sId, i, maxH, maxW;
   if ( ! document.getElementsByTagName){ return false;}
   if ( ! document.getElementById){ return false;}
   if ( ! document.getElementById("internalnav")){ return false;}
   var nav = document.getElementById("internalnav");
   var accord = nav.getElementsByTagName("ul");
   for (var j = 0; j < accord.length; j ++ ){
      //clss = accord[j].className;
      links = accord[j].getElementsByTagName("h6");
      for (i = 0; i < links.length; i++ ) {
         sectionId = links[i].className;
         txtId = sectionId + "-txt";
         if ( ! document.getElementById(sectionId)){ continue;}
         sId = document.getElementById(sectionId);
         sId.style.display = "none";
         links[i].destination = sectionId;
         links[i].dest = txtId;
         links[i].req = sectionId + ".html";
         //links[i].cls = clss;
         links[i].onclick = function() {
			//if(this.cls == "acc"){
            	showSection(this.destination);
			//};
			makerequest(this.req, this.dest);
            return false;
         };
      }
   }
}
//=== aanroepen interne link + accordionslide====//
function accLink(destination, req, dest){
	showSection(destination);
	makerequest(req, dest);
	
}
function showSection(destination){
   var nID = destination;
   if(openAccordion == nID){
      nID = '';
   }
   setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",'" + openAccordion + "','" + nID + "')", 33);
   openAccordion = nID;
}

function animate(lastTick, timeLeft, closingId, openingId){
   var curTick = new Date().getTime();
   var elapsedTicks = curTick - lastTick;
   var opening = (openingId === '') ? null : document.getElementById(openingId);
   var closing = (closingId === '') ? null : document.getElementById(closingId);
   if(timeLeft <= elapsedTicks){
      if(opening !== null){
         opening.style.height = ContentHeight + 'px';
      }
      if(closing !== null){
         closing.style.display = 'none';
         closing.style.height = '0px';
      }
      return;
   }
   timeLeft -= elapsedTicks;
   var newClosedHeight = Math.round((timeLeft / TimeToSlide) * ContentHeight);
   if(opening !== null){
      if(opening.style.display != 'block'){
      opening.style.display = 'block';
      }
      opening.style.height = (ContentHeight - newClosedHeight) + 'px';
   }
   if(closing !== null){
      closing.style.height = newClosedHeight + 'px';
   }
   setTimeout("animate(" + curTick + "," + timeLeft + ",'" + closingId + "','" + openingId + "')", 33);
}
//==== initialisatie functie opstarten pagina
function addLoadEvent(fn){
var oldfn;
   if (typeof window.addEventListener != 'undefined'){
      window.addEventListener('load', fn, false);
   }
   else if (typeof document.addEventListener != 'undefined'){
      document.addEventListener('load', fn, false);
   }
   else if (typeof window.attachEvent != 'undefined'){
      window.attachEvent('onload', fn);
   }
   else{
      oldfn = window.onload;
      if (typeof window.onload != 'function'){
         window.onload = fn;
      }
      else{
         window.onload = function() {
            oldfn();
            fn();
			
         };
      }
   }
}

//======================= verzoek tot inladen nieuwe pagina's. + initialiseren slideshows en mail pagina ========================

var xmlhttp = false;
try {
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
   try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch (E) {
      xmlhttp = false;
   }
}
if ( ! xmlhttp && typeof XMLHttpRequest != 'undefined') {
   xmlhttp = new XMLHttpRequest();
}

function makerequest(serverPage, objID) {
	var page;
   var obj = document.getElementById(objID);
   xmlhttp.open("GET", serverPage);
   xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         obj.innerHTML = xmlhttp.responseText;
		 page=serverPage;
		 switch (page)
		{
		case 'contact.html':
		//fId='res';
		  intitializeEmailClient('res');
		  break;
		  default:
		  break;
		}
      }
   };
   xmlhttp.send(null);
}
addLoadEvent(function(){
    prepareInternalnav();
	}
);

