function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}

function isEmail(str) {
	// are regular expressions supported?
	var supported = 0;

	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) {
			supported = 1;
		}
	}
	if (!supported) {
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	}
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function getURLVars() {
	// Check for hash variables as they take precedence over search string variables
	if (window.location.hash.length != 0) {
		var url_vars = window.location.hash;
	// Check for search string variables
	} else if (window.location.search.length != 0) {
		var url_vars = window.location.search;
	// No URL variables exists, so stop processing
	} else {
		return;
	}
	// Remove unnecessary characters
	url_vars = url_vars.replace(/\?/,'');
	url_vars = url_vars.replace(/\#/,'');
	var searchAttributes = url_vars.split('&');
	for (var i=0; i<searchAttributes.length; i++) {
		var items = searchAttributes[i].split('=');
		// Set the variables if they already exist.  If it's not defined, ignore it.
		if ( typeof( window[ items[0] ] ) != "undefined" ) {
			eval(items[0]+" = '"+items[1]+"';");
		}
	}
}

function padDigits(theNum, totalDigits) { 
	theNum = theNum.toString(); 
	var pd = ''; 
	if (totalDigits > theNum.length) { 
		for (i=0; i < (totalDigits-theNum.length); i++) { 
			pd += '0'; 
		} 
	} 
	return pd + theNum.toString(); 
}