// Ensure that the object contains a phone number in the format we require
// a blank field is considered okay

function validPhone(phoneNumber)
{
	// var phoneFormat = /^\d{3}-\d{3}-\d{4}$/;
	var phoneFormat = /^((\+\d{1,3}(\/|\.|-| )?\(?\d\)?(\/|\.|-| )?\d{1,5})|(\(?\d{2,6}\)?))(\/|\.|-| )?(\d{3,4})(\/|\.|-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
	
	var tmp = '';
	if (typeof(phoneNumber) == 'object')
		tmp = String(phoneNumber.value);
	else
		tmp = String(phoneNumber); // stick it into a temporary variable so we can manipulate it
	tmp = tmp.replace(/\s+$/, ''); // remove trailing spaces as they confuse things
	
	if (tmp.length != 0) // do we have input ?
	{
		if (tmp.search(phoneFormat) == -1) // did we get a match ?
			return (false); // nope
	}
	return (true);
}