useGrafikpfad = 'images/shared/gbg/grafikpack-full';
useGrafikpfadLang = 'images/en/gbg/grafikpack-full';

var I18N = {
	'wordTable' : {
		'noObjInFrontOfAds' : 'Bitte die das Objekt nicht vor die Werbung schieben - auch DL braucht Werbung :/',
		'tavernTableEmpty' : 'Tisch {0} ist unbesetzt!',
		'tavernTableInfo' : 'Tischinfo',
		'tavernTableWithId' : 'Tisch {0}',
  		'DECIMAL_POINT' : '.',
  		'THOUSANDS_SEP' : ',',
  		'SECOND' : ['Second', 'Seconds'],
  		'MINUTE' : ['minute', 'minutes'],
  		'HOUR' : ['hour', 'hours'],
  		'DAY' : ['day', 'days'],
  		'ABORT' : 'Abort',
  		'AREANAME_0' : 'Ocean',
  		'AREANAME_7' : 'Whisper Wood',
  		'AREANAME_8' : 'Splinter Plain',
  		'AREANAME_9' : 'Nag\'rd Nöj',
  		'AREANAME_10' : 'Light Grove',
  		'AREANAME_11' : 'Emerald Valleys',
  		'AREANAME_12' : 'Land of Damagra',
  		'AREANAME_13' : 'Moderia',
  		'AREANAME_14' : 'Sing Dessert',
  		'AREANAME_15' : 'Glastal',
  		'HIRE_PACK_QUESTION' : 'Do you really want to hire this pack \'{0}\'?',
  		'JS_NO_MONSTERS_ON_FIELD' : 'No monster',
  		'JS_MONSTER_DISPLAY_DEACTIVATED' : 'Monster display deactivated',
  		'QUEUE_ENTRY_READY' : 'Ready',
		'BUILDING_PLACEMENT_INFO' : 'Locate the building in the desired location in your settlement. By left-clicking, the construction will begin.[color=tomato]Green areas will be removed after having located the building; red areas cannot be removed.[/color] If you don\'t want to construct the building, close this window.',
		'INFO_MENU_HH' : 'Buildings',
		'INFO_MENU_BIBO' : 'Library',
		'INFO_MENU_TEMPEL' : 'Temple',
		'INFO_MENU_HEXE' : 'Laboratory',
		'INFO_MENU_KASERNE' : 'Barracks',
		'INFO_MENU_FRIEDHOF' : 'Graveyard',
		'INFO_MENU_DRACHENHOF' : 'Dragon Yard',
		'INFO_MENU_SCHATTENPORTAL' : 'Shadowportal',
		'INFO_MENU_VERTEIDIGUNG' : 'Defense',
		'INFO_MENU_MARKT' : 'Marketplace',
		'INFO_MENU_HANDEL' : 'Trade',
		'INFO_MENU_WAPPEN' : 'Coat of arms',
		'INFO_MENU_TRUPPEN' : 'Troops',
		'INFO_MENU_EINHEITEN' : 'Units',
		'INFO_MENU_KARTE' : 'Map',
		'INFO_MENU_AREA' : 'Areas',
		'INFO_MENU_GRUPPE' : 'Guild',
		'INFO_MENU_KRIEG' : 'Wars',
		'INFO_MENU_TOPLIST1' : 'Toplist 1',
		'INFO_MENU_TOPLIST2' : 'Toplist 2',
		'INFO_MENU_TOPLIST3' : 'Toplist 3',
		'INFO_MENU_TOPLISTG' : 'Guild Toplist',
		'INFO_MENU_IGM' : 'Messages',
		'INFO_MENU_HILFE' : 'Help',
		'INFO_MENU_SONSTIGES' : 'Other',
		'INFO_MENU_TAVERN' : 'Tavern',
		'INFO_MENU_COMMITMENT' : 'Surveys',
		'INFO_MENU_TOURNEY' : 'Tournaments',
		'INFO_MENU_SETTLESHOP' : 'Settleshop',
		'INFO_MENU_JUICESHOP' : 'Bazaar',
		'INFO_MENU_QUESTBUILDING1' : 'INFO_MENU_QUESTBUILDING1',
		'INFO_MENU_FORUM' : 'Discussion board',
		'GTYPE_ANARCHIE_BONUS' : 'When anarchy rules random guild mails are sent two times a month (1. and 15. day) to all guild members. A message informs you about new potential officeholder if any.',
		'GTYPE_SCHATTENBRUT_BONUS' : 'Shadow brood\'s nominations are communicated every day at 4.30 according to the inhabitants number of guild member\'s settlement. The more inhabitants to a settlement, the higher is the role into the guild. Nominations rank from leader to successor, general, minister, witch/wizard.',
		'GTYPE_RITUALISTEN_BONUS' : 'Sacrifices are very important to ritualist. Nominations are based on sacrifice points and delivered every day at 4.30 to all members. The more sacrifice point the higher is the role. Nominations rank from guild leader then decreasing to successor, general, minister and witch/wizard.',
		'GTYPE_JAEGER_SAMMLER_BONUS' : 'The one entitled to take the power is the member who can prove the highest income by hunting or gathering.\nOther officers (successor, general, minister, magician) will get their part backward sorting according to collected resources (every day at 4.30)',
		'MAX_TRADE_DIFF_X' : 'The difference of the value must be maximum {0}% !',
		'TRADE_DIFF_OKAY' : 'ratio of the resource OK!',
		'ORE' : 'Ore',
		'GOLD' : 'Gold',
		'WOOD' : 'Wood',
		'FOOD' : 'Food',
		'SILVER' : 'Silver',
		'DURATION_UNTIL_ENDTIME' : '{0} until {1}',
		'ENTER_TEMPLATE_NAME' : 'Enter template name',
		'YES' : 'Yes',
		'NO' : 'No',
		'MONSTERFIELD_TYPE_0' : 'Mixed',
		'MONSTERFIELD_TYPE_1' : 'Close combat',
		'MONSTERFIELD_TYPE_2' : 'Long-distance battle',
		'MONSTERFIELD_TYPE_3' : 'Fight magic',
		'MONSTERFIELD_TYPE_4' : 'Support magic',
		'MONSTERFIELD_CHALLENGE' : '(Challenge)',
		'SAVE_NOTES' : 'Save notes',
		'CLOSE_NOTES' : 'Close',
		'ITEM_COSTS_POPUP' : 'The item \'{0}\' changes a unit capacity to [b]{1} CP[/b] and you need [b]{2} sacrifice points[/b] in order to equip him. It will cost:\n\n[img]{3}/icons/20x20/erz.gif[/img][b] Ore:[/b] {4} - [img]{3}/icons/20x20/gold.gif[/img][b] Gold:[/b] {5} - [img]{3}/icons/20x20/holz.gif[/img][b] Wood:[/b] {6} - [img]{3}/icons/20x20/nahrung_{7}.gif[/img][b] Food:[/b] {8} - [img]{3}/icons/20x20/silber.gif[/img][b] Silver:[/b] {9}',
		'DO_REPAIR' : 'Repair',
		'REPAIR_MARKET_RES' : 'The following resources are lacking for the [b]repair[/b]:',
		'HEAL_UNITS' : 'Heal units',
		'HEAL_MARKET_RES' : 'The following resources are lacking to [b]heal[/b] your units:',
		'CHANGE_LEADER_CONFIRMATION' : 'Do you really want to appoint [b]{0}[/b] as leader?',
		'MISSING_RES' : 'Missing resources',
		'FACEBOOK_FRIENDLIST' : 'Your friends at Facebook',
		'FB_INVITE_NAME' : 'Battlegrounds - The war calls for you!',
		'FB_INVITE_ACTION_NAME' : 'Become a part of Battlegrounds and fight your own battles!',
		'FB_INVITE_DESC' : 'Tauche in Battlegrounds ein, dem fantastischen Actionstrategiespiel! Züchte Drachen und grauenhafte Dämonen und sichere Dir in dieser nie da gewesenen Mischung aus Action, Strategie und Rollenspiel einen Platz in der Geschichte! Melde Dich sofort an - kostenlos und unverbindlich - und werde Teil dieses ewigen Krieges um Macht und Ruhm.',
		'FB_INVITE' : 'FB_INVITE',
		'MONDAY_SHORT' : 'Mon',
		'TUESDAY_SHORT' : 'Tue',
		'WEDNESDAY_SHORT' : 'Wed',
		'THURSDAY_SHORT' : 'Thu',
		'FRIDAY_SHORT' : 'Fri',
		'SATURDAY_SHORT' : 'Sat',
		'SUNDAY_SHORT' : 'Su',
		'DISTANCE_UNIT_SHORT' : 'km',
		'DISTANCE_UNIT' : 'kilometers',
		'CREATE_DIPLOMACY_BUTTON' : 'Enter',
		'DIPLOMACY_ACCEPT' : 'Accept',
		'DIPLOMACY_REJECT' : 'Refuse',
		'SPEEDUP_NO_QUEUEENTRIES_INFO' : 'SPEEDUP_NO_QUEUEENTRIES_INFO'
	},
	
	/**
	  * Format number according to the locale
	  *
	  * @param theNumber The number to be formatted
	  * @param decimalDigits The number of decimal digits can be passed to this functions, as it is not locale specific. Defaults to 0 decimal digits.
	  */
	'numberFormat' : function(theNumber, decimalDigits) {
		return(number_format(theNumber, decimalDigits, this.wordTable['DECIMAL_POINT'], this.wordTable['THOUSANDS_SEP']));
	},

	/**
	 * Format a duration according to the locale
	 *
	 * @param duration The duration to format
	 * @param showUnit (optional) If the unit shall be displayed, set this to true (default)
	 */
	 'durationFormat' : function(duration, showUnit) {
		if(duration < 60) {
		  multiplier = 1;
		  unitLangId = 'SECOND';
		} else if(duration < 3600) {
		  multiplier = 60;
		  unitLangId = 'MINUTE';
		} else if(duration < 86400) {
		  multiplier = 3600;
		  unitLangId = 'HOUR';
		} else {
		  multiplier = 86400;
		  unitLangId = 'DAY';
		}
		
		durationString = this.numberFormat(duration / multiplier, 1);
		if(durationString.indexOf(this.wordTable['DECIMAL_POINT']) != -1) { // If we have a fractionated number
			durationString = durationString.replace(/0+$/, '');						// Trim right zeroes
			if(durationString.substr(durationString.length - 1, 1) == this.wordTable['DECIMAL_POINT']) durationString = durationString.substr(0, durationString.length - 1);  // If, after trimming zeroes, the decimal point is the end of the string, remove it as well
		}
		return(durationString + (showUnit ? ' ' + this.pluralize(Math.round(duration / multiplier * 10) / 10, unitLangId) : ''));
	},
	
	/**
	  * Function to pluralize a given language object
	  *
	  * @param theNumber The number that we are seeking the plural form for
	  * @param langObjId The language object ID. This must refer to an array of objects inside this internationalization classes word table
	  */
	'pluralize' : function(theNumber, langObjId) {
		if(theNumber != 1) return(this.wordTable[langObjId][1]); // In german, everything with a count of 2 or more uses the plural
		return(this.wordTable[langObjId][0]);			// Otherwise return the singular
	},
	
	/**
	  * Returns a specific string
	  * In contrast to the PHP I18N function, this function is used rarely, only when JS strings have wildcards that must be replaced. Usually, the variables are accessed directly through the word table.
          *
	  * @param varName The variable name of the string
	  * @param params A number indexed array of values. The wildcard {0} in the string is replaced with the value at index 0 etc. If the array is empty, nothing is changed
	  */
	'getSpecificString' : function(varName, params) {
		var varVal = this.wordTable[varName];
		if(typeof(params) != 'undefined' && typeof(params.length) != 'undefined') {
			for(var i = 0, len = params.length; i < len; ++i) {
				var replacer = new RegExp('\\{' + String(i) + '\\}', 'g');
				varVal = varVal.replace(replacer, params[i]);
			}
		}
		return(varVal);
	}


}
