/**
 * Formatação automática de texto preenchido
 */
function formatNames(){
	var obj = $.browser ? $(this) : jQuery(this);
	(function($) {
		if($(obj).val().length > 0) {
			var arrVal = new Array();
			var newVal = "";
			arrVal = $(obj).val().split(" ");
			for(x in arrVal) {
				if(typeof arrVal[x] == "string") {
					if(newVal != "") newVal += " ";
					if(arrVal[x].toLowerCase().match(/^d[oae]s?$/)) {
						newVal += arrVal[x].toLowerCase();
					} else {
						newVal += arrVal[x].substr(0,1).toUpperCase() + arrVal[x].substr(1).toLowerCase();
					}
				}
			}
			if($(obj).val() != newVal) {
				var bgColor = $(obj).css("backgroundColor");
				$(obj).css("backgroundColor", "#FFF8AF");
				setTimeout(function(){$(obj).val(newVal);}, 100);
				setTimeout(function(){$(obj).css("backgroundColor", bgColor);}, 500);
			}
			
		}
		
	})(jQuery);
}
