function SToggle(selectID, containerID) {

	this.prepareID = function(id) {
		return id.replace(/\./g, "\\.");
	};
	
	this.get = function(id) {
		return $("#" + this.prepareID(id));
	};

	this.click = function(obj, key, event) {

		if($(obj).hasClass("selected")) {
			if(this.allowEmpty) {
				this.select.attr("selectedIndex", 0);
				$(obj).removeClass("selected");
			}
			return;
		}

		this.select.attr("selectedIndex", key);
		this.container.children(".selected").removeClass("selected");
		$(obj).addClass("selected");
	};

	var THIS = this;

	this.select = this.get(selectID);
	this.container = this.get(containerID);

	if(!this.select || !this.container) {
		return this;
	}

	this.select.hide();

	this.allowEmpty = false;

	this.select.children("option").each(function(key, value) {

		if($(value).html() == "" || $(value).attr("value") == "") {
			THIS.allowEmpty = true;
			return;
		}

		var id = selectID + "_" + key;
		THIS.container.append("<div id=\"" + id + "\" class=\"toggle\"><span>" + $(value).html() + "</span></div>");
		THIS.get(id).click(function(event) {THIS.click(this, key, event); return false;});

		if(key == THIS.select.attr("selectedIndex")) {
			THIS.get(id).trigger("click");
		}
	});
}