// JavaScript Document
function check(email, telefoonnummer, welke)
{
	var mail = false;
	
	if(welke == 1)
	{
		mail = /^(\w+\.)*([\w-]+)@([\w-]+\.)+([a-zA-Z]{2,4})$/.test(email);
	}else
	if(welke == 2)
	{
		pattern = new RegExp ('^[0-9]{0,8}\-[0-9]{0,8}$','');
		match = pattern.test (telefoonnummer);
		if (match)
			mail = true;
	}
	return mail;
}

function checkChangeContact(form)
{
	var fouten = "The following error(s) were found:\n\n";
	var fout = false;
	  /* 
	if (form.name.value == "")
	{
        fout = true;
        fouten = fouten + "The name is missing\n";
    }
 
   if (form.cell.value == "")
    {
        fout = true;
        fouten = fouten + "The cell phone nr is missing\n";        
    } else
    if(!check(form.email.value, form.cell.value, 2))
    {
        fout = true;
        fouten = fouten + "The cell phone nr is incorrect\n";
    }
    
    if (form.phone.value == "")
    {
        fout = true;
        fouten = fouten + "The phone nr is missing\n";        
    } else    
    if(!check(form.email.value, form.phone.value, 2))
    {
        fout = true;
        fouten = fouten + "The phone nr is incorrect\n";
    }
    */
    if (form.email.value == "")
             {
               
             } 
    else {
   
    if(!check(form.email.value, form.phone.value, 1))
       {
            fout = true;
            fouten = fouten + "The email addresss is incorrect\n";
       }
    }
	if (fout)
		alert(fouten);
	else
		form.submit();
}

