window.onload = init;

function init () {
	var x = document.getElementsByTagName ('a');
	var n = x.length;
	
	for (i = 0; i < n; i++) {
		if (x[i].className == 'popup') {
			x[i].onclick = function () {
				return open_picture_win (this);
			}
		}
	}
}

var picture_window;

function open_picture_win (obj) {
	var title = "Klik op de foto om het venster te sluiten"
	var htmlString;
	var settings;
	var left;
	var top;

	var width, height;
	width = (obj.getAttribute('popup_w')) ? (obj.getAttribute('popup_w')) : (1024);
	height = (obj.getAttribute('popup_h')) ? (obj.getAttribute('popup_h')) : (768);

	htmlString = '<html><head><title>' + title + '<\/title>';
	htmlString += "<style>* {border: 0; margin: 0; padding: 0;} body {background-color: black; overflow: hidden; }<\/style><\/head><body style=\"cursor: pointer\" leftmargin=\"0\" topmargin=\"0\" bgcolor=\"#555555\">";
	htmlString += "<img width=\"100%\" height=\"100%\" title=\"Klik om te sluiten\" onclick=\"window.close()\" src=\"";
	htmlString += obj.href;
	htmlString += "\"><\/body><\/html>";
	left = (screen.availWidth - width) / 2;
	top = (screen.availHeight - height) / 2;
	settings = '"toolbar=no, scrollbars=no, left=' + left + ',top=' + top + ',width=' + width + ', height=' + height + '"';

	if (picture_window && !picture_window.closed) {
		picture_window.close();
	}

	picture_window = window.open ('', '', settings);
	picture_window.document.write (htmlString);
	picture_window.focus();
	picture_window.document.close ();
	
	return false;
}
