function centredPopup(popupUrl, popupWidth, popupHeight, scrollable)
{
	var windowLeft = (typeof(window.screenLeft) != "undefined") ? window.screenLeft : window.screenX;
	var windowTop = (typeof(window.screenTop) != "undefined") ? window.screenTop : window.screenY;
	var windowWidth = (typeof(window.innerWidth) != "undefined") ? window.innerWidth : document.body.clientWidth;
	var windowHeight = (typeof(window.innerHeight) != "undefined") ? window.innerHeight : document.body.clientHeight;

	var popupLeft = windowLeft + (windowWidth - popupWidth) / 2;
	var popupTop = windowTop + (windowHeight - popupHeight) / 2;
	if (popupTop + popupHeight > windowTop + windowHeight)
		popupTop -= (popupTop + popupHeight - windowTop - windowHeight);
	if (popupTop < 0)
		popupTop = 0;
	if (popupLeft < 0)
		popupLeft = 0;

	window.open(popupUrl, "dniPopup",
		"top=" + Math.floor(popupTop) + 
		",left=" + Math.floor(popupLeft) + 
		",width=" + popupWidth + 
		",height=" + popupHeight + 
		",resizable," +
		(scrollable ? "scrollbars" : "")).focus();
}

function selValue(oSel)
{
	return oSel.options[oSel.selectedIndex].value;
}

function selText(oSel)
{
	return oSel.options[oSel.selectedIndex].text;
}

function findControl(id)
{
	var elts = document.forms[0].elements;
	for (var n = 0; n < elts.length; n++)
	{
		var elt = elts[n];
		if (elt.name.substr(elt.name.length - id.length) == id)
			return elt;
	}
	return null;
}

function showHeading(id)
{
	var elt = document.getElementById(id);
	if (elt)
		elt.scrollIntoView(true);
}

function questionnaireYes()
{
	location.href = "/questionnaire.aspx?ReturnURL=" + escape(location.href);
}
