/**
 * @class translator class
 * @author Janusz Rygał
 * @date 18.09.2008 
 */
 Translator = function(version_){
 	 /**version of language*/
 	 var version = version_;
 	 /**translation array*/
 	 var transArray = new Array();
 	 /**store with translation*/
 	 this.langStore;
 	 this.plChars;
 	 
 	 /**
 	  * initialize method
 	  */
 	  this.init = function(){
 	  		if(version == null)
 	  		   version = "1";
 	  		   
 	  		this.langStore = new Ext.data.Store({
                    proxy: new Ext.data.HttpProxy({ 
                                      url: project_url+'GetTranslation?ver='+version,
                                      method: 'GET',
                                      waitMsg:'Loading ...' 
                                     }),
                   reader : new Ext.data.JsonReader({
			                            id: 'translation_loader',
			                            idProperty:'trans',
			                            root: 'trans',
			                            fields: ['id','val']
	                         		 })     		 
                }) 
                
           this.plChars = new Array(18);
           	
           	this.plChars[0] = new Array();
           	this.plChars[0]['pl'] = 'ą';
           	this.plChars[0]['un'] = 'a';
           	
           	this.plChars[1] = new Array();
           	this.plChars[1]['pl'] = 'ć';
           	this.plChars[1]['un'] = 'c';
           	
           	this.plChars[2] = new Array();
           	this.plChars[2]['pl'] = 'ę';
           	this.plChars[2]['un'] = 'e';
           	
           	this.plChars[3] = new Array();
           	this.plChars[3]['pl'] = 'ł';
           	this.plChars[3]['un'] = 'l';
           	
           	this.plChars[4] = new Array();
           	this.plChars[4]['pl'] = 'ń';
           	this.plChars[4]['un'] = 'n';
           	
           	this.plChars[5] = new Array();
           	this.plChars[5]['pl'] = 'ó';
           	this.plChars[5]['un'] = 'o';
           	
           	this.plChars[6] = new Array();
           	this.plChars[6]['pl'] = 'ś';
           	this.plChars[6]['un'] = 's';
           	
           	this.plChars[7] = new Array();
           	this.plChars[7]['pl'] = 'ż';
           	this.plChars[7]['un'] = 'z';
           	
           	this.plChars[8] = new Array();
           	this.plChars[8]['pl'] = 'ź';
           	this.plChars[8]['un'] = 'z';
           	
           	this.plChars[9] = new Array();
           	this.plChars[9]['pl'] = 'Ą';
           	this.plChars[9]['un'] = 'A';
           	
           	this.plChars[10] = new Array();
           	this.plChars[10]['pl'] = 'Ć';
           	this.plChars[10]['un'] = 'C';
           	
           	this.plChars[11] = new Array();
           	this.plChars[11]['pl'] = 'Ę';
           	this.plChars[11]['un'] = 'E';
           	
           	this.plChars[12] = new Array();
           	this.plChars[12]['pl'] = 'Ł';
           	this.plChars[12]['un'] = 'L';
           	
           	this.plChars[13] = new Array();
           	this.plChars[13]['pl'] = 'Ń';
           	this.plChars[13]['un'] = 'N';
           	
           	this.plChars[14] = new Array();
           	this.plChars[14]['pl'] = 'Ó';
           	this.plChars[14]['un'] = 'O';
           	
           	this.plChars[15] = new Array();
           	this.plChars[15]['pl'] = 'Ś';
           	this.plChars[15]['un'] = 'S';
           	
           	this.plChars[16] = new Array();
           	this.plChars[16]['pl'] = 'Ż';
           	this.plChars[16]['un'] = 'Z';
           	
           	this.plChars[17] = new Array();
           	this.plChars[17]['pl'] = 'Ź';
           	this.plChars[17]['un'] = 'Z';
           	     
 	  }
 	 
 	 /**
 	  * method to convert polish chars to universal
 	  * @param string to convert
 	  */
 	 this.getUniversalChars = function(word_){
 	 		var newString = "";
 	 		for(var i=0; i<word_.length; ++i){
 	 			var val = word_.charAt(i);
 	 			for(var j=0; j<this.plChars.length; ++j){
 	 				if(word_.charAt(i) == this.plChars[j]['pl']){
 	 					val = this.plChars[j]['un'];
 	 				}
 	 			}
 	 			newString += val;
 	 		}
 	 		return newString;
 	 }
 	 
 	 /**
 	  * translate method
 	  * @param translate key
 	  */ 
 	  this.translate = function(key){
 	       return transArray[key];
 	  }
 	 
 	 /**
 	  * language version setter
 	  * @param version to set
 	  */
 	  this.setVersion = function(version_){
 	  	 version = version_;
 	  }
 	  
 	  /**
 	   * language version getter
 	   * @return the current language version
 	   */
 	  this.getVersion = function(){
 	  	return version;
 	  } 
 	 
 	  /**
 	   * temporary method to create so fast as possible trans array  
 	   */
 	  this.createTransArray = function(){
 	  	for(i=0; i<this.langStore.getCount(); ++i){
 	  	    transArray[this.langStore.getAt(i).get('id')] = this.langStore.getAt(i).get('val'); 
 	  	}
 	  	
 	  }  
 }