function getTextWidth(element, text)
{
	var docElement = document.createElement(element);
	docElement.style.whiteSpace = "nowrap";
	docElement.style.display = "inline";
	docElement.innerHTML = text;
	document.body.appendChild(docElement);
	var width = docElement.offsetWidth;
	document.body.removeChild(docElement);

	return width;
}

function openPlayer (url, heading, playerWidth, playerHeight)
{
	var headingLen = getTextWidth ('h2', heading);
	var width = (headingLen < playerWidth ? playerWidth : headingLen);
	var height = playerHeight + 70;
	width += 40;
	
	window.open (url, 'player', 'height=' + height + ', width=' + width + 'toolbar=no, directories=no, menubar=no, scrollbars=no, resizable=yes');
}