function select(selectid, id) {
	var selectbox = document.getElementById(selectid);
	selectbox.options[id].selected = true;
	selected_option = selectbox.options[id].text;
	var selecta = document.getElementById('text_' + selectid);
	selecta.innerHTML = selected_option;
}

var zindex = 0;

function selectBox(selectid, classname) {
  this.onchangeText = "undefined";
 	this.selectbox = document.getElementById(selectid);
	this.spanbox = document.getElementById("container_" + selectid);
	this.html = '';
	this.title = '';

	this.change = selectOnChange;

	// TITLE
	if (this.selectbox.selectedIndex > 0) {
		var sle = this.selectbox.selectedIndex;
		this.title = this.selectbox.options[this.selectbox.selectedIndex].text;
	} else {
		this.title = this.selectbox.options[0].text;
	}

	// ONCHANGE
	this.onchangeText = this.selectbox.onchange;

	// HTML
	this.html += '<div id="select_' + selectid + '" class="selectbox ' + classname + '"><span id="text_' + selectid + '">' + this.title + '</span><div class="dropdown ' + classname + '">';
	for (var i=0; i < this.selectbox.options.length; i++) {
		this.html += '<a href="javascript:void(0);" onclick="select(\'' + selectid + '\', ' + i + '); sel_reg[\'' + selectid + '\'].change();">' + this.selectbox.options[i].text + '</a>';
	}
	this.html += '</div></div>';
	this.spanbox.innerHTML = this.html;

	this.selectbox.style.display = "none";
	var dhtmlselectbox = document.getElementById("select_" + selectid);
	dhtmlselectbox.style.zIndex = 1000 - zindex;
	dhtmlselectbox.getElementsByTagName("div")[0].style.top = "20px";
	dhtmlselectbox.onmouseover=function() {
		this.getElementsByTagName("div")[0].style.display = "block";
	}
	dhtmlselectbox.onmouseout=function() {
		this.getElementsByTagName("div")[0].style.display = "none";
	}
	zindex++;
	return false;
}

function selectOnChange() {
	if (this.onchangeText != "undefined") {
		var xxx = this.onchangeText;
		if (typeof(xxx) == "function") {
			xxx();
		}
	}
}

function selectRedraw(id) {
	var container = document.getElementById('select_two_container');
	var child = document.getElementById('select_select_multiple_two');
	container.removeChild(child);
	selectBox('select_multiple_two');
	return false;
}
