var currentTabNumber=1;

// Labels for different properties..
var fldName=0;  // name of field
var fldLabel=1; // label to put on screen
var fldCheck=2; // Value check for this field
var fldRequired=3; // Required
//var fldRadioGroup=3; // Radiogroup handling
//var fldRadioValue=4; // Radiogroup handling
var fldPwdCheck=3; // Handling of password checking field
var fldPwdMinLength=4; // Minimum length of the password
var fldPwdMaxLength=5; // Maximum length of the password

var ns4 = (document.layers)?true:false;
var ie4 = (document.all)?true:false;
var ns6 = !ns4 && !ie4 && ((document.getElementById) ? true:false);

var tabfunction   = "";
var tabfunctionnr = "";

function switchTab( tabf, tabn, tabnum) {
  tabfunction   = tabf;
  tabfunctionnr = tabn;
  tabnum        = tabnum + 1; 

  if(checkforms[(currentTabNumber-1)]==0)
  	switchToIfValue(tabnum);
  else	
    switchTo(tabnum);
}

function setUp(num) {
  ns4 = (document.layers)?true:false;
  ie4 = (document.all && !document.getElementById)?true:false;
  ie5 = (document.all && document.getElementById)?true:false;
  ns6 = !ns4 && !ie4 && ((document.getElementById) ? true:false);

  radioBits=1;
  giveFocus(1,0,true);
}

function getTabForm(num) {
  if (ie4)	return document.all['dnsbeTab'+num].forms['dnsbefrm'+num];
  else if (ns4)	return document.layers['dnsbeTab'+num].document.forms['dnsbefrm'+num];
  else if (ns6)	return document.forms['dnsbefrm'+num];
  else 		return document.getElementById('dnsbefrm'+num);
}

function setValue(aform,fieldname,avalue) {
  var myType = aform.elements[fieldname].type;
  if (myType == 'password' || myType == 'text' || myType == 'textarea' || myType == 'hidden') { 
	aform.elements[fieldname].value=avalue;
  }
}

function getValue(aform,elemName) {
  if (elemName.substr(0,4) == "RDO_") {
  	var RadioGroup = aform.elements[elemName];
  	for (i=0; i<RadioGroup.length; i++) {
  		if (RadioGroup[i].checked) {
  			return RadioGroup[i].value;
  		}
  	}
  	return(aform.elements[elemName].value);
  }
  var myType = aform.elements[elemName].type;
  if (myType == 'checkbox') {
	if (aform.elements[elemName].checked) {
		return "1";
	} else {
		return "0";
	}
  }
  if (myType == 'password' || myType == 'text' || myType == 'textarea') 	
  	return(aform.elements[elemName].value);
  if (myType == 'select-one')
  	return aform.elements[elemName].options[aform.elements[elemName].selectedIndex].value;
  return(aform.elements[elemName].value);
}

function getTab(nm) {
  if (ns4) 	return document.layers["dnsbeTab"+nm];
  else if (ie4) return document.all[("dnsbeTab"+nm)];
  else     	return document.getElementById("dnsbeTab"+nm);
}

function switchTo(tabnum) {
  var frm=forms[currentTabNumber-1];
  var myform=getTabForm(currentTabNumber);

  for (var i=0; i<frm.length; i++) {
       if (frm[i][fldCheck] == 'rg') {
          //var rg = frm[i][fldRadioGroup];
          var fieldName = frm[i][fldName];
          var RGValue = getValue(myform, rg);
          setValue(myform, fieldName, RGValue);
       }
  }
  if (currentTabNumber != forms.length) {
    if (!checkValues(currentTabNumber)) return;
  }
  giveFocus(tabnum,0,true);
}

function switchToIfValue(tabnum){
	var f1=getTabForm(currentTabNumber);
	var f=forms[currentTabNumber-1];
	for (j=0; j<f.length; j++) {
		if(document.forms[f1.name].elements[f[j][fldName]].value){
			if (!checkValues(currentTabNumber)) return;
		}
	}	
	giveFocus(tabnum,0,true);
}

