/**********************************************************
 * utils.js
 *
 * Stuart Connolly
 * http://stuconnolly.com/
 *
 * Copyright (c) 2009 Stuart Connolly. All rights reserved.
 **********************************************************/
 
/**
 * Trim function from http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256C0C0062AC78
 */
function trim(value) 
{    
	var temp = value;

	var obj = /^(\s*)([\W\w]*)(\b\s*$)/;

	if (obj.test(temp)) { 
		temp = temp.replace(obj, '$2'); 
	}

	var obj = /  /g;

	while (temp.match(obj)) { 
		temp = temp.replace(obj, " "); 
	}

	return temp;
}

/**
 * Checks if the supplied email address is valid.
 */
function validateEmailAddress(emailAddress) 
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	return reg.test(emailAddress);
}
