function a(l,d,c) {
  try {r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}
  if(r){
    r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){c(r.responseText);}}
    r.open('GET', l+'?'+d, true);r.send(d);
  }
}

function showFoto(id, path) {
  var pi = document.getElementById("pi");
  pi.onload = onScroll;
  var photo_text = document.getElementById("photo_text");
  var o = document.getElementById("overlay");
  var o2 = document.getElementById("overlay_background");

  var p = getPageSize();
  photo_text.innerHTML = "<a href=\"#\" style=\"color:#000000;\" onclick=\"event.cancelBubble = true;showFoto("+id+","+(parseInt(path)-1)+",''); return false;\">&lt; Vorige</a>&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"event.cancelBubble = true; closeFoto(); return false;\">Terug naar fotoboek</a>&nbsp;<a href=\"#\" style=\"color:#000000;\" onclick=\"event.cancelBubble = true;showFoto("+id+","+(parseInt(path)+1)+",''); return false;\">Volgende &gt;</a>";
  a("/photo.asp","id="+id+"&i="+path, function(d) { pi.src = "http://content.cmsbasic.nl/thumbs.ashx?src=sites/179/uploads/"+d+"&w=640&h=400";} ) 
  
  o.style.width  = o2.style.width  = p[0];
  o.style.height = o2.style.height = p[1];
  
  var s = document.getElementsByTagName("SELECT");
  for (var i=0; i < s.length; i++) {
    s[i].style.visibility = "hidden";
  }
  o.style.display = "block";
  
  //pi.src = src;
}

function onScroll() {
  var o = document.getElementById("overlay");
  if (o.style.display != "none") {
    var b = document.getElementById("overlay_block");
    var p = getPageSize();
    
    var pi = document.getElementById("pi");
    b.style.width = pi.width + 10;
    b.style.top  = document.body.scrollTop + (p[3] / 2) - (b.offsetHeight / 2);
    b.style.left = document.body.scrollLeft + (p[2] / 2) - (b.offsetWidth / 2);    
  }
}

function closeFoto() {
  var s = document.getElementsByTagName("SELECT");
  for (var i=0; i < s.length; i++) {
    s[i].style.visibility = "visible";
  }

  var o = document.getElementById("overlay");
  o.style.display = "none";
}

function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
  		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;		
	}

	arrayPageSize = new Array(pageWidth - 17,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function doNessecary ()
{
	sizeTable();
}

function sizeTable ()
{
	var t = document.getElementById('contentTable');
	var c = document.getElementById('content');
	
	middenHeight 	= 134;
	contentHeight = c.offsetHeight;
	
	if (contentHeight < 500)
		contentHeight = 500;
	
	aantal 				= Math.ceil((contentHeight/middenHeight));
	
	newHeight 		= (middenHeight*aantal);
	
	//Pas de nieuwe hoogte toe op het element
	t.style.height = newHeight;
}

window.onload = doNessecary;




/* OLD STUFF ---------------------------------------
////////////////////////////////////////////////////
----------------------------------------------------

/*sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
  
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);*/

/*
//Get the pageSize
function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight) { 
		// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else { 
		// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	
		// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) { 
		// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) { 
		// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
		pageHeight = windowHeight;
	else 
		pageHeight = yScroll;

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
		pageWidth = windowWidth;
	else
		pageWidth = xScroll;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function doNessecary ()
{
	sizeContentImages();
}

function sizeContentImages ()
{
	var s = getPageSize();
	
	document.getElementById('content').style.height 	= s[1]-150;
	document.getElementById('omlijning').style.height = s[1]-150;
}

window.onload = doNessecary;
*/