function displayTab(num) {
  switch(tabfunction) {
     case 1:  LTT0( tabfunctionnr, (num-1));   break;
     case 2:  L0TJ( tabfunctionnr, (num-1));   break;
     case 3:  LTb0( tabfunctionnr, (num-1));   break;
  }
  currentTabNumber = num;
}

function checkValues(ctn) {

  var frm=forms[ctn-1];
  var f=getTabForm(ctn);

  for (var i=0; i<frm.length; i++) {
    if (!checkValue(f, frm[i])) {
       giveFocus(ctn,frm[i][fldName],false);
       return false;
    }
  }
  return true;
}

function checkValue(htmlForm, fldArray) {
   var chk = fldArray[fldCheck];
   //alert('field ['+fldArray[fldName]+'] check : ['+chk+'] value : ['+getValue(htmlForm, fldArray[fldName])+']');

//   if ((chk != 'pw') && (chk != 'pn')) {
//       if (fldArray[fldRadioGroup]) {
//          var rdogrp = fldArray[fldRadioGroup];
//          var rdoval = fldArray[fldRadioValue];
//          var rdosel = getValue(htmlForm, rdogrp);
//          if (rdosel  != rdoval) return true;
//       }
//   }

   var val=getValue(htmlForm, fldArray[fldName]);
   
   if (val=='' && fldArray[fldRequired]=='') return true;
   
   switch(chk) {
      case 'nn':
         if (val == '') {
            alert("Field '"+fldArray[fldLabel]+"' can not be empty!");
            return false;
         }
	     break;
      case 'dm':
         if (!chkDomainName(val)) {
            alert("Field '"+fldArray[fldLabel]+"' contains no valid domainname!");
            return false;
         }
    	 break;
      case 'ns':
         if (!chkNameServer(val)) {
            alert("Field '"+fldArray[fldLabel]+"' contains no valid nameserver!");
            return false;
         }
    	 break;
      case 'ip':
         if (!chkIP(val)) {
            alert("Field '"+fldArray[fldLabel]+"' contains no valid ip address!");
            return false;
         }
    	 break;
      case 'em':
         if (!chkEmail(val)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct email address!");
            return false;
         }
    	 break;
      case 'ph':
         if (!chkPhone(val)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct E.164 phone number!\n bv: 0032 (0)484/185.103 wordt +32.484185103");
            return false;
         }
    	 break;
      case 'pho':
         if (val == '') return true;
         if (!chkPhone(val)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct E.164 phone number!\n bv: 0032 (0)484/185.103 wordt +32.484185103");
            return false;
         }
    	 break;
      case 'phoadsl':
         if (val == '') return true;
         if (!chkPhoneAdsl(val)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct phone number!\n bv: 0032 (0)89/11.11.11 wordt 089/111111");
            return false;
         }
    	 break;
      case 'dt':
         if (!chkDate(val,true)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct future date!");
            return false;
         }
    	 break;
      case 'od':
         if (!chkDate(val,false)) {
            alert("'"+fldArray[fldLabel]+"' contains no correct date!");
            return false;
         }
    	 break;
      case 'pw':
         if (val == '') {
            alert("Field '"+fldArray[fldLabel]+"' can not be empty!");
            return false;
         } else if (val != htmlForm.cpw.value ) {
            alert(fldArray[fldLabel]+" do not match!");
            return false;
         } else if (val.length < 6 ) {
	        alert(fldArray[fldLabel]+" can't be smaller than 6 characters");
	        return false;
         } else if (val.length > 30) {
	        alert(fldArray[fldLabel]+" can't be bigger than 30 characters");
	        return false;
	     }
	     break;
      case 'psp':
         if (val == '') {
            alert("Field '"+fldArray[fldLabel]+"' can not be empty!");
            return false;
         } else if (val != htmlForm.cpsp.value ) {
            alert(fldArray[fldLabel]+" do not match!");
            return false;
         } else if (val.length < 6 ) {
	        alert(fldArray[fldLabel]+" can't be smaller than 6 characters");
	        return false;
         } else if (val.length > 255) {
	        alert(fldArray[fldLabel]+" can't be bigger than 255 characters");
	        return false;
	     }
	     break;
      case 'apipw':
         if (val == '') {
            alert("Field '"+fldArray[fldLabel]+"' can not be empty!");
            return false;
         } else if (val != htmlForm.capipw.value ) {
            alert(fldArray[fldLabel]+" do not match!");
            return false;
         } else if (val.length < 6 ) {
	        alert(fldArray[fldLabel]+" can't be smaller than 6 characters");
	        return false;
         } else if (val.length > 255) {
	        alert(fldArray[fldLabel]+" can't be bigger than 255 characters");
	        return false;
	     }
	     break;
      case 'id': 
         if (!chkUserid(val)) {
            alert("Field '"+fldArray[fldLabel]+"' contains no valid userid!");
            return false;
         }
    	 break;
      case 'dem':
         if (!ValidateEmail(val)) {
            alert("'"+fldArray[fldLabel]+"' no correct email address!\nPlease use syntax like this info@test.com");
            return false;
         }
    	 break;
      case 'dur':
         if (!ValidateURL(val)) {
            alert("'"+fldArray[fldLabel]+"' no correct url address!\nPlease use syntax like this http://www.test.com");
            return false;
         }
    	 break;
      case 'amount': 
         if (val == '') {
            alert("Field '"+fldArray[fldLabel]+"' can not be empty!");return false;
         }
         if (isNaN(val)) {
            alert("Field '"+fldArray[fldLabel]+"' bevat ongeldige karakters!");return false;
         }
         if (val < 5) {
            alert("Field '"+fldArray[fldLabel]+"' bevat een te klein bedrag, min 5 euro!");return false;
         }
         if (val > 1000) {
            alert("Field '"+fldArray[fldLabel]+"' bevat een te groot bedrag, max 1000 euro!");return false;
         }
         if (6<val.length) {
            alert("Field '"+fldArray[fldLabel]+"' bevat te veel cijfers!");return false;
         }
         if (val.lastIndexOf(".") >= 0 && (val.length - (val.lastIndexOf(".")+1)>2 ) ) {
            alert("Field '"+fldArray[fldLabel]+"' aantal decimalen foutief!");return false;
         } 		
    	 break;
   }
   return true;
}

