
var selects = document.getElementsByTagName("select");
var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;
function $$$(a) {
	return document.getElementById(a);
}
function stopBubbling(a) {
	a.stopPropagation();
}
function rSelects() {
	for (i = 0; i < selects.length; i++) {
		selects[i].style.display = "none";
		select_tag = document.createElement("div");
		select_tag.id = "select_" + selects[i].name;
		select_tag.className = "select_box";
		selects[i].parentNode.insertBefore(select_tag, selects[i]);
		select_info = document.createElement("div");
		select_info.id = "select_info_" + selects[i].name;
		select_info.className = "tag_select";
		select_info.style.cursor = "pointer";
		select_tag.appendChild(select_info);
		select_ul = document.createElement("ul");
		select_ul.id = "options_" + selects[i].name;
		select_ul.className = "tag_options";
		select_ul.style.position = "absolute";
		select_ul.style.display = "none";
		select_ul.style.zIndex = "999";
		select_tag.appendChild(select_ul);
		rOptions(i, selects[i].name);
		mouseSelects(selects[i].name);
		if (isIE) {
			selects[i].onclick = new Function("clickLabels3('" + selects[i].name + "');window.event.cancelBubble = true;");
		} else {
			if (!isIE) {
				selects[i].onclick = new Function("clickLabels3('" + selects[i].name + "')");
				selects[i].addEventListener("click", stopBubbling, false);
			}
		}
	}
}
function rOptions(c, b) {
	var a = selects[c].getElementsByTagName("option");
	var d = "options_" + b;
	for (n = 0; n < selects[c].options.length; n++) {
		option_li = document.createElement("li");
		option_li.style.cursor = "pointer";
		option_li.className = "open";
		$$$(d).appendChild(option_li);
		option_text = document.createTextNode(selects[c].options[n].text);
		option_li.appendChild(option_text);
		option_selected = selects[c].options[n].selected;
		if (option_selected) {
			option_li.className = "open_selected";
			option_li.id = "selected_" + b;
			$$$("select_info_" + b).appendChild(document.createTextNode(option_li.innerHTML));
		}
		option_li.onmouseover = function () {
			this.className = "open_hover";
		};
		option_li.onmouseout = function () {
			if (this.id == "selected_" + b) {
				this.className = "open_selected";
			} else {
				this.className = "open";
			}
		};
		option_li.onclick = new Function("clickOptions(" + c + "," + n + ",'" + selects[c].name + "')");
	}
}
function mouseSelects(b) {
	var a = "select_info_" + b;
	$$$(a).onmouseover = function () {
		if (this.className == "tag_select") {
			this.className = "tag_select_hover";
		}
	};
	$$$(a).onmouseout = function () {
		if (this.className == "tag_select_hover") {
			this.className = "tag_select";
		}
	};
	if (isIE) {
		$$$(a).onclick = new Function("clickSelects('" + b + "');window.event.cancelBubble = true;");
	} else {
		if (!isIE) {
			$$$(a).onclick = new Function("clickSelects('" + b + "');");
			$$$("select_info_" + b).addEventListener("click", stopBubbling, false);
		}
	}
}
function clickSelects(b) {
	var a = "select_info_" + b;
	var c = "options_" + b;
	for (i = 0; i < selects.length; i++) {
		if (selects[i].name == b) {
			if ($$$(a).className == "tag_select_hover") {
				$$$(a).className = "tag_select_open";
				$$$(c).style.display = "";
			} else {
				if ($$$(a).className == "tag_select_open") {
					$$$(a).className = "tag_select_hover";
					$$$(c).style.display = "none";
				}
			}
		} else {
			$$$("select_info_" + selects[i].name).className = "tag_select";
			$$$("options_" + selects[i].name).style.display = "none";
		}
	}
}
function clickOptions(c, d, b) {
	var a = $$$("options_" + b).getElementsByTagName("li");
	$$$("selected_" + b).className = "open";
	$$$("selected_" + b).id = "";
	a[d].id = "selected_" + b;
	a[d].className = "open_hover";
	$$$("select_" + b).removeChild($$$("select_info_" + b));
	select_info = document.createElement("div");
	select_info.id = "select_info_" + b;
	select_info.className = "tag_select";
	select_info.style.cursor = "pointer";
	$$$("options_" + b).parentNode.insertBefore(select_info, $$$("options_" + b));
	mouseSelects(b);
	$$$("select_info_" + b).appendChild(document.createTextNode(a[d].innerHTML));
	$$$("options_" + b).style.display = "none";
	$$$("select_info_" + b).className = "tag_select";
	selects[c].options[d].selected = "selected";
}
window.onload = function (a) {
	bodyclick = document.getElementsByTagName("body").item(0);
	rSelects();
	bodyclick.onclick = function () {
		for (i = 0; i < selects.length; i++) {
			$$$("select_info_" + selects[i].name).className = "tag_select";
			$$$("options_" + selects[i].name).style.display = "none";
		}
	};
};


