function show(id) {
	document.getElementById(id).style.display='';
}
function hide(id) {
	document.getElementById(id).style.display='none';
}
function val(id) {
	return gE(id).value;
}
function gE(id) {
	return document.getElementById(id);
}
function popupPage(url) {
	popupWidth = 800; // set the popup width
	widthHeightRatio = 1.618;
	popupHeight = popupWidth / widthHeightRatio;

	leftVal = (screen.width / 2) - (popupWidth / 2);
	topVal = 100;
	var page = window.open(url, '', 'width=' + popupWidth + ', height = ' + popupHeight + ', scrollbars=yes, resizable=no, left=' + leftVal + ', top=' + topVal);
	page.focus();
}
function watchPostalCode() {
	var pCElm = document.getElementById('postalCode');
	var cityElm = document.getElementById('city');
	var cityDisabledElm = document.getElementById('cityDisabled');

	if(pCElm.value.length >= 3) {
		var city = getCityFromPostalCode(pCElm.value);
		cityDisabledElm.value = (city == undefined) ? 'Findes ikke.' : city;
		cityElm.value = (city == undefined) ? '' : city;
	} else {
		cityElm.value = '';
		cityDisabledElm.value = '';
	}
}
function nl2br(str) {
	return str.replace(/([^>])\n/g, '$1<br />\n');
}
function subtractVat(elmId) {
	exVat = roundNumber($('#' + elmId).val() * 0.8, 2);
	$('#' + elmId).val(exVat);
}
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