function giveFocus(tabnum, fldN, showPage) {
  if (tabnum != currentTabNumber) displayTab(tabnum);
  var myform=getTabForm(tabnum);
  var field=myform.elements[fldN];
  var found=false;
  if (field.type.toLowerCase()=='hidden') {
     for (var i=fldN+1; i<myform.elements.length; i++) {
        var ff=myform.elements[i];
        if (ff.type.toLowerCase()!='hidden') {
            field=ff;
            found=true;
            break;
        }
     }
  } else {
    found=true;
  }
  if (found) {
     var typ=field.type.toLowerCase();
     field.blur();
     field.focus();
     if (typ == 'password' || typ == 'text')
          field.select();
  }
}

function chkEmail(a) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (a.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(a) && r2.test(a));
}

function ValidateEmail(email){
	var sEmailMatch = "^[a-zA-Z0-9][-._a-zA-Z0-9]{0,127}@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.*[a-zA-Z]$";
	if (email && email.match(new RegExp(sEmailMatch))){
		return true;
	}
	else if (email == ''){
		return true;
	}else{
		return false;
	}
}

function ValidateURL(URL){
	var sURL = "^(((ht|f)tp(s?))\://)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.\/]+\.[a-zA-Z]{2,6})(\:[0-9]+)*(/($|[a-zA-Z0-9*\.\,\;\?\'\\\+@&%\$#\=~_\-]+))*$";
	if (URL && URL.match(new RegExp(sURL))){
		return true;
	}
	else if (URL == ''){
		return true;
	}else{
		return false;
	}
}

function chkPhone(a) {
  var i = 0;
  var n = a.length;
  var count;
  if (n == 0 || a.charAt(i) != '+') return false;
  for (i = 1, count = 0; i < n; i++) {
    var c = a.charAt(i);
    if (c < '0' || c > '9') {
      if (c != '.') return false;
      break;
    }
    count++;
  }
  if (count == 0 || count > 3) return false;
  for (i++, count = 0; i < n; i++) {
    var c = a.charAt(i);
    if (c < '0' || c > '9') return false;
    count++;
  }
  if (count == 0 || count > 12) return false;
  return true;
}

