// JavaScript Document
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ValidateZoeker() {
  with (window.document.forms[0]) {
    message = "";
    notfilled = "";
    opp = "";
	if (!geslacht[0].checked && !geslacht[1].checked) {
	  notfilled += "-Geslacht\n";
    }
	if (naam.value == "") {
	  notfilled += "-Naam\n";
    }
	if (voorletters.value == "") {
	  notfilled += "-Voorletters\n";
    }
	if (adres.value == "") {
	  notfilled += "-Adres\n";
    }
	if (postcode.value == "") {
	  notfilled += "-Postcode\n";
    }
	if (plaats.value == "") {
	  notfilled += "-Plaats\n";
    }
	if (telefoon.value == "") {
	  notfilled += "-Telefoonnummer\n";
    }
	if (!oppgv.checked) {
      JSoppvan = parseInt(oppvan.value);
	  if (isNaN(JSoppvan)) {
	    opp += "Oppervlakte vanaf moet een getal zijn\n\n";
	  }
	  JSopptot = parseInt(opptot.value);
	  if (isNaN(JSopptot)) {
	    opp += "Oppervlakte tot moet een getal zijn\n\n";
	  }
	  if (!isNaN(JSoppvan) && !isNaN(JSopptot) && (JSoppvan >= JSopptot)) {
        opp += "Oppervlakte vanaf moet kleiner zijn dan Oppervlakte tot\n\n";	  
	  }
	}
	if (notfilled != "" || opp != "") {
	  if (notfilled != "") {
	    message = "De volgende verplichte velden zijn leeg:\n" + notfilled + "\n";
	  }
	  message += opp;
	  alert (message);
	  return false;
	}
	//JSplaatsen vullen
	//newplaatsen.value = JSplaatsen;
	return true;
  }
}

function ValidateReageer() {
  with (window.document.forms[0]) {
    message = "";
    notfilled = "";
	if (!contactvoor[0].checked && !contactvoor[1].checked) {
	  notfilled += "-Contact opnemen voor\n";
    }
	if (!contactper[0].checked && !contactper[1].checked && !contactper[2].checked) {
	  notfilled += "-Contact opnemen per\n";
    }
    if (bedrijfsnaam.value == "") {
      notfilled += "-Bedrijfsnaam\n"
    }
    if (contactpersoon.value == "") {
      notfilled += "-Contactpersoon\n";
    }
	if (contactper[2].checked) {
      if (adres.value == "") {
	    notfilled += "-Adres\n";
      }
	  if (postcode.value == "") {
	    notfilled += "-Postcode\n";
      }
	  if (plaats.value == "") {
	    notfilled += "-Plaats\n";
      }
    }
    if (email.value == "") {
      notfilled += "-Emailadres\n";
    }
	if (telefoon.value == "") {
	  notfilled += "-Telefoon\n";
    }
    if (notfilled != "") {
      message = "De volgende verplichte velden zijn leeg:\n" + notfilled + "\n";
      alert (message);
	  return false;
	} else {
	  return true;
	}
  }
}

function emailCheck (emailStr) {

  if (emailStr == "") {
    return true;
  }

  /* The following variable tells the rest of the function whether or not
  to verify that the address ends in a two-letter country or well-known
  TLD.  1 means check it, 0 means don't. */

  var checkTLD=1;

  /* The following is the list of known TLDs that an e-mail address must end with. */

  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|biz|info)$/;

  /* The following pattern is used to check if the entered e-mail address
  fits the user@domain format.  It also is used to separate the username
  from the domain. */

  var emailPat=/^(.+)@(.+)$/;

  /* The following string represents the pattern for matching all special
  characters.  We don't want to allow special characters in the address. 
  These characters include ( ) < > @ , ; : \ " . [ ] */

  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

  /* The following string represents the range of characters allowed in a 
  username or domainname.  It really states which chars aren't allowed.*/

  var validChars="\[^\\s" + specialChars + "\]";

  /* The following pattern applies if the "user" is a quoted string (in
  which case, there are no rules about which characters are allowed
  and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
  is a legal e-mail address. */

  var quotedUser="(\"[^\"]*\")";

  /* The following pattern applies for domains that are IP addresses,
  rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
  e-mail address. NOTE: The square brackets are required. */
  
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
  
  /* The following string represents an atom (basically a series of non-special characters.) */
  
  var atom=validChars + '+';

  /* The following string represents one word in the typical username.
  For example, in john.doe@somewhere.com, john and doe are words.
  Basically, a word is either an atom or quoted string. */

  var word="(" + atom + "|" + quotedUser + ")";

  // The following pattern describes the structure of the user

  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

  /* The following pattern describes the structure of a normal symbolic
  domain, as opposed to ipDomainPat, shown above. */

  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

  /* Finally, let's start trying to figure out if the supplied address is valid. */

  /* Begin with the coarse pattern to simply break up user@domain into
  different pieces that are easy to analyze. */

  var matchArray=emailStr.match(emailPat);

  if (matchArray==null) {

    /* Too many/few @'s or something; basically, this address doesn't
    even fit the general mould of a valid e-mail address. */

    alert("Dit emailadres is onjuist (controleer @ en .)");
    return false;
  }
  var user=matchArray[1];
  var domain=matchArray[2];

  // Start by checking that only basic ASCII characters are in the strings (0-127).

  for (i=0; i<user.length; i++) {
    if (user.charCodeAt(i)>127) {
      alert("Dit gebruikersnaam bevat ongeldige karakters.");
      return false;
    }
  }
  for (i=0; i<domain.length; i++) {
    if (domain.charCodeAt(i)>127) {
      alert("De domeinnaam bevat ongeldige karakters.");
      return false;
    }
  }
}

