var JadeLang = {
	_vars: function(){
		this.defaultLanguage='en';
		this.languages=[];
		this._add_language('es','Español');
		this._add_language('en','English');
		this._add_language('pt','Português');
		this._add_language('hr','Hrvatski');
		this._add_language('sl','Slovenščina');
		this._add_language('ca','Catalan');
		this._add_language('fr','Français');
		//this._add_language('ar','العربية');
	},
	_initial: function(){
		var strLang = Jade.Cookie.Get('lng');
		if(strLang==null) { strLang = Jade.Lang.GetDefaultLanguage(); }
		Jade.Cookie.Set('lng', strLang);
		Jade.Lang.language = strLang;
		Jade.Include(Jade.path.replace('/lib/js/','')+'/languages/'+strLang+'/page.lng',false);
	},
	_add_language: function(code,name){
		this.languages.push({'code': code, 'name': name});
	},
	SetLanguage: function(lngCode){
		Jade.Cookie.Set('lng', lngCode, 3000);
	},
	GetDefaultLanguage: function(){
		var language=Jade.Lang.defaultLanguage;
		if(typeof(CONFIG)!="undefined" && typeof(CONFIG.LANGUAGE_DEFAULT)!="undefined" && CONFIG.LANGUAGE_DEFAULT!=""){ language=CONFIG.LANGUAGE_DEFAULT; }
		/*
		var boolSupported=false;
		if  (typeof(navigator.userLanguage) != "undefined")	{ language = navigator.userLanguage; }
		else if(typeof(navigator.systemLanguage)!="undefined") { language = navigator.systemLanguage; }
		else if(typeof(navigator.browserLanguage)!="undefined")	{ language = navigator.browserLanguage;	}
		else if(typeof(navigator.language)!="undefined") { language = navigator.language; }
		
		language = language.substr(0,2).toLowerCase();
		for(var i=0; i<Jade.Lang.supportedLanguages.length;i++)
		{
			if(language==Jade.Lang.supportedLanguages[i]) { boolSupported = true; }
		}
		if(!boolSupported) { language=Jade.Lang.defaultLanguage; }
		*/
		//Jade.Cookie.Set('lng', language);
		return language;
	},
	Get: function(value){
		if(typeof(languageStrings)!="undefined" && typeof(languageStrings[value])!="undefined") { return languageStrings[value]; }
		else { return '';}
	},
	Reposition: function(obj){
		if($.Lang.language=='ar'){
			if(!/jade_container/.test(obj.className)){
				var x=obj.parent.width-obj.width-obj.x;
				obj.lng_pos=1;
				obj.Position(x, obj.y);
			}
		}
	}
};
Jade.LoadLibrary('Lang',JadeLang);
$.lng=Jade.Lang.Get;
