var StringUtils = {
	
	isEmail: function (str) {
		var emailRegex = 
		   new RegExp(
		   '([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})',
		   "gi");
		return emailRegex.test(str);
	},
	
	wrapURLs : function (text) {
	
		var emailRegex = 
		   new RegExp(
		   '([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})',
		   "gi");

//		var urlRegex = 
//		   new RegExp(
//		   '((https?://)' +
//		   '?(([0-9a-z_!~*\'().&=+$%-]+: )?[0-9a-z_!~*\'().&=+$%-]+@)?' + //user@ 
//		   '(([0-9]{1,3}\.){3}[0-9]{1,3}' + // IP- 199.194.52.184 
//		   '|' + // allows either IP or domain 
//		   '([0-9a-z_!~*\'()-]+\.)*' + // tertiary domain(s)- www. 
//		   '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.' + // second level domain 
//		   '[a-z]{2,6})' + // first level domain- .com or .museum 
//		   '(:[0-9]{1,4})?' + // port number- :80 
//		   '((/?)|' + // a slash isn't required if there is no file name 
//		   '(/[0-9a-z_!~*\'().;?:@&=+$,%#-]+)+/?))',
//		   "gi");
		
		var urlRegex = new RegExp('((http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*)', "gi");

		var urlRegexNoProtocol = new RegExp(
			//'"{0}'+		// not already wrapped to href
		   '((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])'// +
		   //'"{0}',
		   ,
		   "gi");
		
		text = text.replace(emailRegex, "<a href=\"mailto:$1\" target=\"_blank\">$1</a>");
		//text = text.replace(urlRegex, "<a href=\"$1\" target=\"_blank\">$1</a>");
		text = text.replace(urlRegexNoProtocol, "<a href=\"$1\" target=\"_blank\">$1</a>");
		text = text.replace("<a href=\"www.", "<a href=\"http://www.");

		
		return text;
		
	}
		
};
