 
      document.onkeyup = function(e) {
         if (!e) var e = window.event;
         if(window.event) { keynum = e.keyCode; }// IE
         else if(e.which) { keynum = e.which; }// Netscape/Firefox/Opera 
         if(keynum == 27 && document.getElementById('popupWindowFoto').style.display != 'none') { toggleDiv('popupWindowFoto','hidden'); } //als popup zichtbaar is en esc wordt ingedrukt.
         if(keynum == 27 && document.getElementById('popupWindowUpload').style.display != 'none') { toggleDiv('popupWindowUpload','hidden'); } //als popup zichtbaar is en esc wordt ingedrukt.
         if(keynum == 27 && document.getElementById('popupWindowEdit').style.display != 'none') { toggleDiv('popupWindowEdit','hidden'); } //als popup zichtbaar is en esc wordt ingedrukt.
      }
      
      function toggleDiv(id,action) {
         if(action == "") {
            if(document.getElementById(id).style.display == "none")  { document.getElementById(id).style.display = ""; }
            else { document.getElementById(id).style.display = "none"; }
         }
         else if(action == 'hidden') { document.getElementById(id).style.display = "none"; }
         else { document.getElementById(id).style.display = ""; }
      }

      function changeLeft(sObject, iLeft, bAddLeft, iMaxScroll, iMinScroll) {
         if(!document.scrollTimeOut) { document.scrollTimeOut; }
         oObject = document.getElementById(sObject);
         
         iCurLeft = parseFloat(oObject.style.left); 
         if(bAddLeft) { iLeft = iCurLeft + iLeft; } //als bAddLeft true is, iCurLeft ophogen met iLeft
         
         //voorkom van het scherm af scrollen als iMaxScroll of iMinScroll is geset
         if(iLeft < iMinScroll) { iLeft = iMinScroll; }
         if(iLeft > iMaxScroll) { iLeft = iMaxScroll; }
         
         iSpeed = Math.abs((iCurLeft-iLeft)/5);
         if(iSpeed < 2) { iSpeed = 2; }
         
         clearTimeout(document.scrollTimeOut);
         if(iCurLeft != iLeft) { 
            if(iCurLeft < iLeft) { 
               if((iCurLeft + iSpeed) > iLeft) { iCurLeft += iLeft - iCurLeft; } //als de stap voorbij het target gaat: zorgen dat de stap zo groot is dat hij precies op het target komt.
               else {iCurLeft += iSpeed; } //stap kan genomen worden
            }
            else { 
               if((iCurLeft - iSpeed) < iLeft) { iCurLeft += iLeft - iCurLeft; } //als de stap voorbij het target gaat: zorgen dat de stap zo groot is dat hij precies op het target komt.
               else {iCurLeft -= iSpeed; } //stap kan genomen worden
            }
            //alert(iCurLeft);
            oObject.style.left = iCurLeft+"px";
            document.scrollTimeOut = setTimeout("changeLeft('"+sObject+"',"+iLeft+")",10);
         }
      }
      
      function empty(mixed_var) {  
         var key;  
         if (mixed_var === "" || mixed_var === 0 || mixed_var === "0" || mixed_var === null || mixed_var === false || mixed_var === undefined || mixed_var === " " || mixed_var === "  " || mixed_var === "  " || mixed_var === "  "){  
            return true;  
         }  
         if (typeof mixed_var == 'object') {  
            for (key in mixed_var) {  
               if (typeof mixed_var[key] !== 'function' ) { return false; }  
            }  
            return true;  
         }  
         return false;  
      }  
      
      function showImg(iTop, sPath, iWidth, iHeight, sName, sDescription) {
         if (document.images) {
            img = new Image(iWidth, iHeight); //voeg eerst de img toe aan de DOM anders is er de kans dat de afbeelding in IE niet helemaal geladen wordt.
            
            if(document.getElementById('slidePreviewPicture')) { //inpage foto, als foto nog niet geladen is
               document.body.style.cursor = "progress"; //laat progress-cursor zien
               oFotoDiv = document.getElementById('slidePreviewPicture');
               img.style.margin = iTop+"px auto";
               if(iHeight) img.style.height = iHeight+"px";
               if(iWidth) img.style.width = iWidth+"px";
            } else if(!document.getElementById('popupWindowEdit') || document.getElementById('popupWindowEdit').style.display == 'none') { //popup foto, als foto nog niet geladen is
               oFotoDiv = document.getElementById('popupWindowFotoImg');
               oFotoDiv.innerHTML = ''; //maak div leeg
               document.getElementById('ajaxFotoTitel').innerHTML = '<img src="img/loading.gif"> Bezig met laden...';
               document.getElementById('popupWindowFotoWindow').style.width = (parseFloat(iWidth)+10)+"px";
               toggleDiv('popupWindowFoto','visible');
            }
            
            img.onload = function() { //pas als hij geladen is, de img gebruiken.
               if(document.getElementById('slidePreviewPicture')) { //inpage foto
                  if(document.getElementById('ajaxFotoSlideTitelDesc')) { //als er een div is om foto titel/beschrijving in te zetten
                     if(!empty(sName)) { document.getElementById('ajaxFotoSlideTitel').innerHTML = sName; toggleDiv('ajaxFotoSlideTitelDesc','visible');} //geef naam weer
                     else { document.getElementById('ajaxFotoSlideTitel').innerHTML = "&nbsp;"; }
                     
                     if(!empty(sDescription)) { document.getElementById('ajaxFotoSlideDescription').innerHTML = sDescription; toggleDiv('ajaxFotoSlideTitelDesc','visible'); } //geef omschrijving weer.
                     else { document.getElementById('ajaxFotoSlideDescription').innerHTML = "&nbsp;"; }
                  }
                  
                  document.body.style.cursor = ""; //laat progress-cursor niet meer zien
                  
                  oFotoDiv.innerHTML = ''; //maak div leeg
                  oFotoDiv.appendChild(img); //zet foto in div
               } else if(!document.getElementById('popupWindowEdit') || document.getElementById('popupWindowEdit').style.display == 'none'){ //popup foto, maar niet als edit popup zichtbaar is...
                  if(sName) { document.getElementById('ajaxFotoTitel').innerHTML = sName; } //geef naam weer
                  else { document.getElementById('ajaxFotoTitel').innerHTML = "Afbeelding"; }
                  if(sDescription) { document.getElementById('ajaxFotoDescription').innerHTML = sDescription; } //geef omschrijving weer.
                  else { document.getElementById('ajaxFotoDescription').innerHTML = ""; }
                  
                  if(iWidth) document.getElementById('ajaxFotoDescription').style.width = iWidth+"px"; // Maak div van description net zo breed als de foto.
                  
                  oFotoDiv.appendChild(img); //zet foto in div
               }
            } //einde onload functie
            
            img.src = sPath; //laad de img.
         }
      }
      
      
      
      function toggleDiv(id,action) {
         if(action == "") {
            if(document.getElementById(id).style.display == "none")  { document.getElementById(id).style.display = ""; }
            else { document.getElementById(id).style.display = "none"; }
         }
         else if(action == 'hidden') { document.getElementById(id).style.display = "none"; }
         else { document.getElementById(id).style.display = ""; }
      }
      
      function toggleDiv(id,action) {
         if(action == "") {
            if(document.getElementById(id).style.display == "none")  { document.getElementById(id).style.display = ""; }
            else { document.getElementById(id).style.display = "none"; }
         }
         else if(action == 'hidden') { document.getElementById(id).style.display = "none"; }
         else { document.getElementById(id).style.display = ""; }
      }
      
      function createHTTPHandler(){
          httphandler = false;
          /*@cc_on @*/
          /*@if (@_jscript_version >= 5)
          // JScript gives us Conditional compilation, we can cope with old IE versions.
          // and security blocked creation of the objects.
          try {
            httphandler = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
            try {
             httphandler = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                httphandler = false;
            }
          }
          @end @*/
          if (!httphandler && typeof XMLHttpRequest!='undefined') {
              httphandler = new XMLHttpRequest();
          }
          return httphandler;
      }

      function ajax_form($form_id,$action,$status_div){//$responseReactionArray,
         xmlhttp_form = createHTTPHandler();
         form = document.getElementById($form_id);
         statusDiv = document.getElementById($status_div);
         bFileFieldPresent = false; //als er een besand geupload wordt, geen ajax gebruiken maar het form submitten naar een iframe. standaard: ajax
         
         function submit_value(value,disbling) { parseResult("disableForm('"+value+"',"+disbling+")",$form_id,$status_div); }
         
         function statusDiv(value) { parseResult('statusDiv.innerHTML="'+value+'"',$form_id,$status_div); }
        
         //get form element names en inhoud
         sElements = '';
         for($i = 0; $i < form.elements.length;$i++) {
            if($i != 0) {
               sElements += '&';
            }
            if(!((form.elements[$i].type == 'radio' && form.elements[$i].checked == false) || (form.elements[$i].type == 'checkbox' && form.elements[$i].checked == false))) {
               sElements += form.elements[$i].name +'='+ encodeURIComponent(form.elements[$i].value);
            }
         }
         
         //set method en .open parameter
         if(form.method == 'post') {xmlhttp_form.open('POST', $action, true); }
         else {xmlhttp_form.open('GET', $action +'?'+sElements, true);}
        
         //zorg voor afhandeling
         xmlhttp_form.onreadystatechange = function() {
            if(xmlhttp_form.readyState==4 && xmlhttp_form.status == 200) {
               submit_value('Verzenden',false);
               parseResult(xmlhttp_form.responseText,$form_id,$status_div);
               
               if(document.autoSaveTimeOut) {
                  clearTimeout(document.autoSaveTimeOut);
                  document.autoSaveTimeOut = setTimeout(document.sgAutoSaveFunction,document.igAutoSaveFormTime);
               }
            }
            else if(xmlhttp_form.readyState==4) {
               submit_value('Verzenden',false);
               statusDiv.innerHTML ='Error: '+xmlhttp_form.status;
            }
            else {
               submit_value('Bezig...',true);
               statusDiv.innerHTML = "<img src=\"img/loading.gif\"> Bezig...";
            }
         }
        
         //set headers
         xmlhttp_form.setRequestHeader('Cache-Control', 'no-cache');
         xmlhttp_form.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         xmlhttp_form.setRequestHeader('Connection', 'close');
        
         //send
         if(form.method == 'post') {xmlhttp_form.send(sElements); }
         else {xmlhttp_form.send(null);}
      }

      function parseResult(sJsFunction,sFormId,sStatusDiv) { //functie voor het weergeven van foute velden, veranderen van de form tijdens het verzenden ed.
         form = document.getElementById(sFormId);
         statusDiv = document.getElementById(sStatusDiv);
         //alert(sJsFunction);
         
         //maak functie die submit button kan veranderen
         function disableForm(value,disabling) {
            for($i = 0; $i < form.elements.length;$i++) {
              if(form.elements[$i].type == 'submit') { form.elements[$i].value = value; }
              form.elements[$i].disabled = disabling;
            }
         }
         
         //functie die velden rood maakt als deze fout zijn ingevuld
         function showWrongFields(sFields) {
            aFields = new Array();
            aFields = sFields.split(',');
            for($i = 0; $i < form.elements.length;$i++) {
               if(inArray(form.elements[$i].name,aFields)) { 
                  form.elements[$i].style.border = "1px solid #5D000D"; 
                  form.elements[$i].parentNode.parentNode.firstChild.style.color = "#972786"; 
                  //form.elements[$i].parentNode.parentNode.firstChild.style.font-weight = "bold"; 
               }
               else if(form.elements[$i].type != 'submit') { //IE fix, anders veranderd button
                  form.elements[$i].style.borderColor = ""; //IE fix
                  form.elements[$i].style.borderWidth = ""; //IE fix
                  form.elements[$i].style.borderStyle = ""; //IE fix
                  form.elements[$i].parentNode.parentNode.style.color = "";
                  //form.elements[$i].parentNode.parentNode.firstChild.style.font-weight = "normal"; 
               } 
            }
         }
         
         function inArray(needle, haystack) {
            for(key in haystack) {
               if(haystack[key].toLowerCase() == needle.toLowerCase()) { return true; }
            }
            return false;
         }
         
         eval(sJsFunction);
      }
      
      
function createHTTPHandler(){
    httphandler = false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
    try {
      httphandler = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
       httphandler = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
          httphandler = false;
      }
    }
    @end @*/
    if (!httphandler && typeof XMLHttpRequest!='undefined') {
        httphandler = new XMLHttpRequest();
    }
    return httphandler;
}


function toggleDiv(id,action) {
   if(action == "") {
      if(document.getElementById(id).style.display == "none")  { 
         document.getElementById(id).style.display = "";
      }
      else { 
         document.getElementById(id).style.display = "none";
      }
   }
   else if(action == 'hidden') {
      document.getElementById(id).style.display = "none";
   }
   else {
      document.getElementById(id).style.display = "";
   }
}