function chkPhoneAdsl(a) {
   var strError,i,j;       
   var strCount=0;
   var Validno;
   Validno="0123456789/";

   for(i=0;i<a.length;i++){
     if(Validno.indexOf(a.charAt(i))==-1)
       return false;
     else{
       if (a.charAt(i)=="/")  strCount++;
    }
  }

  if( (a.charAt(2)=="/" || a.charAt(3)=="/") && strCount==1)
      return true;
  else
      return false;
  return true;
}

function chkDate(a, checkFuture) {
   if (a.length!=8) return false;
   for (var i=0; i<a.length; i++) {
     var chr=a.charAt(i);
     if (chr<'0' || chr>'9') return false;
   }
   return dateCheck(a, checkFuture);
}

function chkDomainName(d) {
   var validdom=1;
   d = d.toLowerCase();
   if (d.length<2) return false;
   for (var i=0; i<d.length; i++) {
     var chr=d.charAt(i);
     if ((chr<'a' || chr>'z') && (chr<'0' || chr>'9') && (chr!='-')) return false;
   }
   return true;
}

function chkUserid(d) {
   d = d.toLowerCase();
   if ((d.length<2) || (d.length>20)) return false;
   for (var i=0; i<d.length; i++) {
     var chr=d.charAt(i);
     if ((chr<'a' || chr>'z') && (chr<'0' || chr>'9') && (chr!='-') && (chr!='_')) return false;
   }
   return true;
}

function chkNameServer(n) {
   n = n.toLowerCase();
   if (n=='') return true;
   if ((n.charAt(0) == '.') || (n.charAt(n.length-1) == '.') ||
       (n.charAt(0) == '-') || (n.charAt(n.length-1) == '-')) return false;
   var dotcnt=0;
   for (var i=0; i<n.length; i++) {
     var chr=n.charAt(i);
     if ((chr<'a' || chr>'z') && (chr<'0' || chr>'9') && (chr!='-') && (chr!='.'))
        return false;
     if (chr=='.') {
       dotcnt++;
       if ((i!=0) && (n.charAt(i-1)=='.')) return false;
     }
   }
   if (dotcnt==0) return false;
   return true;
}

