/**********************************************************
* Function for the menu to work in Internet Explorer      *
**********************************************************/
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

/**********************************************************
* Function for popup nicely in the center of the screen   *
**********************************************************/
function centerPopUp( url, name, width, height, scrollbars ) { 
 
	if( scrollbars == null ) scrollbars = "0" 
 
	str  = ""; 
	str += "resizable=1,"; 
	str += "scrollbars=" + scrollbars + ","; 
	str += "width=" + width + ","; 
	str += "height=" + height + ","; 
 
	if ( window.screen ) { 
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 
 
		var xc = ( aw - width ) / 2; 
		var yc = ( ah - height ) / 2; 
 
		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	} 
	window.open( url, name, str ); 
} 

/* submitten van het cursus formulier formulier genaamd */
function checkAantal(field){
	if (isNaN(field.value)) {
		field.value='1';
		alert("U moet hier het aantal personen invullen.\n\n Dit moet een getal zijn!");
		field.focus();
		
	} else {
		if (field.value>0) {
			document.formulier.submit();
		}
	}
}

/* submitten van het cursus formulier formulier genaamd */
function checkAantalF(field){
	if (isNaN(field.value)) {
		field.value='';
		alert("U moet hier het aantal functies invullen.\n\n Dit moet een getal zijn!");
		document.getElementById("pago3_aantal").focus();
		
	} else {
		if (field.value>0) {
			document.formulier.submit();
		}
	}
}

function checkGetal(field) {
	if (isNaN(field.value)) {
		field.value='1';
		alert("U moet hier het aantal deelnemers invullen.\n\n Dit moet een getal zijn!");
		field.focus();
	}
}



//////////////////////////////////////
//   Please use this comment        //
//     when you use this code!      //
//                                  //
//         copyright MMDA           //
//     code by Mark Westenberg      //
//////////////////////////////////////


//globale variabele voor foutmelding
var message="";
//algemene cijfer controle
function cijfers(c){
cijfer= new Array(0,1,2,3,4,5,6,7,8,9);
	for(z=0;z<11;z++){
		if (c == cijfer[z]){
		return true;
		}
	}
}
//algemene letter controle
function letters(l){
letter=new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ');
for (x=0;x<27;x++){
	if (l == letter[x]){
	return true;
	}
}
}
//telefoon check
function telefoon(n,t){
var c = "";
if (n!="" && t!=""){
		veld = n+t;
		telveld = new String(veld);
		if (telveld.length!=10){c=4;}
		for(i=0;i<10;i++){
			if (!cijfers(telveld.charAt(i))){
			c=5;
			}
		}
}
return c;
}

function zipcode(cijf){
var c="";
if (cijf!=""){
	if (isNaN(cijf)){
		c=1;
	}
}
return c;
}

function postcode(cijf, let){
var c="";
if (cijf!="" && let!=""){
	veld = new String(let);
	veld = veld.toLowerCase();
	if (cijf.length!=4){
		c=1;
	}
	else{
		if (cijf<1000 || isNaN(cijf)){c=2;}
	}
	if (veld.length!=2){
	c=4;
	}
	else {
		for (i=0;i<2;i++){
			if (!letters(veld.charAt(i))){
			c=5;
			}
		}
	}
}
return c;
}


//tekstveld controle
function tekstveld(t){
var c="";
if (t!=""){
	tekst = new String(t);
	tekst = tekst.toLowerCase();
	l = tekst.length;
	for (i=0;i<l;i++){
		if (!letters(tekst.charAt(i))){
		c=6;
		}
	}
}
return c;
}
//nummer controle
function nummer(n){
var c="";
if (n!=""){
	num = new String(n);
	l = num.length;
	for (i=0;i<l;i++){
		if (!cijfers(num.charAt(i))){
		c=6;
		}
	}
}
return c;
}

//kvk nummer controle
function kvk(n){
var c=0;
if (n!=""){
	num = new String(n);
	if (n.length!=8){c=4;}
	for (i=0;i<n.length;i++){
		if (!cijfers(num.charAt(i))){
		c=6;
		}
	}
}
return c;
}


//email controle
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 dag(d){
c="";
if (d!=""){
	g = nummer(d);
	if (g!="" || d>31){
		c=7;
	}
}
return c;
}

function maand(m){
c="";
if (m!=""){
	d = nummer(m);
	if (d!="" || m>12){
		c=7;
	}
}
return c;
}

function jaar(j){

d = new Date();
maxj = d.getFullYear();
c="";
if (j!=""){
	d = nummer(j);
	if (d!="" || j<1900 || j>maxj){
		c=7;
	}
}
return c;	
}

//The script below was taken from The JavaScript Source!! http://javascript.internet.com

function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}

//end money script
function checkLength(field,type) {
	pc = new String(field);
	l = pc.length;
	if (document.all&&document.getElementById) {
		if (pc.length == 4) {
			if (type=="zip") {
				document.getElementById('post_l').focus();
			} else {
				document.getElementById('postbus_post_l').focus();
			}
		}
	} else {
		if (pc.length == 3) {
			if (type=="zip") {
				document.getElementById('post_l').focus();
			} else {
				document.getElementById('postbus_post_l').focus();
			}
		}
	}
}
