/* xlation.js */

/**
 * Class XlationTable
 * Holds and returns translation of key-data to user-readable strings.
 */
function XlationTable(){
	this.data = new Array();
	this.add = function(sKey, sLabel){
		this.data[this.data.length] = new Array(sKey, sLabel);
	}
	this.get = function(sKey){
		for(var iX = 0; iX < this.data.length; iX++){
			if(this.data[iX][0] == sKey){
				return this.data[iX][1];
			}
		}
		// If the method has run to here, the var was not found, try parent
		var iUnderscorePos = sKey.lastIndexOf("_");
		if(iUnderscorePos != -1){
			var sKeyParent = sKey.substring(0, iUnderscorePos);
			for(var iX = 0; iX < this.data.length; iX++){
				if(this.data[iX][0] == sKeyParent){
					return this.data[iX][1];
				}
			}
		}
		return sKey;
	}
	this.getLowerCase = function(sKey){
		return this.get(sKey).toLowerCase();
	}
	this.getLeadUpperCase = function(sKey){
		var sOut = this.get(sKey);
		if(sOut.length < 2){
			sOut = sOut.toUpperCase();
		}
		return sOut.substring(0, 1).toUpperCase() + sOut.substring(1);
	}
}