function CompareEmails( email, email_confirm, id_for_result ) {

	// this function may be called when the person fills in the email or the comparison email.
	// if this function is called when the person fills in the comparison email, then we need to 
	// compare to the first email.
	// if this function is called when the person fills in the first email, then we only want to
	// compare to the comparison email if the person has already entered something in the 
	// comparison email.
	
	email.value = email.value.replace(/^\s+|\s+$/g, '') ; // trim
	email_confirm.value = email_confirm.value.replace(/^\s+|\s+$/g, '') ;	// trim
	
	
	if (email_confirm.value!='') 
		// i.e. if the confirmation email has been filled out, then we need to do the comparison
		if ( email.value == email_confirm.value )
			document.getElementById(id_for_result).innerHTML = '&nbsp;';
		else
			document.getElementById(id_for_result).innerHTML = 'Email addresses do not match.';
		
}

