function addUser()
{	
	var Handler		 		= null;
	var Error				= 0;
	var Mail				= 0;
	var errorMsg			= '';

		var str = document.getElementById('email').value
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
	
		if (str.indexOf(at)==-1)   
		{
			Mail++;   
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)  
		{
			Mail++;   
		}
	
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) 
		{
			Mail++;   
		}
	   
		if (str.indexOf(at,(lat+1))!=-1)      
		{
			Mail++;   
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) 
		{
			Mail++;   
		}
	   
		if (str.indexOf(dot,(lat+2))==-1)                 
		{
			Mail++;   
		}
	   
		if (str.indexOf(" ")!=-1) 
		{
			Mail++;   
		}

	var firstname = document.getElementById('firstname').value
	var lastname = document.getElementById('lastname').value
	var address = document.getElementById('address').value
	var postal = document.getElementById('postal').value
	var city = document.getElementById('city').value
	var phone = document.getElementById('phone').value
	
	postal = postal.split(' ').join('');
	
	rExp = /^[1-9]{1}[0-9]{3}[A-Z]{2}$/;

	if ( firstname == '' ) {
	   errorMsg =  "Vul uw voornaam in. \n";
	   Error++;
	}

	else if ( lastname == '' ) {
	   errorMsg = "Vul uw achternaam in. \n";
	   Error++;

	}
	
	else if ( address == '' ) {
	   errorMsg = "Vul uw adres + huisnummer in. \n";
	   Error++;

	}
	
	else if (!rExp.exec(postal)) 
	{
  		errorMsg = 'U heeft het veld postcode niet juist ingevuld.\nVul de postcode in met notatie 1234AB';
		 Error++;
  	}
	
	else if ( postal.length != 6 )
	{
		errorMsg = 'Uw postcode is niet 6 tekens lang';	
		 Error++;
	}

	else if ( postal == '' ) {
	   errorMsg = "Vul uw postcode in. \n";
	   Error++;

	}

	else if ( city == '' ) {
	   errorMsg = "Vul uw woonplaats in. \n";
	   Error++;

	}

	else if (isNaN(parseInt(phone))) {
	   errorMsg = "Er mogen alleen cijfers gevuld worden in de veld 'Telefoon'.";
	   Error++;
	}
		
	
	if ( Error > 0 )
	{
		alert(errorMsg);
	}
	else if ( Mail > 0 )
	{
		alert('Vul uw emailadres correct in!');	
	}
	else
	{
		document.forms['registreren'].action.value = 'addUser';
		document.forms['registreren'].submit();	
	}
	
}


function loginUser()
{	
	document.forms['bevestigen'].action.value = 'confirmOrder';
	document.forms['bevestigen'].submit();
}

function goShipment()
{	
	
	var shipment = document.getElementById('shipment').value;

	if ( shipment == 'ophalen' )
	{
		document.forms['shipment'].action.value = 'ophalen';	
	}
	
	else if ( shipment == 'anders' )
	{
		document.forms['shipment'].action.value = 'anders';	
	}
	
	else 
	{
		document.forms['shipment'].action.value = 'address';	
	}

	document.forms['shipment'].submit();
}

	



