/**
* Tommy Brière
* 2008-03-14
* Gestion des ressources textes
**/

function _TR(id, defaut){
var txt= RessourcesTextes.get(id, defaut);
var args= arguments;
for(var i=2; i< args.length; i++){
var p= args[i];
var j= i-2;
var txt= txt.replace("{"+j+"}", p);}
return txt;}
var Langue= new function(){
var l= 2;
this.getId= function(){
return l;}
this.setId= function(id){
l= id;}
this.getAll= function(){
return[{"id":1,"code":"fr","nom":"Français"},{"id":2,"code":"en","nom":"Anglais"}];}}
var RessourcesTextes= new function(){
this.rs= new Object();

this.add= function(data){
for(var i=0; i< data.length; i++){
var l= data[i];
this.addRs(l[0], l[1]);}}

this.addRs= function(id, valeur){
var els= id.split(".");
var base= this.rs;
while(els.length> 1){
var anc= base;
base= base[els[0]];
if(base){} else{
base= new Object();
anc[els[0]]= base;
}
els.splice(0, 1);}
base[els[0]]= valeur;}

this.get= function(id, defaut){
id=id.toLowerCase();
var els= id.split(".");
var base= this.rs;
while((els.length> 0)&&(base)&&(typeof base=="object" )){
base= base[els[0]];
els.splice(0, 1);}
if((base)&&(typeof base=="string" )){
return base;} else{
return defaut;}}

this.getLangue= function(){
Langue.getId();}}
var ressourcesTextes= RessourcesTextes;