function cImgPopup() {
	var _self = this;
	var blnOpen = false;

	this.dragStart = function(e) {
		dragStart(e, "divImgPopup");
	}

	this.openDHTML = function(img, strSrc, intWidth, intHeight) {
		var frmPopup = document.getElementById("divImgPopup");
		
		// Maak popup voor de eerste keer
		if (!frmPopup) {
			var frmPopup = document.createElement("div");
			frmPopup.className = "imgPopup";
			frmPopup.id = "divImgPopup";
			frmPopup.style.display = "none";
			
			var divImgPopupHeader = document.createElement("div");
			divImgPopupHeader.className = "imgPopupHeader";
			divImgPopupHeader.id = "divImgPopupHeader";
			divImgPopupHeader.onmousedown = objImgPopup.dragStart;
			frmPopup.appendChild(divImgPopupHeader);
			
			var aSluiten = document.createElement("a");
			aSluiten.onclick = objImgPopup.sluitDHTML;
			aSluiten.className = "sluiten";
			aSluiten.innerHTML = "x";
			divImgPopupHeader.appendChild(aSluiten);
			
			var spanImgPopupHeader = document.createElement("span");
			spanImgPopupHeader.id = "spanImgPopupHeader";
			divImgPopupHeader.appendChild(spanImgPopupHeader);
			
			var imgPopupImg = document.createElement("img");
			imgPopupImg.id = "imgPopupImg";
			imgPopupImg.alt = "Klik om te sluiten";
			imgPopupImg.title = "Klik om te sluiten";
			imgPopupImg.onclick = objImgPopup.sluitDHTML;
			frmPopup.appendChild(imgPopupImg);
			
			document.body.appendChild(frmPopup);
		}
		
		var imgPopupImg = document.getElementById("imgPopupImg");
		var divHeader = document.getElementById("divImgPopupHeader");
		var spanHeader = document.getElementById("spanImgPopupHeader");
		intWidth = parseInt(intWidth);
		intHeight = parseInt(intHeight);
		
		// Controleer of afbeelding is gewijzigd
		var blnAndereAfbeelding = (imgPopupImg.src != strSrc);
		
		if (!blnAndereAfbeelding) return false;
		
		// Reset src ter voorkoming van flikkering (werkt nog steeds niet in IE)
		imgPopupImg.src = "";
		
		// Sluit popup, opnieuw opbouwen
		frmPopup.style.display = "none";
		
		divHeader.style.width = (intWidth + 2) + "px"; 
		imgPopupImg.width = intWidth;
		imgPopupImg.height = intHeight;
		
		if (self.innerWidth) { // all except Explorer
	        var intWindowWidth = self.innerWidth;
			var intWindowHeight = self.innerHeight;
		}
	   else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			var intWindowWidth = document.documentElement.clientWidth;
			var intWindowHeight = document.documentElement.clientHeight;
		}
		else if (document.body) { // other Explorers
			var intWindowWidth = document.body.clientWidth;
			var intWindowHeight = document.body.clientHeight;
		}
		
		//var intScrollY = (self.pageYOffset) ? self.pageYOffset : document.body.scrollTop;

		if (self.pageYOffset) // all except Explorer
			var intScrollY = self.pageYOffset;
		else if (document.documentElement && document.documentElement.scrollTop)// Explorer 6 Strict
			var intScrollY = document.documentElement.scrollTop;
		else if (document.body) // all other Explorers
			var intScrollY = document.body.scrollTop;
			
		// Bepaal gecentreerde positie van popup
		var intLeft = (intWindowWidth / 2) - (intWidth / 2);
		var intTop = ((intWindowHeight / 2) - (intHeight / 2)) + intScrollY;
		
		// Zou het buiten beeld vallen?
		if (intLeft < 0) intLeft = 0;
		if (intTop < 0) intTop = 0;
		
		// Centreer popup
		frmPopup.style.left = intLeft + "px";
		frmPopup.style.top = intTop + "px";
		
		// Wijzig titelnaam
		var intPos = strSrc.lastIndexOf("/");
		var strBestandsnaam = strSrc.substr(intPos + 1);
		var strExtra = ""; //"(" + intScrollY + " | " + intWindowWidth + "x" + intWindowHeight + " | " + intWidth + "x" + intHeight + " | " + intLeft + "x" + intTop + ") ";
		spanHeader.innerHTML = strExtra + strBestandsnaam;
		
		// Wijzig afbeelding
		imgPopupImg.src = strSrc;
		
		_self.open = true;
		
		// Open popup
		_self.setOpacity(frmPopup, 0);
		frmPopup.style.display = "block";
		_self.fadeIn("divImgPopup", 0);	
	}

	this.sluitDHTML = function() {
		_self.fadeOut("divImgPopup", 99.999);
		//document.getElementById("divImgPopup").style.display = "none";
		//document.getElementById("imgPopupImg").src = "";
	}
	
	this.setOpacity = function(obj, opacity) {
		opacity = (opacity == 100) ? 99.999 : opacity;
	  	
		// IE/Win
		obj.style.filter = "alpha(opacity:" + opacity + ")";
	  
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity / 100;
	  
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity / 100;
	  
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity / 100;
	}
	
	this.fadeIn = function(objID, opacity) {
		var obj = document.getElementById(objID);
		if (opacity <= 100) {		
			_self.setOpacity(obj, opacity);
			opacity += 30;
			window.setTimeout("objImgPopup.fadeIn('" + objID + "'," + opacity+")", 10);
		}
		else
			_self.setOpacity(obj, 99.999);
	}
	
	this.fadeOut = function(objID, opacity) {
		var obj = document.getElementById(objID);
		if (opacity >= 0) {
			_self.setOpacity(obj, opacity);
			opacity -= 40;
			window.setTimeout("objImgPopup.fadeOut('" + objID + "'," + opacity+")", 10);
		}
		else {
			_self.setOpacity(obj, 0);
			obj.style.display = "none";
			document.getElementById("imgPopupImg").src = "";
			_self.open = false;
		}
	}
	
	this.dragStart = function(event) {
		dragStart(event, "divImgPopup");
	}	
}
var objImgPopup = new cImgPopup();
