var menuHeight = 270; // height of the closed menu on the left

function openPopup(waarde, hh, url) {
	blurContainer(waarde, hh, url);
}
function blurContainer(waarde, hh, url) {
	targetlaag = "popup";
	h = 0;
	r = 0;
	obj = document.getElementById("col-links");
	if(obj) h = getElementHeight(obj);
	obj = document.getElementById("col-rechts");
	if(obj) r = getElementHeight(obj);
	if(r > h) h = r;
	h += 72;
	obj = document.getElementById("opac");
	if(obj) {
		if(waarde == 0) {
			obj.style.display = "none";
			obj = document.getElementById(targetlaag);
			if(obj) {
				obj.style.display = "none";
			}
		} else {
			obj.style.height = (h+1+18)+"px";
			obj.style.opacity = waarde/100;
			obj.style.filter = "alpha(opacity="+waarde+",style=0)";
			obj.style.display = "block" ;
			obj = document.getElementById(targetlaag);
			if(obj) {
				getSize();
				getScrollXY();
				breedte = 680;
				topup = 60;
				obj.style.width = breedte+"px";
				obj.style.marginLeft = "-"+parseInt(breedte/2)+"px";
				obj.style.top = parseInt(topup+scrollPosY)+"px";
				hhh = 0;
				if(hh == "auto") {
					hhh = parseInt(screenPosHeight-2*topup);
				} else if(hh == "content") {
					hhh = "content";
				} else {
					hhh = hh;
					if(hh > parseInt(screenPosHeight-2*topup)) hhh = parseInt(screenPosHeight-2*topup);
				}
				hhh == "content" ? obj.style.height = "auto" : obj.style.height = hhh+"px";
				obj.style.display = "block";
				obj = document.getElementById(targetlaag+"overflow");
				hhh == "content" ? obj.style.height = "auto" : obj.style.height = (hhh-24)+"px";
				//obj.style.width = (breedte-20)+"px";
				//obj.style.width = (breedte-18)+"px";
				//obj.style.paddingRight = "18px";
				obj.style.display = "block";
				obj.style.overflowX = "hidden";
				obj.style.overflowY = "auto";
				haalInhoud(url);
			}
		}
	}
}

function haalInhoud(url) {
	/*
	info ophalen
	*/
	document.getElementById("popuptitel").innerHTML = url;
	//document.getElementById("popupoverflow").innerHTML = "fdshahfj";
}

function getElementHeight(Elem) {
	var yPos = false;
	if(typeof(Elem) == "string")
	{
		if(document.getElementById) {
			Elem = document.getElementById(Elem);
		} else if (document.all){
			Elem = document.all[Elem];
		}
	}
	if(Elem.offsetHeight) {
		yPos = Elem.offsetHeight;
	} else if (Elem.style) {
		if (Elem.style.pixelHeight) yPos = Elem.style.pixelHeight;
	}
	return yPos;
}

var screenPosWidth = 0;
var screenPosHeight = 0;
var scrollPosY = 0;
var scrollPosX = 0;

function getSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		screenPosWidth = window.innerWidth;
		screenPosHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		screenPosWidth = document.documentElement.clientWidth;
		screenPosHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		screenPosWidth = document.body.clientWidth;
		screenPosHeight = document.body.clientHeight;
	}
}
function getScrollXY() {
	scrollPosY = 0;
	scrollPosX = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrollPosY = window.pageYOffset;
		scrollPosX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrollPosY = document.body.scrollTop;
		scrollPosX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrollPosY = document.documentElement.scrollTop;
		scrollPosX = document.documentElement.scrollLeft;
	}
}
function getElementTop(Elem) {
		if(typeof(Elem) == "string")
		{
			if(document.getElementById) {	
				Elem = document.getElementById(Elem);
			} else if (document.all) {
				Elem = document.all[Elem];
			}
		}
		var yPos = Elem.offsetTop;
		var tempEl = Elem.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
}
function getElementLeft(Elem) {
		if(typeof(Elem) == "string")
		{
			if(document.getElementById) {
				Elem = document.getElementById(Elem);
			} else if (document.all) {
				Elem = document.all[Elem];
			}
		}
		var xPos = Elem.offsetLeft;
		var tempEl = Elem.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
		return xPos;
}

if(!mouseMoveActions) var mouseMoveActions = new Array();

if(!document.all) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = onmousemovement;
// voorkom tekstselectie (tijdens slepen)
if(!document.all) document.captureEvents(Event.ONSELECTSTART)
document.onselectstart = cancelSelect;
function cancelSelect() {
	if(dragger) return false;
}

function onmousemovement(e) {
	// ten aller tijden de muispositie bepalen
	if(document.all) {
		if(document.documentElement.scrollTop) {
			xx = document.documentElement.scrollLeft;
			yy = document.documentElement.scrollTop;
		} else {
			xx = document.body.scrollLeft;
			yy = document.body.scrollTop;
		}
		topX = xx + 20;
		topY = yy + 20;
		mousePosX = event.clientX + xx;
		mousePosY = event.clientY + yy;
	} else {
		if(document.body.scrollTop || document.body.scrollLeft) {
			mousePosX = parseInt(e.pageX);
			mousePosY = parseInt(e.pageY);
			topX = parseInt(document.body.scrollLeft) + 20;
			topY = parseInt(document.body.scrollTop) + 20;
		} else {
			xx = parseInt(window.pageXOffset);
			yy = parseInt(window.pageYOffset);
			topX = xx + 20;
			topY = yy + 20;
			mousePosX = parseInt(e.pageX); // + xx;
			mousePosY = parseInt(e.pageY); // + yy;
		}
	}
	if(mousePosX < 0) {
		mousePosX = 0;
	}
	if(mousePosY < 0) {
		mousePosY = 0;
	}
	for( var i=0 ; i<mouseMoveActions.length ; i++)
	{
		eval("if(typeof("+mouseMoveActions[i]+") == 'function') "+mouseMoveActions[i]+"();");
	}
}
