﻿function addFormEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
  var oldonload=window.onload
  if (typeof window.onload != 'function') { window.onload=func }
  else {
    window.onload=function() { oldonload(); func() }
  }
}

// --------------------- borders for text type inputs ------------------------------ //
function attachBorderAndSelect(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="1px solid #f00"; this.select();}
  obj0.onblur = function() {
                  this.style.border="1px inset #ccc"
                  if (this.value=="") {this.value=this.defaultValue}
                  this.value=this.value
                }
}

// ----------------------------------------------------------------------------- //



// -------------------------- borders for radio and checkboxes ------------------------- //
function attachBorderToRadio(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="1px solid #f00"}
  obj0.onblur = function() {this.style.border="1px solid #fff7dd"}
}

// ----------------------------------------------------------------------------- //



// ------------------------------ border for submit buttons --------------------------- //
function attachBorderToButton(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="1px solid #f00"}
  obj0.onblur = function() {this.style.border="1px outset #fff"}
}

// ----------------------------------------------------------------------------- //

// example contact form
function initContact(){

  if (!document.getElementsByTagName) return

// JavaScript is available so hide the help divs
//hideHelp('help-email')
//hideHelp('help-phone')

// text type inputs
 attachBorderAndSelect('v1gebdat');
 attachBorderAndSelect('v2gebdat');
 attachBorderAndSelect('ingangsdatum');
 //attachBorderAndSelect('aanvangsstorting');
 attachBorderAndSelect('v1verzbedr');
 //attachBorderAndSelect('voornaam');
 
// textfield
// attachBorderAndSelect('opmerkingen');

// radio buttons defined individually
// though it does not appear to work except in IE
 attachBorderToRadio('verzekerden_1');
 attachBorderToRadio('verzekerden_2'); 
 attachBorderToRadio('v1gesl_1');
 attachBorderToRadio('v1gesl_2');
 attachBorderToRadio('v2gesl_1');
 attachBorderToRadio('v2gesl_2');
 attachBorderToRadio('v1rokerjanee_1');
 attachBorderToRadio('v1rokerjanee_2');
 attachBorderToRadio('v2rokerjanee_1');
 attachBorderToRadio('v2rokerjanee_2'); 

// checkbox
// this does not appear to work except in IE
// attachBorderToRadio('check1_0');

// submit
 attachBorderToButton('Submit');

}

// Other "onload" events may be added in the same format as this //
addFormEvent(initContact)
