//©2008, B. Hordijk, Midhold bv, the Netherlands.
var ie6=(navigator.appName&&navigator.appName=="Microsoft Internet Explorer"&&navigator.appVersion&&navigator.appVersion.indexOf("MSIE 6.")>=0)?true:false;
function hide_ctrls(){
  var inputs=document.getElementsByTagName('select');
  for(var i=0;i<inputs.length;i++)inputs[i].style.display = 'none';
}
function show_ctrls(){
  var inputs=document.getElementsByTagName('select');
  for(var i=0;i<inputs.length;i++)inputs[i].style.display = 'inline';
}
function page_size(){
  var pw=ph=0;
  pw=(document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth; 
  ph=(document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
  return{w:pw,h:ph};
}
function client_size(){
  var cw=ch=0;
  if (document.documentElement && document.documentElement.clientWidth){
      cw = document.documentElement.clientWidth;
      ch = document.documentElement.clientHeight;
  }
  else if (self.innerWidth){
      cw = self.innerWidth;
      ch = self.innerHeight;
  }
  else if (document.body){
      cw = document.body.clientWidth;
      ch = document.body.clientHeight;
  }
  return{w:cw, h:ch};
}
function scroll_left(){
  var xScroll = 0;
  if (self.pageXOffset) xScroll = self.pageXOffset;
  else if (document.documentElement && document.documentElement.scrollLeft) xScroll = document.documentElement.scrollLeft; 
  else if (document.body) xScroll = document.body.scrollLeft;
  return xScroll;
}
function scroll_top(){
  var yScroll = 0;
  if(self.pageYOffset) yScroll = self.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop; 
  else if (document.body) yScroll = document.body.scrollTop; 
  return yScroll; 
}
function check_overlay(){if(document.getElementById('infolayer')==null)insert_overlay();}
function insert_overlay(){
  try{
    var b=document.body;
    var g=document.createElement('div');
    g.id='greylayer';
    g.onclick = function(){hide_overlay();}
    g.title="Klik om de bovenste laag te sluiten";
    if(document.getElementById('greylayer')==null)b.appendChild(g);
    var c=document.createElement('div');
    c.id='overclose';
    var p=document.createElement('span');
    p.className='pseudolink'
    p.title="Sluit deze laag";
    p.onclick = function(){hide_overlay();}
    p.innerHTML="X (sluiten)";
    c.appendChild(p);
    var ih=document.createElement('div');
    ih.id='overholder';
    var i=document.createElement('div');
    i.id='overlayer';
    i.title="OverLayer (C)2008";
    i.appendChild(c);
    i.appendChild(ih);
    if(document.getElementById('overlayer')==null)b.appendChild(i);
  }catch(e){}
}
function overlay_pic(a){
	var url=""+a.href;
	if(url==""){return;}
	else{
	  check_overlay();
	  try{
		  document.getElementById('overholder').innerHTML="<img id='overcontent' src='"+url+"' width='500' onclick='javascript:hide_overlay();' alt='klik om te sluiten'></iframe>";
      var b=document.getElementById('greylayer');
	    var d=page_size();
	    b.style.width=d.w+"px";
	    b.style.height=d.h+"px";
      b.style.display = 'block';
      var i = document.getElementById('overlayer');
      var s = client_size();
      if(ie6){
        i.style.top=parseInt( ( (s.h-500)/2 )+ scroll_top())+"px";
        i.style.left=parseInt( ( (s.w-500)/2 )+ scroll_left())+"px";
        hide_ctrls();
      }else{
        i.style.top=parseInt( (s.h-500)/2  )+"px";
        i.style.left=parseInt( ( s.w-500)/2 )+"px";
      }
		  i.style.display = 'block';
		  window.onresize=relocate_overlay;
		}catch(e){return true;}
	}
	return false;
}
function overlay_pop(a, w, h){
	var url=""+a.href;
	if(url==""){return;}
	else{
	  check_overlay();
	  try{
		  //document.getElementById('overholder').innerHTML="<iframe id='overcontent' src='"+url+"' frameborder='0' width='"+w+"' height='"+h+"' scrolling='auto' allowtransparency='true'></iframe>";
			document.getElementById('overholder').innerHTML="<iframe id='overcontent' src='"+url+"' frameborder='0' width='"+w+"' height='"+h+"' scrolling='no' allowtransparency='true'></iframe>";
      var b=document.getElementById('greylayer');
	    var d=page_size();
	    b.style.width=d.w+"px";
	    b.style.height=d.h+"px";
      b.style.display = 'block';
      var i = document.getElementById('overlayer');
      var s = client_size();
      if(ie6){
        i.style.top=parseInt( ( (s.h-h)/2 )+ scroll_top())+"px";
        i.style.left=parseInt( ( (s.w-w)/2 )+ scroll_left())+"px";
        hide_ctrls();
      }else{
        i.style.top=parseInt( (s.h-h)/2  )+"px";
        i.style.left=parseInt( ( s.w-w)/2 )+"px";
      }
		  i.style.display = 'block';
		  window.onresize=relocate_overlay;
		}catch(e){return true;}
	}
	return false;
}
function relocate_overlay(){
	//try{
  var b=document.getElementById('greylayer');
  var d=page_size();
  b.style.width=d.w+"px";
  b.style.height=d.h+"px";
  var i = document.getElementById('overlayer');
  var s = client_size();
  var content=document.getElementById('overcontent');
  var ih=parseInt( content.height );
  var iw=parseInt( content.width );
  if(ie6){
    i.style.top=parseInt( ( (s.h-ih)/2 )+ scroll_top())+"px";
    i.style.left=parseInt( ( (s.w-iw)/2 )+ scroll_left())+"px";
  }else{
    i.style.top=parseInt( (s.h-ih)/2  )+"px";
    i.style.left=parseInt( ( s.w-iw)/2 )+"px";
  }
	//}catch(e){}
}
function hide_overlay(){
	document.getElementById('overlayer').style.display = 'none';
	document.getElementById('greylayer').style.display = 'none';
	window.onresize=function(){};
	if(ie6)show_ctrls();
}

/*backwards compatible*/
function infopic(a){
	overlay_pic(a);
}
function infopop(a, w, h){
	overlay_pop(a,w,h);
}