// functies voor menu-sturing Luxom.be

function imgSwap(objImg) {
  var strOver  = "_o";     // image to be used with mouse over
  var strNormal = "_n";     // normal image
  var strImg = objImg.src;
  if (strImg.indexOf(strOver) != -1) {
    objImg.src = strImg.replace(strOver,strNormal);
    } else {
    objImg.src = strImg.replace(strNormal,strOver);
    }
  }

function insertMailAddress(first,last,cssClass) {
  var c = '';
  if (cssClass != '') {
    c = ' class="'+cssClass+'"'
    }
  document.write('<a href="mailto:' + first + String.fromCharCode(64) + last + '"' + c + '>' + first + String.fromCharCode(64) + last + '</a>');
  }



// functies voor form-validatie

function trim(stringToTrim) {
  while (stringToTrim.substring(0,1) == ' ') {
    stringToTrim = stringToTrim.substring(1,stringToTrim.length);
    }
  while (stringToTrim.substring(stringToTrim.length-1,stringToTrim.length) == ' ') {
    stringToTrim = stringToTrim.substring(0,stringToTrim.length-1);
    }
  return stringToTrim;
  }

function checkTxtField(x,y) {
  if (trim(window.document.getElementById(x).value)=="") {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkNrField(x,y) {
  a = window.document.getElementById(x).value
  if (isNaN(a) || a=="") {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkNumberLimits(x,y,min,max) {
  a = window.document.getElementById(x).value
  if (isNaN(a) || a=="") {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    } else if (window.document.getElementById(x).value<min || window.document.getElementById(x).value>max) {
      foutmelding=foutmelding+"\n"+y;
      error=1;
    }
  }

function checkEmailAddress(x,y) {
  a = window.document.getElementById(x).value;
  if (a.indexOf("@")==-1) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkPasswords(x1,x2,y) {
  if (window.document.getElementById(x1).value.toLowerCase()!=window.document.getElementById(x2).value.toLowerCase()) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkFieldMinLength(x,l,y) {
  if (window.document.getElementById(x).value.length < l) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkDoubleQuotes(x,y) {
  pos = window.document.getElementById(x).value.indexOf('"');
  if (pos != -1) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

function checkNoSpaces(x,y) {
  pos = window.document.getElementById(x).value.indexOf(' ');
  if (pos != -1) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }

// bij deze functie is het mogelijk om enkel te controleren als de bijhorende radio-button geselecteerd is (aangeduid met id=z!!)
function checkNrField_radiocheck(x,y,z) {
  if (window.document.getElementById(z).checked) {
    a = window.document.getElementById(x).value
    if (isNaN(a) || a=="") {
      foutmelding=foutmelding+"\n"+y;
      error=1;
      }
    }
  }

// bij deze functie is het mogelijk om enkel te controleren als de bijhorende radio-button geselecteerd is (aangeduid met id=z!!)
function checkTxtField_radiocheck(x,y,z) {
  if (window.document.getElementById(z).checked) {
    if (window.document.getElementById(x).value=="") {
      foutmelding=foutmelding+"\n"+y;
      error=1;
      }
    }
  }

function checkRadioButtons(x,y,start,end) {
  // x=ID-basename, start/end=volnummer (vb: reeks van ID's: datum1,datum2,datum3,datum4 >> x=datum; start=1; end=4)
  foundCheck=false;
  for (i=start;i<=end;i++) {
    if (document.getElementById(x+i).checked) {
      foundCheck=true;
      }
    }
  if (!foundCheck) {
    foutmelding=foutmelding+"\n"+y;
    error=1;
    }
  }