DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
Konqueror = (navigator.userAgent.indexOf("Konqueror") > -1) ? 1 : 0;
Konqueror22 = (navigator.userAgent.indexOf("Konqueror 2.2") > -1 || navigator.userAgent.indexOf("Konqueror/2.2") > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf("Opera") > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf("Opera 5") > -1 || navigator.userAgent.indexOf("Opera/5") > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf("Opera 6") > -1 || navigator.userAgent.indexOf("Opera/6") > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf("MSIE") > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;

function setLMCookie(name, value) {
	document.cookie = name + "=" + value;
}

function getLMCookie(name) {
	foobar = document.cookie.split(name + "=");
	if (foobar.length < 2) {
		return null;
	}
	tempString = foobar[1];
	if (tempString.indexOf(";") == -1) {
		return tempString;
	}
	yafoobar = tempString.split(";");
	return yafoobar[0];
}


function calcPhcp(ehcp, par, sr, cr)
{
	phcp = ehcp * sr / 113 + cr - par;
	return phcp;
}

function calculate()
{
	// haal Exact handicap op
	tmp_ehcp = document.getElementById('ehcp').value;
	tmp_s = tmp_ehcp.replace(',','.');
	ehcp = new Number(tmp_s);
	
	// berekenen playing handicap
	hbt = Math.round(calcPhcp(ehcp, 72.0, 131, 73.5));
	hmt = Math.round(calcPhcp(ehcp, 72.0, 130, 72.6));
	dbt = Math.round(calcPhcp(ehcp, 72.0, 124, 74.9));
	dmt = Math.round(calcPhcp(ehcp, 72.0, 123, 74.0));

	// vul de velden
	document.getElementById('hbtphcp').value = hbt;
	document.getElementById('hmtphcp').value = hmt;
	document.getElementById('dbtphcp').value = dbt;
	document.getElementById('dmtphcp').value = dmt;
		
}

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2 - 5;
var wint = (screen.height - h) / 2 - 15;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no, toolbar=no, location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

