// JavaScript Document voor Div-popup


function GetElement(n)
{
	if(document.getElementById){
		return document.getElementById(n);
	} else if (document.all) {
		return document.all[n];
	} else if (document.layers) {
		return document.layers[n];
	}	
}

function HideContent(d) { 
	if(d.length < 1) 
	{ 
		return; 
	} 
	GetElement(d).style.display = "none"; 
} 

function ShowImgs(overlayElement, overlayImageElement, initialImg, imageRootName, imageNumber, imageExtension, numberOfImages)
{
	ShowContent(overlayElement);
	
	var image = GetElement(initialImg);
	var prevImage = GetElement('prev_img');
	var nextImage = GetElement('next_img');
	var nextImgHref = GetElement('next_img_href');
	var v_style = GetElement(overlayImageElement).style;
	
	var popupheight = 0;
	var schermhoogte = 0;
	if(typeof window.innerHeight != 'undefined') {
		popupheight = window.innerHeight;
	} 
	else {
		popupheight = document.documentElement.clientHeight;
	}
	if((popupheight > document.body.parentNode.scrollHeight) && (popupheight > document.body.parentNode.clientHeight)) {
		schermhoogte = popupheight;
	} 
	else {
		if(document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			schermhoogte = document.body.parentNode.clientHeight;
		} 
		else {
			schermhoogte = document.body.parentNode.scrollHeight;
		}
	}
	var popupwidth = 0;
	var schermbreedte = 0;
	if(typeof window.innerWidth != 'undefined') {
		popupwidth = window.innerWidth;
	} 
	else {
		popupwidth = document.documentElement.clientWidth;
	}
	if((popupwidth > document.body.parentNode.scrollWidth) && (popupwidth > document.body.parentNode.clientWidth)) {
		schermbreedte = popupwidth;
	} 
	else {
		if(document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			schermbreedte = document.body.parentNode.clientWidth;
		} 
		else {
			schermbreedte = document.body.parentNode.scrollWidth;
		}
	}

	
	var screen_width = 0;
	var screen_height = 0;
	screen_height = parseInt((schermhoogte-400)/2);
	v_style.top = screen_height + 'px';
	screen_width = parseInt((schermbreedte-1000)/2);
	v_style.left = screen_width + 'px';
	image.src = imageRootName + imageNumber + '.' + imageExtension;

	var imgNr = parseInt(imageNumber);
    if(imgNr > 1) {
		prevImage.src = imageRootName + (imgNr-1) + '.' + imageExtension;
	}
	else {
		prevImage.src = imageRootName + numberOfImages + '.' + imageExtension;
	}
	if(imgNr < numberOfImages) {
		nextImage.src = imageRootName + (imgNr+1) + '.' + imageExtension;
		nextImgHref.href = 'javascript:ShowImgs(' + overlayElement + ',' + overlayImageElement + ',' + initialImg + ',' + imageRootName, + ',' + (imgNr+1) + ',' + imageExtension + ',' + numberOfImages +')';
	}
	else {
		nextImage.src = imageRootName + '1' + '.' + imageExtension;
	}
}

function ShowContent(d) { 
	if(d.length < 1) 
	{ 
		return; 
	} 
	var v_style = GetElement(d).style;
	v_style.display = "block"; 
	
} 
function ReverseContentDisplay(d) { 
	if(d.length < 1) 
	{ 
		return; 
	} 
	if(GetElement(d).style.display == "none") 
	{ 
		GetElement(d).style.display = "block"; 
	} 
	else 
	{ 
		GetElement(d).style.display = "none"; 
	} 
} 
 