function chkIP(str) {
	if (str == '') return true;

	var ip4 = new Array( 0, 0, 0, 0 );
	var ip6 = new Array( 0, 0, 0, 0, 0, 0, 0, 0 );

	var pos = 0;
	var ip4Next = 0;
	var ip6Next = 0;
	var ip6Subst = 0;

	var debug = false;

	// parse address parts
	var part = "";

	if (str.length < 2) {
		if (debug) alert("debug info: error 1");
		return false;
	}
	if (str.charAt(0) == ':') {
		if (str.charAt(1) != ':') {
			if (debug) alert("debug info: error 2");
			return false;
		}
		pos++;
	}

	while (pos < str.length) {
		var c = str.charAt(pos);
		while (   (c >= '0' && c <= '9')
		       || (c >= 'a' && c <= 'f')
		       || (c >= 'A' && c <= 'F')) {
			part += c;
			c = str.charAt(++pos);
			if (pos == str.length) break;
		}
		if (pos == str.length) break;
		switch (c) {
			case ':' :
				if (ip6Next == 8 || ip4Next != 0 || part.length > 4) {
					if (debug) alert("debug info: error 4");
					return false;
				}
				if (part.length == 0) {
					if (ip6Subst != 0) {
						if (debug) alert("debug info: error 5");
						return false;
					}
					ip6Subst = ++ip6Next;
				}
				else {
					ip6[ip6Next++] = parseInt(part, 16);
				}
				part = "";
				break;
			case '.' :
				if (ip6Next > 6 || ip4Next == 4 || part.length == 0) {
					if (debug) alert("debug info: error 6");
					return false;
				}
				for (var i = 0; i < part.length; i++) {
					if (part.charAt(i) < '0' || part.charAt(i) > '9') {
						if (debug) alert("debug info: error 7");
						return false;
					}
				}
				if (part.length > 1 && part.charAt(0) == '0') return false;
				ip4[ip4Next] = parseInt(part, 10);
				if (ip4[ip4Next++] > 255) {
					if (debug) alert("debug info: error 8");
					return false;
				}
				part = "";
				break;
			default :
				if (debug) alert("debug info: error 9 (char " + c + " at pos " + pos + ")");
				return false;
		}
		pos++;
	}

	if (part.length == 0) {
		if (ip6Next == 8 || ip4Next != 0 || (ip6Subst != 0 && ip6Subst != ip6Next)) {
			if (debug) alert("debug info: error 10");
			return false;
		}
		ip6Next++;
	}
	else {
		if (ip4Next == 0) {
			if (ip6Next == 8) {
				if (debug) alert("debug info: error 11");
				return false;
			}
			ip6[ip6Next++] = parseInt(part, 16);
			if (ip6Subst == 0) {
				if (ip6Next != 8) {
					if (debug) alert("debug info: error 12");
					return false;
				}
			}
			else {
				var delta = 8 - ip6Next;
				if (delta != 0) {
					for (var i = ip6Next - 1; i >= ip6Subst; i--) {
						ip6[i + delta] = ip6[i];
						ip6[i] = 0;
					}
				}
			}
		}
		else {
			if (ip6Next > 6 || ip4Next != 3) {
				if (debug) alert("debug info: error 13");
				return false;
			}
			for (var i = 0; i < part.length; i++) {
				if (part.charAt(i) < '0' || part.charAt(i) > '9') {
					if (debug) alert("debug info: error 14");
					return false;
				}
			}
			if (part.length > 1 && part.charAt(0) == '0') return false;
			ip4[ip4Next] = parseInt(part, 10);
			if (ip4[ip4Next++] > 255) {
				if (debug) alert("debug info: error 15");
				return false;
			}
			ip6[6] = ip4[0]*256 + ip4[1];
			ip6[7] = ip4[2]*256 + ip4[3];
			if (ip6Next != 0 && ip6Subst != 0) {
				var delta = 6 - ip6Next;
				if (delta != 0) {
					for (var i = ip6Next - 1; i >= ip6Subst; i--) {
						ip6[i + delta] = ip6[i];
						ip6[i] = 0;
					}
				}
			}
		}
	}

	if (debug) {
		var type = (ip6Next == 0 ? "IPv4" : "IPv6");
		var formatted = ip6[0].toString(16);
		for (var i = 1; i < 8; i++) {
			formatted += ":" + ip6[i].toString(16);
		}
		alert("debug info: " + type + " " + formatted);
	}

	// check for valid IP addresses
	if (ip6[0] != 0x000) {
		// IPv6 unicast addresses assigned by IANA
		if (ip6[0] < 0x2000 || ip6[0] >= 0x4000) {
			if (debug) alert("debug info: error 16");
			return false;
		}
	}
	else {
		// unspecified address, loopback address, embedded IPv4
		for (var i = 1; i < 5; i++) {
			if (ip6[i] != 0x0000) {
				if (debug) alert("debug info: error 17");
				return false;
			}
		}
		if (ip6[5] == 0x0000 && ip6[6] == 0x0000 && (ip6[7] == 0x0000 || ip6[7] == 0x0001)) {
			if (debug) alert("debug info: error 18");
			return false;
		}
		if (ip6[5] != 0x0000 && ip6[5] != 0xFFFF) {
			if (debug) alert("debug info: error 19");
			return false;
		}
		if (ip6[6] >= 127 * 0x0100 && ip6[6] < 128 * 0x0100) {
			if (debug) alert("debug info: error 20");
			return false; // 127.*.*.*
		}
		if (ip6[6] >=  10 * 0x0100 && ip6[6] <  11 * 0x0100) {
			if (debug) alert("debug info: error 21");
			return false; // 10.*.*.*
		}
		if (ip6[6] == 172 * 0x0100 +  31) {
			if (debug) alert("debug info: error 22");
			return false; // 172.31.*.*
		}
		if (ip6[6] == 192 * 0x0100 + 168) {
			if (debug) alert("debug info: error 23");
			return false; // 192.168.*.*
		}
	}
	return true;
}

