function checkUser() {
var d = document.forms.contact;

   if (d.m_naam.value==""){
                alert('U bent vergeten om uw naam in te vullen!');
                d.m_naam.focus();
                return false;
 }
   if (d.m_email.value==""){
                alert('U bent vergeten om uw email adres in te vullen!');
                d.m_email.focus();
                return false;
 }
        if (!isEmail(d.m_email.value)){
                window.alert("Uw email adres is niet correct in gevuld!");
                d.m_email.focus();
                return false;
 }

}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function ShowHideChildItems(listItem, state){
  if(listItem){
    if(listItem.tagName == "LI"){
      var item_id = listItem.id.substr(4);
      var child_ul = document.getElementById('subnavigatie'+item_id);
      var current_li = '';
      
      //collapse all items in corresponding menu
      var parent_node = listItem.parentNode;
      for(i=0;i<=parent_node.childNodes.length-1;i++){
        current_li = parent_node.childNodes[i];
        for(j=0;j<=current_li.childNodes.length-1;j++){
          //console.log(current_li.childNodes[j].tagName);
          if(current_li.childNodes[j].tagName == "UL"){
            current_li.childNodes[j].style.display = 'none'
          }
        }
      }
      
      if(child_ul){
        if(typeof state != 'undefined'){
          if(state == 'block' || state == 'none'){
            child_ul.style.display = state;
          }
        }else{
          if(child_ul.style.display == '' || child_ul.style.display == 'block'){
            child_ul.style.display = 'none';
            return;
          }else{
            child_ul.style.display = 'block';
            return;
          }
        }
      }
    }
  }
}

	  
	  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(); }
}
