/**
The Camel Case function capitalizes any letter following a space and sets all other characters to lowercase.
@customFunction
*/
function CAMELCASE(value) {
// TRIM VALUE
value = value.trim();
// SPLIT VALUE INTO ARRAY OF CHARACTERS
var splitString = value.split('');
// CAPITALIZE FIRST CHARACTER
try {
splitString[0] = splitString[0].toUpperCase();
} catch(e) {}
var prevChar = '';
for (var i = 1; i < splitString.length; i++) {
// CAPITALIZE CHARACTERS AFTER SPACES
if (prevChar == ' ') {
try {
splitString[i] = splitString[i].toUpperCase();
} catch(e) {}
}
// SET ALL OTHER CHARACTERS TO LOWER CASE
else {
try {
splitString[i] = splitString[i].toLowerCase();
} catch(e) {}
}
var prevChar = splitString[i];
}
// MERGE VALUE ARRAY
var mergeString = splitString.join('');
return mergeString;
}