var CHAMBERMANAGER = {
	ui: {}
};

// Source: http://stackoverflow.com/questions/1588521/how-to-limit-the-size-of-an-html-textarea-with-javascript
CHAMBERMANAGER.ui.limitFieldLength = function(textarea, limit, infoDiv) {
	var textarea = $('#' + textarea);
	var infoDiv = $('#' + infoDiv);
	var text = textarea.val(); 
	var textLength = text.length;
	var charsLeft = limit - textLength;
	var parentDiv = infoDiv.parent('div');
	
	if (charsLeft <= 0) {
		infoDiv.html(0);
		textarea.val(text.substr(0, limit));
		parentDiv.css('color', '#FF0000');
		return false;
	} else {
		infoDiv.html(charsLeft);
		parentDiv.css('color', null);
		return true;
	}
};
