function changeImpression(s, sLarge) {
  document.getElementById('impression').style.backgroundImage = 'url("'+s+'")';
  document.getElementById('impression').style.backgroundRepeat = 'no-repeat';
  currentLargeImage = sLarge;
}

function cleanUp(s, str) {
  str = (str.replace(new RegExp(/,/g), ", "))
  if (document.getElementById(s)) document.getElementById(s).innerHTML = str;
}

function enable_output_escaping()
{
   if (!ie)
   {
      var fieldsToCheck = new Array('description', 'details_description');
      for(var i = 0; i < fieldsToCheck.length; i++)
      {
         try
         {
            var htmlToDecode = document.getElementById(fieldsToCheck[i]).innerHTML;
            htmlToDecode = htmlDecode(htmlToDecode);
            document.getElementById(fieldsToCheck[i]).innerHTML = htmlToDecode;
         }
         catch(e)
         {}
      }
   }
}

function htmlDecode(htmlToDecode)
{
   htmlToDecode = htmlToDecode.replace(/&lt;/g, '<');
   htmlToDecode = htmlToDecode.replace(/&gt;/g, '>');
   htmlToDecode = htmlToDecode.replace(/&amp;/g, '&');
   return htmlToDecode;
}

function zoom(io) {
  document.getElementById('zoom').className ='zoom '+io;
}

function getWindowWidth() {
  var x,y;
  if (self.innerHeight) // all except Explorer
  {
    x = self.innerWidth;
    y = self.innerHeight;
  }

  else if (document.documentElement && document.documentElement.clientHeight)
  // IE in strict mode
  {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
  } else if (document.body) // all other IE's
  {
    x = document.body.clientWidth;
    y = document.body.clientHeight;
  }

  return x;
}

var popupDiv;
var popupDivLoading;
var image;

function imgLarge() {
  var popupDivImage = document.createElement("div");
  popupDivImage.className = 'popupDivImage';
  popupDivImage.innerHTML =
     '<img id="image" src="' + currentLargeImage + '" alt="Impressie"/>';

  popupDiv.style.display = 'none';

  popupDiv.removeChild(popupDivLoading);
  popupDiv.appendChild(popupDivImage);

  divLeft = (getWindowWidth() - image.width) / 2;
  divLeft = divLeft < 10 ? 10 : divLeft;

  popupDiv.style.left = divLeft + 'px';
  popupDiv.style.width = image.width + 'px';
  popupDiv.style.height = (image.height + 31) + 'px';

  popupDivImage.style.width = image.width + 'px';
  popupDivImage.style.height = image.height + 'px';
  popupDivImage.style.width = image.width + 'px';
  popupDivImage.style.height = image.height + 'px';

  popupDiv.style.display = 'block';
}

function showLarge() {
  popupDiv = document.createElement("div");
  popupDiv.className = 'popupDiv';
  popupDiv.setAttribute('id', 'popupDiv');

  var popupDivHeader = document.createElement("div");
  popupDivHeader.className = 'popupDivHeader';
  popupDivHeader.innerHTML =
  '<a href="javascript:hideLarge()" title="deze popup sluiten">deze popup sluiten</a>';

  popupDivLoading = document.createElement("div");
  popupDivLoading.className = 'popupDivLoading';
  popupDivLoading.innerHTML =
    '<div style="margin-top: 100px; font-size: 10px;">even geduld a.u.b.<br/><br/>' +
    '<img id="image" src="//gfx/ajax-loader.gif" alt="Impressie"/></div>';

  popupDiv.appendChild(popupDivHeader);
  popupDiv.appendChild(popupDivLoading);

  var body = document.getElementsByTagName("body")[0];
  body.appendChild(popupDiv);

  var divLeft = (getWindowWidth() - 600) / 2;
  divLeft = divLeft < 10 ? 10 : divLeft;

  popupDiv.style.left = divLeft + 'px';
  popupDiv.style.display = 'block';

  image = new Image();
  image.src = currentLargeImage;

   // <!-- IE7 HACK -->
  // onload will not work if image is already loaded (complete)
  if (image.complete)
  {
     imgLarge();
  }
  else
  {
     image.onload = function()
     {
        imgLarge();
     }
   }
  // <!-- END IE7 HACK -->
}

function hideLarge() {
   var popupDiv = document.getElementById('popupDiv');
   var body = document.getElementsByTagName("body")[0];

   body.removeChild(popupDiv);
}

function showPopup(url) {
   window.open(url, '', 'left=20,top=20,width=800,height=600,toolbar=0, scrollbars=1, resizable=1');
}

var prev_info = '';

function showInfo(info) {
  if (prev_info != '') {
    document.getElementById(prev_info).style.display = 'none';
  }
  document.getElementById(info).style.display = 'inline';
  prev_info = info;
}

function hideInfo(s) {
  document.getElementById(s).style.display = 'none';
}

function showCriteriaPrev() {
  if (document.getElementById('column0').style.display && document.getElementById('column0').style.display == 'block') {
    document.getElementById('column0').style.display = 'none';
    document.getElementById('toonknop').innerHTML = '<span>Toon zoekcriteria</span>';
  } else {
    document.getElementById('column0').style.display = 'block';
    document.getElementById('toonknop').innerHTML = '<span>Verberg zoekcriteria</span>';
  }
}

function showCriteria() {
  if (document.getElementById('searchcriteria_long').style.display && document.getElementById('searchcriteria_long').style.display == 'block') {
    document.getElementById('searchcriteria_long').style.display = 'none';
    document.getElementById('scl_toonknop').innerHTML = 'Toon zoekcriteria';
  } else {
    document.getElementById('searchcriteria_long').style.display = 'block';
    document.getElementById('scl_toonknop').innerHTML = 'Verberg zoekcriteria';
  }
}




/* Deze functies worden gebruikt omdat je geen target=blank meer mag gebruiken */
try {
  document.addEventListener('click', handleClick, false);
  } catch(e) {
  if (document.attachEvent) {
	  document.attachEvent('onclick', handleClick);
  } else {
	  document.onclick = handleClick;
  }
}

function handleClick(e) {
  var event = e || window.event;
  if(event.ctrlKey || event.shiftKey || event.altKey) return true;
  if(event.which && event.which != 1) return true;

  var target = event.target || event.srcElement;
  while(target && !/^a$/i.test(target.nodeName)) {
	  target = target.parentNode;
}

if(!target || !target.getAttribute('rel')) return true;

  var rel = target.getAttribute('rel');
  var href = target.getAttribute('href');
  var id = target.getAttribute('id');
  switch(rel) {
  case 'privacyverklaring':
	 window.open(href, '', 'width=800,height=600,resizable=1, scrollbars=1');
	 break;
  case 'external':
	 window.open(href);
	 break;
  case 'selectmap':
   document.getElementById('mapImage').src = href;
   document.getElementById(id).className = 'mapChoiceOptionBold';
	 break;
  default:
	 return true;
  }
  try { event.preventDefault(); } catch(e){}
  return false;
}