	tsControl.Checkbox = Class.create();
	tsControl.Checkbox.prototype = Object.extend(tsControl.Checkbox,{
		initialize: function(options){
			this.options = Object.extend({
				id: null,
				target : false,
				name : 'checkbox[]',
				checked : false,
				className : 'my_select',
				Tree : null,
				info : [],
				country : false,
				classNameChecked : 'my_select_checked',
				onClick : function(){return true;},
				afterClick : Prototype.emptyFunction,
				onMouseOver : Prototype.emptyFunction, /// TODO: Добавить обработчик
				onMouseOut : Prototype.emptyFunction /// TODO: Добавить обработчик
			},options || {});
			this.checked = this.options.checked;
			this.id = this.options.info.id;
			if ($(this.options.target)){
				this.target = this.options.target;
				this.createItem();
			}return this;
		},
		getTree : function(){
			if (this.options.Tree) return this.options.Tree;
			else return null;
		},
		createItem : function(){
			this.control = new Element('div',{className : this.options.className});
			if (this.checked) this.control.addClassName(this.options.classNameChecked);
			this.input = new Element('input',{
				type : 'checkbox',
				'checked':this.checked,
				'name' : this.options.name,
				'id' : this.options.id
			}).setStyle({'display':'none'});
			$(this.control).insert(this.input);
			$(this.target).insert(this.control);
			//$(this.target).insert(new Element('div').setStyle({'clear':'none'}));
			this.listenerOnClickObj = this.listenerOnClick.bindAsEventListener(this);
			Event.observe(this.control, 'click',this.listenerOnClickObj);
			return this;
		},

		hide : function(){$(this.control).hide();return this;},
		show : function(){$(this.control).show();return this;},
		check : function(){
			this.control.addClassName(this.options.classNameChecked);
			this.checked = true;
			$(this.input).checked = true;
			return this;
		},

		uncheck : function(){
			this.control.removeClassName(this.options.classNameChecked);
			this.checked = false;
			$(this.input).checked = false;
			return this;
		},
		toggle : function(){
			if(this.checked) this.uncheck();
			else this.check();
			if (this.options.country){
				var Tree = this.getTree();
				var innerItems = Tree.getItemsByParent(this.options.info['id']);
				if (innerItems)
				innerItems.each(function(elm){
					if (elm.control.checked!=this.checked){
						elm.control.toggle();
						var itemId = elm.readAttribute('nodeid');
						if (this.checked){
							Tree.items[Tree.items.length] = itemId;
							Tree.updateInput();
						}else{
							Tree.items = Tree.items.without(itemId);
							Tree.updateInput();
						}
					}
				}.bind(this));
			}
			return this;
		},
		listenerOnClick : function(event){
			if (this.options.onClick(event)) this.toggle();
			this.options.afterClick(event);
			Event.stop(event);
			return this;
		}
	});
