	function emailcheck(formulier,field) {
		
		alertBericht="You did not enter a valid email address.";				
		str=eval('document.'+formulier+'.'+field+'.value');
		if( str == "" ){			
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
			cont = false;
		}
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');	
		  alert(alertBericht)
		  return false
		}		
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');				
			alert(alertBericht)
		  return false
		}		
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}		
		if (str.indexOf(at,(lat+1))!=-1){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}		
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}		
		if (str.indexOf(dot,(lat+2))==-1){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}			
		if (str.indexOf(" ")!=-1){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}
		if ( str.substring(str.indexOf(dot)+1,str.indexOf(dot)+3)==""){
			eval('document.'+formulier+'.'+field+'.style.backgroundColor = \'#FFD4D4\'');
		  alert(alertBericht)
		  return false
		}
	 	return true					
	}	
	
	function check( ){
		//RESET FIELD		
		fieldArray = Array("name_send","email_send","friend_name_send","friend_email_send","message");
	
		var cont = true;	
		for(var i in fieldArray){
			eval("document.input."+fieldArray[i]+".style.backgroundColor =  '#ffffff'");				
		}
		
		// EMAIL CHECK				
		cont = emailcheck("input","email_send");
		cont = emailcheck("input","friend_email_send");
	
		
		//TEXT FIELD		
		fieldArray = Array("name_send","email_send","friend_name_send","friend_email_send");
		
		for(var i in fieldArray){
			if( eval("document.input."+fieldArray[i]+".value") == "" ){
				eval("document.input."+fieldArray[i]+".style.backgroundColor =  '#FFD4D4'");
				cont = false;	
			}					
		}			
		
		if(cont==false){
			alert("Please fill in all required fields.");					
		}else{
			document.input.action_name.value = 'sendmail';
			document.input.submit();
		}
	}
