var DOMsupport = document.getElementsByTagName;
var popped = false;
if (DOMsupport) {
 window.onload = function() {
  var tables = document.getElementsByTagName('table');
  for (var i = 0; i < tables.length; i++) {
   var trs = tables[i].getElementsByTagName('tr');
   for (var j = 1; j < trs.length; j+=2) {
    trs[j].className = 'rij';
   }
  }
  var as = document.getElementsByTagName('a');
  for (var i = 0; i < as.length; i++) {
   if (as[i].getAttribute('rel') && as[i].getAttribute('rel').indexOf('external') != -1) {
    as[i].setAttribute('target', '_blank');
    as[i].className = 'external';
   }
  }
  var fotos;
  if (fotos = document.getElementById('fotos')) {
   var imgs = fotos.getElementsByTagName('img');
   for (var i = 0; i < imgs.length; i++) {
    AddClass(imgs[i], 'popup');
    //imgs[i].className = 'popup';
    imgs[i].setAttribute('title', 'Vergroten');
    imgs[i].onmouseover = function() {
     AddClass(this, 'hover');
     //this.className = 'popup hover';
    }
    imgs[i].onmouseout = function() {
     KillClass(this, 'hover');
     //this.className = 'popup';
    }
    imgs[i].onclick = function() {
     createImage(this);
    }
   }
  }
  if (document.getElementById('zoekformulier')) {
   var s = document.getElementById('s');
   s.onfocus = function() {
    if (this.value == 'zoekterm') {
     this.value = '';
    }
   }
   s.onblur = function() {
    if (this.value == '') {
     this.value = 'zoekterm';
    }
   }
   var zoek = document.getElementById('zoekformulier');
   zoek.onsubmit = function() {
    var zoektekst = s.value.replace(/ /g, '+');
    if (zoektekst == '') {
     zoektekst = 'trefpunt';
    }
    location.href = 'http://tweedetrefpunt.nl/algemeen/nieuws/zoeken/' + zoektekst;
    return false;
   }
  }
  if (document.getElementById('spammer')) {
   document.getElementById('spammer').value = 'nee';
   document.getElementById('spam-dt').style.display = 'none';
   document.getElementById('spam-dd').style.display = 'none';
   if (document.getElementById('spam-help')) {
    document.getElementById('spam-help').style.display = 'none';
   }
  }
 }
}

function createImage(element) {
 var strSource = element.src.replace('/klein/', '/groot/')
 if (document.createElement) {
  if (popped) {
   var pop = document.getElementById('pop');
   pop.parentNode.removeChild(pop);
  }
  popped = true;
  var nImg = document.createElement('img');
  nImg.setAttribute('src', strSource);
  nImg.setAttribute('title', 'Sluiten');
  if (HasClass(element, 'verticaal')) {
   nImg.className = 'popped popped-verticaal';
  } else {
   nImg.className = 'popped';
  }
  nImg.setAttribute('id', 'pop');
  nImg.onclick = function() {
   popped = false;
   this.parentNode.removeChild(this);
   document.getElementById('fotos').className = '';
  }
  /* PPK is liev */
  var pos;
  if (window.innerHeight) {
   pos = window.pageYOffset
  } else if (document.documentElement && document.documentElement.scrollTop) {
   pos = document.documentElement.scrollTop
  } else if (document.body) {
   pos = document.body.scrollTop
  }
  if (pos < 330) {
   pos = 330;
  } else {
   pos += 50;
  }
  /* Thanks :) */
  nImg.style.top = pos + 'px';
  document.body.appendChild(nImg);
  document.getElementById('fotos').className = 'doorzichtig';
 }
}


//*** This code is copyright 2002-2003 by Gavin Kistner and Refinery; www.refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)

//***Adds a new class to an object, preserving existing classes
function AddClass(obj, cName) {
 KillClass(obj,cName);
 return obj && (obj.className+=(obj.className.length>0?' ':'')+cName);
}

//***Removes a particular class from an object, preserving other existing classes.
function KillClass(obj, cName) {
 return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''));
}

//***Returns true if the object has the class assigned, false otherwise.
function HasClass(obj, cName) {
 return (!obj || !obj.className) ? false : (new RegExp("\\b"+cName+"\\b")).test(obj.className);
}