/**
 * Switches Yamli on or off.
 */
var YamliSwitcher = new Class({
	initialize: function(clicker, status) {		
		this.status = status;
		this.img = $('yamliIMG');
		this.DirBGIMG = 'fileadmin/images/plugins/tx_3m5techdict_pi1/';		
		this.input = $('tx_3m5techdict_pi1_sword');			
		this.clicker = clicker;
		//change img on initialisation depending on status
		this.switchIMG(this.status);
		this.clicker.addEvent('click', this.switchYamli.bind(this));
	},
	switchYamli: function() {		
		if (this.status == 'off') {			
			Yamli.yamlify(this.input, { settingsPlacement: "hide" } );
			Yamli.setGlobalOptions( {uiLanguage:"en", startMode:"on"});			
			this.status = 'on';			
		} else if (this.status == 'on') {			
			Yamli.deyamlify(this.input);
			Yamli.setGlobalOptions({uiLanguage:"en", startMode:"off"});
			this.status = 'off';
			//if switched off the direction of the input-field have to be resetted
			this.input.setStyle('direction', 'ltr');
			this.input.setStyle('text-align', 'left');
		}
		this.switchIMG(this.status);
	},
	switchIMG: function(status) {
		this.img.setStyle('background-image', 'url("' + this.DirBGIMG + 'yamli_' + status + '.gif' + '")');
	}
});
