function Popup(u, w, h)
{
	if (!w) w = 500;
	if (!h) h = 500;
	l = Math.round(screen.width/2-w/2);
	t = Math.round(screen.height/2-h/2);
	
	win = window.open(u, 'popup', 'width='+w+',height='+h+',left='+l+',top='+t+',scrolling');
	win.focus();
}

function PopupRight(u, w, h)
{
	if (!w) w = 200;
	if (!h) h = 400;
	l = Math.round(screen.width/2) + 250;
	t = Math.round(screen.height/2-h/2);
	win = window.open(u, 'popup', 'width='+w+',height='+h+',left='+l+',top='+t+',scrolling');
	win.focus();
}

function AlphaPopupHide()
{
	document.getElementById('divAlphaPopupBack').style.display = 'none';
	document.getElementById('divAlphaPopupText').style.display = 'none';
	
	AlphaPopupWidth = 0;
	AlphaPopupHeight = 0;
	
	// Tilføjer onScroll event handler
	window.onscroll = null;
	onresize = null;
}

function AlphaPopupShow(url, width, height)
{
	
	
	// Henter dokument størrelse og scroll
	var scrollX = document.body.scrollLeft;
	var scrollY = document.body.scrollTop;
	if (window.innerWidth)
	{
		var sizeX = window.innerWidth;
		var sizeY = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		var sizeX = document.documentElement.clientWidth;
		var sizeY = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientWidth)
	{
		var sizeX = document.body.clientWidth;
		var sizeY = document.body.clientHeight;
	}
	else
	{
		return false;
	}
	
	
	if (width > sizeX) width = sizeX;
	if (height > sizeY) height = sizeY;
	
	if( window.innerHeight && window.scrollMaxY ) // Firefox 
	{
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{
		pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop; 
	}
	
	
	// Viser transparent baggrund
	var divBack = document.getElementById('divAlphaPopupBack');
	divBack.style.left = scrollX + 'px';
	divBack.style.top = scrollY + 'px';
	divBack.style.width = sizeX + 'px';
	divBack.style.height = pageHeight + 'px';
	divBack.style.display = '';
	
	// Viser teksboks med info	
	var divText = document.getElementById('divAlphaPopupText');
	if (!width) width = AlphaPopupWidth;
	if (!height) height = AlphaPopupHeight;
	if (width) AlphaPopupWidth = width;
	if (height) AlphaPopupHeight = height;
	var posX = scrollX + Math.round(sizeX / 2 - width / 2);
	var posY = scrollY + Math.round(sizeY / 2 - height / 2);
	divText.style.left = posX + 'px';
	divText.style.top = posY + 'px';
	divText.style.width = width + 'px';
	divText.style.height = height + 'px';		
	if (url && (typeof url == 'string')) 
		 divText.innerHTML = '<table cellspacing="0" cellpadding="0" style="border:4px #525252 solid;" style="display: block;"><tr><td align="right" style="padding:7px 10px 5px 0px; background-color:#E8E8E8; border:1px #525252 solid;"><a id="popup-close" href="javascript:AlphaPopupHide();" title="Close"><img src="/layouts/Standard/img/btn_close.jpg"/></a></td></tr><tr><td><iframe src="' + url + '" width="' + (width-54) + '" height="' + (height+6) + '" scrolling="auto" frameborder="0" framespacing="0" allowtransparency="true" marginwidth="0" marginheight="0" style="display: block;"></iframe></td><td id="tdAlphaPopupInfo"></td></tr></table></div>';
	divText.style.display = '';

	// Tilføjer onScroll event handler
	window.onscroll = AlphaPopupShow;
	onresize = AlphaPopupShow;
}

function AlphaPopupInfoHide()
{
	tdInfo = document.getElementById('tdAlphaPopupInfo');
	tdInfo.innerHTML = '';
}

function AlphaPopupInfo(url, width)
{
	if (AlphaPopupWidth == 0 || AlphaPopupHeight == 0) return;
	if (!width) width = 200;
	var divText = document.getElementById('divAlphaPopupText');
	divText.style.width = (AlphaPopupWidth + width) + 'px';
	tdInfo = document.getElementById('tdAlphaPopupInfo');
	tdInfo.innerHTML = '<iframe src="' + url + '" width="' + width + '" height="' + AlphaPopupHeight + '" scrolling="yes" frameborder="0" framespacing="0" allowtransparency="true"></iframe>';
}

document.write('<div id="divAlphaPopupBack" style="background: #000000; width: 100px; height: 100px; filter: alpha(opacity=70); opacity: 0.70; position: absolute; left: 0px; top: 0px; display: none; z-index: 1000;">&nbsp;</div>');
document.write('<div id="divAlphaPopupText" style="background: none; width: 100px; height: 100px; position: absolute; left: 0px; top: 0px; display: none; z-index: 1001;">&nbsp;</div>');

var AlphaPopupWidth = 0;
var AlphaPopupHeight = 0;
