/*
 ==================
 Manager singleton
 ==================
 */
var GameManager = (function(){
	var _instance;
			var init = function() {
				var _selectedLevel = SS.LEVELS.LEVEL_61;
				var _gameState = SS.GAME_STATE.MENU;
				var _gameMode = SS.GAME_MODE.HARDCORE;
				var _roundsCount = null;
				var _currentRound = _selectedLevel.Rounds.Round_1;
				
						var _setSelectedLevel = function (level) {
						
									_selectedLevel = level;
						};
						
						var _getSelectedLevel = function () {
							return _selectedLevel;
						};
						
						var _setGameMode = function (s) {
							_gameMode = s;
							if(_gameMode == SS.GAME_MODE.HARDCORE){
								_currentRound = _selectedLevel.Rounds.Round_1;
								_roundsCount = _selectedLevel.RoundNum;
							}
						};
					
						var _getGameMode = function () {
							return _gameMode;
						};
						
						var _getCurrentRound = function () {
							return _currentRound;
						};
						
						var _setNextRound = function (s) {
							for(var it in _selectedLevel.Rounds){
								if(  (_currentRound.ID)+1 == _selectedLevel.Rounds[it].ID){
									_currentRound = _selectedLevel.Rounds[it];
									return true;
								}
									
							}
							return false;							
						};
						
						var _getRoundsCount = function () {
							return _roundsCount;
						};
						
						var _setGameState = function (gameState) {
							_gameState = gameState;
						};
						
						var _getGameState = function () {
							return _gameState;
						};
						
						return {
							setSelectedLevel:_setSelectedLevel,
							setNextRound:_setNextRound,
							setGameMode:_setGameMode,
							getSelectedLevel:_getSelectedLevel,
							getGameMode:_getGameMode,
							getCurrentRound:_getCurrentRound,
							getRoundsCount:_getRoundsCount,
							getGameState:_getGameState,
							setGameState:_setGameState
						};
			};
			return {
				getInstance: function () {
					if (!_instance) {
						_instance = init();
					}
					return _instance;
					}
			};	
})();