﻿var App = {
	start: function() {
		App.VietTyping.initialize();
	}
};

App.VietTyping = {
	_el: null,
	
	initialize: function() {
		this._el = $E("img.vietTyping", "search-box");
		if ($defined(this._el)) {
			this._el.addEvent("click", this._toggleOnOff.bind(this));
			
			var on = Cookie.get("AVIM_on_off");
			if (on && on.toInt())
				this._toggleOnOff();
		}
	},
	
	_toggleOnOff: function() {
		if (this._el.hasClass("on")) {
			AVIMObj.setMethod(-1);
			
			this._el.title = "Bật bộ gõ tiếng Việt";
		}
		else {
			AVIMObj.setMethod(0);
			
			this._el.title = "Tắt bộ gõ tiếng Việt";
		}
		
		this._el.toggleClass("on");
	}
};
