function start() {
 if ($('f-spam')) {
  $('f-spam').value = $('f-spam').getAttribute('title');
 };
 if ($('dd-spam')) {
  $('dd-spam').style.display = 'none';
 };
 if (document.createElement) {
  fixPopups();
  fixSubmits();
 };
}

function $(s) {
 return document.getElementById(s);
}

function fixSubmits() {
 if (document.getElementsByTagName('input').length > 0) {
  for (var i = 0, inps = document.getElementsByTagName('input'); i < inps.length; i++) {
   if (inps[i].getAttribute('type') == 'submit') {
    var t = inps[i].value;
    inps[i].style.display = 'none';
    inps[i].id = 'click-me';
    var a = document.createElement('a');
    a.href = '#';
    a.onclick = function() {
     $('click-me').click();
     return false;
    };
    a.className = 'js-submit ' + t.toLowerCase();
    var em = document.createElement('em');
    em.appendChild(document.createTextNode(t));
    a.appendChild(em);
    inps[i].parentNode.appendChild(a);
   };
  };
 };
}

function fixPopups() {
 var divs = $('content').getElementsByTagName('div');
 for (var i = 0, l = divs.length; i < l; i++) {
  if (divs[i].className.indexOf('popup') != -1 && divs[i].getElementsByTagName('a').length == 1) {
   var link = divs[i].getElementsByTagName('a')[0];
   link.setAttribute('title', 'Klik voor een vergroting');
   link.onclick = function() {
    var file = this.getAttribute('href');
    var img = document.createElement('img');
    img.setAttribute('src', file);
    img.setAttribute('alt', '');
    var div = document.createElement('div');
    div.setAttribute('title', 'Klik om te sluiten');
    div.onclick = function() {
     var next = this.nextSibling;
     while (next.nodeType != 1) {
      next = next.nextSibling;
     };
     next.style.display = 'block';
     this.parentNode.removeChild(this);
    };
    div.className = 'popped';
    div.appendChild(img);
    this.parentNode.style.display = 'none';
    this.parentNode.parentNode.insertBefore(div, this.parentNode);
    return false;
   };
  };
 };
}

// Dean Edwards/Matthias Miller/John Resig
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) clearInterval(_timer);
	if (document.getElementById) {
	 start();
	};
};
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
};
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init();
		}
	};
/*@end @*/
if (/WebKit/i.test(navigator.userAgent)) {
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init();
		};
	}, 10);
};
window.onload = init;