﻿Type.registerNamespace('Thinsolutions.Search');

Thinsolutions.Search.SearchBox = function(element) {
	this._textBox = null;
	this._button = null;
	Thinsolutions.Search.SearchBox.initializeBase(this, [element]);
}
Thinsolutions.Search.SearchBox.prototype =
{
	get_textBox: function() {
		return this._textBox;
	},
	get_button: function() {
		return this._button;
	},

	initialize: function() {
		Thinsolutions.Search.SearchBox.callBaseMethod(this, 'initialize');

		var o = this.get_element();
		var id = o.id;
		this._textBox = $get(id + '_txt');
		this._button = $get(id + '_btn');
		$addHandlers(this._textBox, { 'keydown': this._keydown }, this);
	},
	dispose: function() {
		if (this._textBox != null)
			$clearHandlers(this._textBox);
		Thinsolutions.Search.SearchBox.callBaseMethod(this, 'dispose');
	},

	_keydown: function(e) {
		if (e.keyCode == Sys.UI.Key.enter) {
			e.preventDefault();
			this.get_button().click();
		}
	}
}

Thinsolutions.Search.SearchBox.registerClass('Thinsolutions.Search.SearchBox', Sys.UI.Control);

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();