function toForm(){
document.card.recip_name.focus();
}
//het geheim zit in nul, is geen value

function check_email (e){
		var i, j, l = e.length;
		var foundPoint = false;

		function checkChars (s, i, l) 
		{
			while (i < l && ("_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789").indexOf(s.charAt(i)) != -1)
			{
				i++;
			}
			return i;
		}
		function checkFirstLevelDomainChars (s, i, l) {
			while (i < l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(s.charAt(i)) != -1) 
			{
				i++;
			}
			return (i == l);
		}
		//trace(e);

		// every email starts with a string
		if ((i=checkChars(e, 0, l)) == 0) {
			return 0;
		}
		//init j
		j=i;

		// followed by an arbitrary number of ("." string) combinations
		while (i < l && e.charAt(i) == ".") {
			// skip the point
			i++;
			// if there are no chars, we have an error
			if ((j=checkChars(e, i, l)) == i) {
				return 0;
			}
			// else skip the chars
			i = j;
		}
		// then follows the magic @
		if (e.charAt(i) != "@"){
			return 0;
		}

		// followed by minimum one string point string
		// after the last point minimum 2 characters are allowed

		do {
			// skip the @ (j == i at the beginning, so it is like i++)
			i = j+1;
			// do we have more chars ?
			j = checkChars(e, i, l);
			if (j == i) {
				// no more chars found -> error
				return 0;
			} else if (j == e.length) {
				// emailaddress is finished, do we have a first level domain ?
				j -= i;
				// we have one if it is at least 2 long and consists of the correct characters
				if(foundPoint && j>=2 && checkFirstLevelDomainChars(e, i, l)){
					return 1;
				} else {
					return 0;
				}
			}
			// if we reach the end or don't have a point, we return an error
			foundPoint = (e.charAt(j) == ".");
		} while (i < l && foundPoint);
		return 0;
}

function worteltest() { // f is the form (passed using the this keyword)
	if (document.card.recip_name.value == "" )

	      {
	      // zo niet, laat een melding zien:
	       alert ("\r Je hebt geen naam ingevuld");
	document.card.recip_name.focus();
	document.card.recip_name.select();

	      // voorkomen dat het formulier verzonden wordt:
	      return false;
	 } 

	if (document.card.recip_email.value == "" )

	      {
	      // laat een melding zien:
	       alert ("\r Er is niets ingevuld bij het email adres van de ontvanger...");
	document.card.recip_email.focus();
	document.card.recip_email.select();


	      // voorkomen dat het formulier verzonden wordt:
	      return false;
	 }
	// check the first email address ( the exclamation means "not" )
	if(!check_email(document.card.recip_email.value)){
	alert ("\r Er is iets mis met het email adres van de ontvanger");
	document.card.recip_email.focus();
	document.card.recip_email.select(); 
	// if the browser is Netscape 6 or IE
	if(document.all || document.getElementByID){
	// change the color of text field
	document.card.recip_email.style.background = "yellow";
	}
	// make sure the form is not submitted
	return false;
	}

	if (document.card.sender_name.value == "" )

	      {
	      // zo niet, laat een melding zien:
	       alert ("\r Je hebt geen afzender ingevuld");
	document.card.sender_name.focus();
	document.card.sender_name.select();

	      // voorkomen dat het formulier verzonden wordt:
	      return false;
	 } 


	if (document.card.sender_email.value == "" )

	      {
	      // laat een melding zien:
	       alert ("\r Niets ingevuld bij je eigen email adres?");
	document.card.sender_email.focus();
	document.card.sender_email.select();


	      // voorkomen dat het formulier verzonden wordt:
	      return false;
	 }	



// check the second email address
if(!check_email(document.card.sender_email.value)){
alert ("\r Er is iets mis met dit e-mail adres");
document.card.sender_email.focus(); 
document.card.sender_email.select();
if(document.all || document.getElementByID){
document.card.sender_email.style.background = "yellow";
}
return false;
}
}

