function name_preview(element,name,rooturl)
{
	if(name)
	{
		if( name.search(/[;,]/) >= 0 )
		{
			element.value = name.replace(/[,;]/, "")
			alert('Sorry, no commas or semicolons are allowed.')
			return
		}
		instructblk = $('guidelines_block')
		feedblk     = $('feedback_block')
		shortname   = name.replace(/[^A-Za-z0-9]/g, "")
		if(shortname.length >= 3)
		{
			if( feedblk.style.display == 'none' ){
				if( instructblk ){instructblk.visualEffect("blind_up", {duration:0.8})}
				feedblk.visualEffect("blind_down", {duration:0.5})
			}
			$('displayname').innerHTML  = name
			$('homepage').innerHTML     = rooturl + '<strong>' + shortname.toLowerCase() + '</strong>';
		}
		else
		{
			$('displayname').innerHTML  = '...'
			$('homepage').innerHTML     = '(User name too short)';
		}
	}
	else
	{
		feedblk.visualEffect("blind_up", {duration:0.3})
		instructblk.visualEffect("blind_down", {duration:0.3})
	}
}

// Lee, 11/7/2007
// I didn't implement all the rules here, such as the consecutive period rule for Gmail.
// Note that I only deal with the non-local part (the part before any +)
// 
// Yahoo:
// Use 4 to 32 characters and start with a letter. You may use letters, numbers, underscores, and one dot (.).
// 
// AOL
// 3-16 letters or numbers. It must start with a letter.
// 
// Gmail
// Sorry, only letters (a-z), numbers (0-9), and periods (.) are allowed.
// Sorry, the first character of your username must be an ascii letter (a-z) or number (0-9).
// Sorry, your username cannot contain consecutive periods (.)
// Sorry, your username must be between 6 and 30 characters long.

function isValidEmail(address)
{
	ok = true;
	nonlocal = /^[^@\+]+/;

	if (address.match("@yahoo\.com$"))
	{
		part = address.match(nonlocal);
		ok = /^[a-z][a-z0-9_\.]{3,31}$/i.test(part);
	}
	else if (address.match("@aol\.com$"))
	{
		part = address.match(nonlocal);
		ok = /^[a-z][a-z0-9]{2,15}$/i.test(part);
	}
	else if (address.match("@gmail\.com$"))
	{
		part = address.match(nonlocal);
		ok = /^[a-z0-9][a-z0-9\.]{5,29}$/i.test(part);
	}
	else
	{
		// Just make sure there are no illegal characters
		part = address.match(nonlocal);
		ok = /^[^\(\)\[\]\<\>\,\;\:\\\" ]+$/.test(part);
	}

	return ok;
}

function validateEmail()
{
	// If we can't find the field, let it slide
	if ($('end_user_email_address') == null)
		return true;

	address = $('end_user_email_address').value
	ok = isValidEmail(address);
	if (ok && (/^www/.test(address)))
	{
		ok = confirm('"' + address + '" begins with www. \nGenerally, this in invalid. \nAre you sure you want to use this email address?');
	}
	else if (!ok) 
	{
		ok = confirm('"' + address + '" doesn\'t appear to be a valid email address. \nAre you sure you want to use this email address?');
	}
	return ok;
}
