function ValidateNewUser()
    {
	//Adjust fields by removing invalid characters
	document.adduser.email.value=validatedemail(document.adduser.email.value);
	
	//Set up vairables
	var error="";
	
	//Check all fields
	if(document.adduser.email.value=="")
	    {
		error += "Please enter a valid email address.\n";
		}
	if(document.adduser.name.value=="")
	    {
		error += "Please enter your name.\n";
		}
    if(document.adduser.address.value=="")
	    {
		error += "Please enter your address.\n";
		}
    if(document.adduser.town.value=="")
	    {
		error += "Please enter your town or city.\n";
		}
    if(document.adduser.county.value=="")
	    {
		error += "Please enter your county, province or state.\n";
		}
    if(document.adduser.postcode.value=="")
	    {
		error += "Please enter your postcode or zip code.\n";
		}
    if(document.adduser.password.value==""||document.adduser.passwordcheck.value=="")
	    {
		error += "Please enter a password (in both boxes).\n";
		} else {
		if(document.adduser.password.value!=document.adduser.passwordcheck.value)
			{
			error += "Your passwords don't match, please check.\n";
			}
		}
		
    //Validate the submittion and flag errors if applicable
	if(error=="")
	    {
		//valid - sumit
		document.adduser.submit();
		} else {
		//invalid - flag errors
		alert("You have the following errors, please check and re-try:-\n\n"+error);
		}
		
	}
	
function validatednum(string)
    {
    for (var i=0, output='', valid="1234567890"; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
    output += string.charAt(i)
    return output;
	} 
	
function validatedalpha(string)
    {
    for (var i=0, output='', valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
    output += string.charAt(i)
    return output;
	}
	
function validatedemail(string)
    {
    for (var i=0, output='', valid="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-@"; i<string.length; i++)
    if (valid.indexOf(string.charAt(i)) != -1)
    output += string.charAt(i)
    return output;
	}
	


