var I18NManager = (function(){
	var uniqueInstance;
	
	function construct(){
	
		var i18nConstant = null;

		function _loadBundles(){
			//alert("load exec...");
			var lang = _getCookie("lang");
			jQuery.i18n.properties({
				name:'JsMessages', 
				path:'js/bundle/', 
				mode:'both',
				language:lang
			});
			i18nConstant = jQuery.i18n;
		};
		
		function _getProperty(key, params){	// params is an array
			if(i18nConstant == null){
				_loadBundles();
			}
			var value;
			if(params == undefined){
				value = i18nConstant.prop(key);
			}else{
				value = i18nConstant.prop(key, params);
			}
			return value;
		};
		
		function _getI18nCssFile(){
			var lang = _getCookie("lang");
			if(lang == null){
				return "/i18n/i18n.css";
			}else{
				return "/i18n/i18n_" +  lang + ".css";
			}
		}
		
		function _getCookie(key){
			if(key == undefined){
				return;
			}
			var value = $j.cookie(key);
			return value;
		};
		
		return {
			loadBundles:_loadBundles,
			getProperty:_getProperty,
			getCookie:_getCookie,
			getI18nCssFile:_getI18nCssFile
		};
	};
	
	return {
		getInstance:function(){
			if(!uniqueInstance){
				uniqueInstance = construct();
			}
			return uniqueInstance;
		}			
	};	
})();
