/**
 * @alias ComboBox.class
 * @author WilC <wilz04@gmail.com>
 * @since 2007.
 */

function ComboBox(element) {
	
	this.box = element;
	
	this.addItem = function (opt) {
		this.box.options[this.box.options.length] = opt;
	};
	
	this.addItems = function (opts) {
		var i;
		for (i in opts) {
			this.box.options[this.box.options.length] = opts[i];
		}
	};
	
	this.setSelectedIndex = function (index) {
		this.box.selectedIndex = index;
	};
	
	this.getValue = function () {
		if (this.box.options.length > 0) {
			return this.box.options[this.box.selectedIndex].value;
		}
		return null;
	};
	
	this.setFocus = function () {
		this.box.focus();
	};
	
	this.removeAllItems = function () {
		for (var i=this.box.options.length-1; i>=0; i--) {
			this.box.options[i] = null;
		}
	};
	
	this.onChange = function (action) {
		this.box.onchange = action;
	};
	
}
