/*	Luk layer el. popup
	Hvis der er alternative DHTML-layers, der skal kigges efter, kan
	funktionen kaldes således:
	close_popup(false, 'layer1', 'layer2');
*/

function close_popup(bol_never_show_again, sDHTMLID) {
	
	for (i=1; i<arguments.length; i++) {
		if (document.getElementById(arguments[i])) {
			document.onclick = "";
			document.getElementById(arguments[i]).style.display = "none";
			if (bol_never_show_again) location.href = location.href + '&no' + sDHTMLID + '=1';
		} else if (window.parent.document.getElementById(arguments[i])) {
			document.onclick = "";
			window.parent.document.getElementById(arguments[i]).style.display = "none";
			if (bol_never_show_again) window.parent.location.href = window.parent.location.href + '&no' + sDHTMLID + '=1';
		} else {
			try {
				if (bol_never_show_again) window.opener.location.href = window.opener.location.href + '&no' + sDHTMLID + '=1';
				self.close();
			} catch(e) {
				
			}
		}
	}
}

/*	Skalér layer el. popup
	Hvis der er alternative DHTML-layers, der skal kigges efter, kan
	funktionen kaldes således:
	resizeTo_popup(343, 343, true, 'layer1', 'layer2');
*/
function resizeTo_popup(the_x, and_the_y, bol_ignore_the_x, sDHTMLID) {
	for (i=3; i<arguments.length; i++) {
		if (document.getElementById(arguments[i])) {
			if (!bol_ignore_the_x) document.getElementById(arguments[i] + "iframe").style.width = (the_x) + "px";
			document.getElementById(arguments[i] + "iframe").style.height = (and_the_y) + "px";
		} else if (window.parent.document.getElementById(arguments[i])) {
			if (!bol_ignore_the_x) window.parent.document.getElementById(arguments[i] + "iframe").style.width = (the_x) + "px";
			window.parent.document.getElementById(arguments[i] + "iframe").style.height = (and_the_y) + "px";
		} else {
			try {
				window.resizeTo(the_x, and_the_y + 40);
			} catch(e) {
				
			}
		}
	}
}

function scalePopUp(id_scale_from, id_scroll_in, bol_auto_move) {
	
	try {
		scX = document.getElementById(id_scale_from).offsetWidth+11;
		scY = document.getElementById(id_scale_from).offsetHeight+49;
		
		bol_scroll = false;

		if (scX > screen.width - 200) {
			scX = screen.width - 200;
			bol_scroll = true;
		}

		if (scY > screen.height - 200) {
			scY = screen.height - 200;
			bol_scroll = true;
		}
		
		if (bol_scroll) {
			scX += 15;
			scY += 15;
			document.getElementById(id_scroll_in).style.width = "100%";
			document.getElementById(id_scroll_in).style.height = "100%";
			document.getElementById(id_scroll_in).style.overflow = "auto";
		}
		
		window.resizeTo(scX,scY+22);
		if (bol_auto_move) window.moveTo((screen.width / 2) - 485 + 10, 250);
	} catch(e) {
					
	}

}

function lukRefresh(besked) {
    
    if(arguments.length > 0) {
        alert(besked)
    }

    if(!window.opener.closed) {
        window.opener.location.reload();
    }

    self.close();
}

function lukRefreshIframe(besked) {
    
    if(arguments.length > 0) {
        alert(besked)
    }

    parent.location.reload();
}

function iframeScale(id_dom) {


			scX = document.getElementById(id_dom).offsetWidth;
			scY = document.getElementById(id_dom).offsetHeight;

			if (!document.all)
			{
				scX += 36;
				scY += 11;
				
				parent.document.getElementById('iframechild').style.width=scX+'px';
				parent.document.getElementById('iframechild').style.height=scY+'px';

		cX = (parent.document.documentElement.clientWidth-parseInt(scX)) / 2;
		cY = (parent.document.documentElement.clientHeight-parseInt(scY)) / 2;

		if (cY < 0) cY = 0;
		if (cX < 0) cX = 0;

		parent.document.getElementById('iframechild').style.top = cY + 'px';
		parent.document.getElementById('iframechild').style.left = cX + 'px';

			} else {
				window.resizeTo(scX,scY);
			
				cX = (parent.document.body.parentNode.clientWidth-scX) / 2;
				cY = (parent.document.body.parentNode.clientHeight-scY) / 2;

				if (cY < 0) cY = 0;
				if (cX < 0) cX = 0;

				window.moveTo(cX, cY);
			}
}

var mPOPOver = false;
function init_popup(s_DHTMLID, placX, placY, bol_rel_bot_right) {

	SET_DHTML(s_DHTMLID);
	eval("dd.elements." + s_DHTMLID + ".hide()");
	setTimeout("dd.elements." + s_DHTMLID + ".show()", 1000);
	
	if (bol_rel_bot_right) {
		eval("dd.elements." + s_DHTMLID + ".moveToReverse(" + placX + "," + placY + ")");
	} else {
		eval("dd.elements." + s_DHTMLID + ".moveTo(" + placX + "," + placY + ")");
	}
	
	document.onclick = function() {
	if (!mPOPOver) {
		document.getElementById(s_DHTMLID).style.display = "none";
		eval('window.open(window.' + s_DHTMLID + 'win.location.href, "' + s_DHTMLID + '", "width=' + parseInt(document.getElementById(s_DHTMLID).style.width) + ',height=' + parseInt(document.getElementById(s_DHTMLID).style.height) + '");');
		self.focus();
		document.onclick="";
		}
	}

	var winy;
	if (self.innerHeight) // all except Explorer
	{
		winy = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		winy = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		winy = document.body.clientHeight;
	}

	if (winy < 500) {
		//document.getElementById(s_DHTMLID).style.top = "5px";
		//document.getElementById(s_DHTMLID).style.right = "5px";
	}

}