function doTX() {
  if (!checkValues(currentTabNumber)) return; 
  for (var i=1; i<=forms.length; i++) {
    //if(checkforms[i-1][1]==1)
    	if (!checkValues(i)) return;
  }
  if (!transactionCheck()) return;
  mkForm();
  return;
}



function dateCheck(dateArg,checkFuture) {
  var strDay, strMonth, strYear;
  var intDay, intMonth, intYear;

  strYear = dateArg.substr(0, 4);
  strMonth = dateArg.substr(4, 2);
  strDay = dateArg.substr(6);

  intDay = parseInt(strDay, 10);
  if (isNaN(intDay)) return false;

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) return false;

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear))  return false;

  if (intMonth>12 || intMonth<1) return false;

  if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intDay > 31 || intDay < 1)) return false;

  if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30 || intDay < 1)) return false;

  if (intMonth == 2) {
    if (intDay < 1) return false;
    if (LeapYear(intYear) == true) {
      if (intDay > 29) return false;
    } else {
      if (intDay > 28) return false;
    }
  }

  if (checkFuture == true) {
    var today = new Date();
    today.setHours(0);
    today.setMinutes(0);
    today.setSeconds(0);
    today.setMilliseconds(0);
    var value = new Date(intYear, intMonth - 1, intDay, 0, 0, 0, 0);
    if (value.getTime() < today.getTime()) {
      return false;
    }
  }

  return true;
}

function LeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) return true;
  } else {
     if ((intYear % 4) == 0) return true;
  }
  return false;
}

function checkAlias() {
  var a = document.searchform.al.value;
  var na = '';
  for(var i=0; i<a.length; i++){
    if(a.charCodeAt(i)>32) na+=a.charAt(i);
  }
  var re = new RegExp("^[a-zA-Z]+[0-9]+$");
  if ( re.test(na) ) {
    return true;
  } else {
    alert("Alias should be letter(s) followed by number(s)");
    return false;
  }
}

function checkNameserver() {
  var ns = document.searchform.ns.value;
  if (!chkNameServer(ns)) {
    alert("Input field contains no valid nameserver!");
    return false;
  } else {
    return true;
  }
}

function checkSubtext() {
  var s = document.searchform.na.value;
  var ns = '';
  for(var i=0; i<s.length; i++) {
    if(s.charCodeAt(i)>32) ns += s.charAt(i);
  }
  var re = new RegExp("^[a-zA-Z0-9\\.\\%\\-]{2,}$");
  if ( re.test(ns) ) {
    return true;
  } else {
    alert("Letter(s), number(s), point(.) and % are the only characters allowed");
    return false;
  }
}

function checkYear() {
  var s = document.searchform.ye.value;
  var rs = new RegExp("^[0-9]{4,4}$");
  if ( (rs.test(s)) && (s>2000) && (s<2100)){
    return true;
  } else {
    alert("Year must be 4 numbers between 2000 and 2100");
    return false;
  }
}

function collectFieldValues(f, t) {
  var s='';
  for (j=0; j<f.length; j++) {
	s+=f[j][fldName]+":"+getValue(t,f[j][fldName])+'\n';
  }
  return s;
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

function CopyContact(tabnumFrom ,tabnumTo )
{
	f1=getTabForm(tabnumFrom);f=forms[(tabnumFrom-1)];
	n1=getTabForm(tabnumTo);n=forms[(tabnumTo-1)];
	for (j=0; j<f.length; j++) {
		document.forms[n1.name].elements[n[(j+1)][fldName]].value = getValue(f1,f[j][fldName]);
	}
}

function SetValueTo(tabnum ,veld, waarde, extra )
{
	f1=getTabForm(tabnum);f=forms[(tabnum-1)];
	for (j=0; j<f.length; j++) {		
		if(f[(j)][fldName] == veld ){ 
			alert("Changing Field '" + f[(j)][fldLabel] + "' To: '" + (extra?extra:waarde) + "'");
			document.forms[f1.name].elements[f[(j)][fldName]].value = waarde;
		}
	}
}
