﻿var SearchSubmitter = Class.create();
SearchSubmitter.prototype = {

	initialize : function (input, submit) {

		// constants 
		
		this.MIN_LENGTH = 3;
		
		
		// private members
		
		this.input	= null;
		this.submit	= null;

	
		// ctor
		
		if (!input || !submit)
			throw new Error('Ошибка инициализации менеджера формы');
			
		this.input = input;
		this.submit = submit;
		
		this.addBehavior();
	},
	
		
	// private methods
	
	addBehavior : function () {
		this.input.observe('keyup', this.valueChanged.bind(this));
		this.valueChanged();
		this.input.focus();
	},
	
	valueChanged : function () {
		this.submit.disabled = (this.input.value.length < this.MIN_LENGTH);
	}

}

