//this function takes a string and trims off any spaces from either end
function trim(what) {
	//make sure the value that was sent is a string
	if (typeof(what) != "string") {
		alert("ERROR: The trim function was sent the following non-string value: " + what + ".");
		return;
	}
	
	//create a regular expression to match the spaces on the right and the left
	var rtrim_regexp = /\s*$/;
	var ltrim_regexp = /^\s*/;
	
	//replace the regular expressions with nothing to trim the spaces
	what = what.replace(ltrim_regexp, "").replace(rtrim_regexp, "");
	
	//return the value of the trimmed string
	return what;
}

//this checks an email for valid format
function IsValidEmailFormat(email) {
	//get the indexes of the main characters
	var indexAt		= email.indexOf("@");
	var indexDot	= email.lastIndexOf(".");
	var indexEnd	= email.length - 1;

	//validate the basics
	if (indexAt > 0 && indexDot > (indexAt + 1) && indexDot < indexEnd) {
		return true;
	}
	else {
		return false;
	}
}