function DCSelect(id) {
	this.id = id;
	this.transform(document.getElementById(id));
	this.status.onclick = this.toggle;
	this.options.onmouseout = this.options.style.display = "none";
//alert(document.getElementById(id).innerHTML);
}
DCSelect.prototype.toggle = function () {
	this.parent.options.style.display = (this.parent.options.style.display == "block") ? "none" : "block";
}
DCSelect.prototype.select = function () {
	this.parent.statusText.innerHTML = this.innerHTML;
	this.parent.value.value = this.value;
	this.parent.options.style.display = "none";
	this.className = "";
}
DCSelect.prototype.transform = function (from) {
	this.selector = document.createElement("div");
	this.selector.className = "DCselect" + " " + from.className;
	this.selector.id = from.id;

	this.status = document.createElement("div");
	this.status.className = "status";
	this.status.parent = this;

	this.statusText = document.createElement("span");
	this.statusText = this.status.appendChild(this.statusText);

	this.value = document.createElement("input");
	this.value.type = "hidden";
	this.value.name = from.name;

	this.options = document.createElement("div");
	this.options.className = "options";
	this.options.parent = this;

	var elements = from.getElementsByTagName("option");
	for (var i=0; i<elements.length; i++) {
		var span = document.createElement("span");
		span.innerHTML = elements[i].innerHTML;
		span.value = elements[i].value;
		span.parent = this;
		span.onclick = this.select;
		span.onmouseover = function () {this.className = "hover";}
		span.onmouseout  = function () {this.className = "";}
		this.options.appendChild(span);

		if (i==0 || elements[i].selected) {
			this.statusText.innerHTML = elements[i].innerHTML;
			this.value.value = elements[i].value;
		}
	}

	this.status = this.selector.appendChild(this.status);
	this.options = this.selector.appendChild(this.options);
	this.value = this.selector.appendChild(this.value);

	from.parentNode.replaceChild(this.selector, from);
}
