//-------------------------------------------------------
/** 
 *  TC = Type C namespace
 */
if(window["TC"] == null){
	TC = {};
}
//-------------------------------------------------------
TC.UserMedals = Class.create();
/**
 * Normal  Ranking: 0 = best 1 = last
 * Reverse Ranking: 1 = best 0 = last
 **/
TC.UserMedals.reverseRanking = true;
/**
 * Array of all medal-levels
 **/
TC.UserMedals.All = [];
/**
 * adds a new ranking level
 *
 * @param {double} sImg
 * a number between 0 to 1 that ranks level of users in comparison to 
 * thier community
 *
 * @param {string} sImg
 * Relative path to the user-medal image
 **/
TC.UserMedals.addRankingLevel = function(dblRanking, sImg){
	var oLevel = new TC.UserMedals(dblRanking, sImg)
	this.All[this.All.length] = oLevel;
	this.All.sort();
}
/**
 * Returns the Ranking Level by the user ranking
 *
 * @param {double} dblRanking
 * The ranking of the user
 **/
TC.UserMedals.getMedalByRanking = function(dblRanking){
	var i;

	if (this.reverseRanking)
	    dblRanking = 1 - dblRanking;

	for(i = 0; i < this.All.length; i++)
		if (dblRanking <= this.All[i].ranking)
			return this.All[i];
}
/**
 *@private
 * Constructor of Ranking-Level object
 *
 * @param {double} dblRanking
 * @param {string} sImg
 * The ranking of the user
 **/
TC.UserMedals.prototype.initialize = function(dblRanking, sImg){
	this.img = sImg;
	this.ranking = dblRanking;
}
/**
 * @private
 * override of  Object.toString(), for the Array.sort()
 **/
TC.UserMedals.prototype.toString = function(){
	return this.ranking;
}
/**
 * MpRanking class stores the images of the ranking levels for the mp
 **/
TC.MpRanking = Class.create();
/**
 * Array of all ranking-levels
 **/
TC.MpRanking.All = [];
/**
 * Holds the maximum upper bound for the ranking (2000+)
 */
TC.MpRanking.MaximumRanking = {};
/**
 *@private
 * Constructor of Ranking-Level object
 *
 * @param {integer} score
 * @param {string} image
 * The ranking of the user
 **/
TC.MpRanking.prototype.initialize = function(score, image){
	this.score = score;
	this.image = image;
}
/**
 * adds a new ranking level for multiplayer game
 *
 * @param {integer} score
 * @param {string} image
 **/
TC.MpRanking.addRankingLevel = function(score, image){
	var oLevel = new TC.MpRanking(score,image);
	this.All[this.All.length] = oLevel;
}
/**
 * adds a the upper bound ranking level for multiplayer game
 *
 * @param {integer} score
 * @param {string} image
 **/
TC.MpRanking.addMaximumRankingLevel = function(score, image){
	this.MaximumRanking = new TC.MpRanking(score,image);
}
/**
 * Returns the Ranking Level by the user score
 *
 * @param {integer} score
 * The ranking of the user
 **/
TC.MpRanking.getMpRankingByScore = function(score){
	for(var i=0;i<this.All.length;i++){
		if(score<=this.All[i].score)
			return this.All[i];
	}
	if(this.MaximumRanking && score>=this.MaximumRanking.score)
		return this.MaximumRanking;
	return null;	
}
