var closebutton = "/images/dockets/img_close_green.gif"; //Adress of image of the button
var raampje, xtra, ytra;

function sleepen(){
	if (event.button!=1)return;	
	raampje = document.getElementById("action_win");
	temp1=raampje.style.posLeft;
	temp2=raampje.style.posTop;xpos=event.clientX;
	ypos=event.clientY;xtra = temp1-xpos;
	ytra = temp2-ypos;document.onmousemove=plaats;
}

function plaats(){
	if (event.button==1){
		raampje.style.pixelLeft=event.clientX+xtra;
		raampje.style.pixelTop=event.clientY+ytra;return false;
	}
}

function loadwindow(inside, color, width, height, background, top, left){		
	titlecolor = "silver";
	opacitytitle = 45;
	if(!width){
		width = 400;
		height = 300;
	}
	if(inside.indexOf(".php"))
		inside = "<iframe frameborder=0 name=\"raampje\" width="+(width-10)+" height="+(height-30)+" src=\""+inside+"\" scrolling=\"no\" ></iframe>";
	if(!color)
		color = "silver";							
	//var thisspan = document.getElementById("action_win").style;
	document.getElementById("action_win").innerHTML = "";
	if (!top){
		top = 300;
		left = 250;
	}
	document.getElementById("action_win").style.pixelLeft = document.body.scrollLeft + left;		
	document.getElementById("action_win").style.pixelTop =  document.body.scrollTop + top;
	document.getElementById("action_win").style.left = document.body.scrollLeft + left + "px";
	document.getElementById("action_win").style.top =  document.body.scrollTop + top + "px";
	document.getElementById("action_win").style.visibility="visible";
	output = "<table cellpadding=0 cellspacing=0 width=" + width + " height=" + height + " border=2>";
	output += "<tr><td onmousedown='sleepen()' style='cursor:hand' onmouseup='JavaScript:document.onmousemove=\"\" ' bgcolor='"+titlecolor+"' style='filter:alpha(opacity="+opacitytitle+");' width =" + width + "></td><td bgcolor='silver'>";
	output += "<input type='image' onclick='close_lw()' src='"+closebutton+"'></td></tr>";
	output += "<tr><td width=100% colspan=2><table ";
	if(background) output += "style='background-image:url(\" " + background + "\")'";
	output += " width=100% height=100% bgcolor='"+color+"'><tr><td height=100% width=100% >"+ inside+"</td></tr></table></td></tr>";
	document.getElementById("action_win").innerHTML = output;
}

function close_lw(){
	document.getElementById("action_win").style.visibility="hidden";
}


/*--------------------------------------------*/
// Fix the amount of digging parents up.
/*--------------------------------------------*/

function getelementtop(elm)
{
	var mOffsetTop    = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	var parents_up    = 2;
	
	while(parents_up > 0)
	{
		mOffsetTop   += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
		parents_up--;
	}
	
	return mOffsetTop;
}

/*--------------------------------------------*/
// Fix the amount of digging parents up.
/*--------------------------------------------*/

function getelementleft(elm)
{
	var mOffsetLeft   = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	var parents_up    = 2;
	
	while(parents_up > 0)
	{
		mOffsetLeft  += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
		parents_up--;
	}
	return mOffsetLeft;
}

function findPosleft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return curleft;
}

function findPostop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}
	return curtop;
}