var bkInput = Base.extend({

	bkForm : null,
	settings : {},
	input : null,
	inputName : null,
	label : null,

	constructor : function(bkForm, settings) {
		this.settings = settings;
		this.bkForm = bkForm;

		this.init();
		this.datalist();
	},

	init : function() {
	},

	datalist : function() {
		var dl = document.getElementById('dl_' + this.getInputName()), ajax;
		if (dl && ('options' in dl)) {
			ajax = new AjaxRequest();
			ajax.method = 'POST';
			ajax.handleArguments({
				'url' : dl.getAttribute('data'),
				'async' : false
			});
			ajax.process();
			dl.innerHTML = ajax.responseText;
		}
	},

	getInput : function() {
		if (this.input === null) {
			this.input = document.getElementById(this.getInputName());
		}
		return this.input;
	},

	getInputName : function() {
		if (this.inputName === null) {
			this.inputName = this.bkForm.getName() + '_' + this.getName();
		}
		return this.inputName;
	},

	getName : function() {
		return this.settings.name;
	},

	getLabel : function() {
		if (this.label === null) {
			var tmp = document.createElement("div");
			tmp.innerHTML = document.getElementById(this.getInputName() + '_label').innerHTML;
			this.label = tmp.textContent || tmp.innerText;
		}
		return this.label;
	},

	get : function() {
		var input = this.getInput();
		if (input) {
			return input.value;
		} else {
			return value = '';
		}
	},

	checkRequired : function() {
		if (typeof this.settings.options.required != "undefined" && (this.settings.options.required == 'yes' || this.settings.options.required === true)) {
			var val = this.get();
			if (val) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	},

	checkValid : function() {
		return true;
	},

	validate : function() {
		if ((typeof this.settings.options.required != "undefined" && (this.settings.options.required == 'yes' || this.settings.options.required === true) && !this.checkRequired())) {
			return false;
		} else if (this.checkValid()) {
			return true;
		} else {
			return false;
		}
	}

});
