
var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "200";


document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index:15; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(aa = 0; aa < inputs.length; aa++) {
			if((inputs[aa].type == "checkbox" || inputs[aa].type == "radio") && inputs[aa].className == "styled") {
				span[aa] = document.createElement("span");
				span[aa].className = inputs[aa].type;

				if(inputs[aa].checked == true) {
					if(inputs[aa].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[aa].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[aa].style.backgroundPosition = position;
					}
				}
				inputs[aa].parentNode.insertBefore(span[aa], inputs[aa]);
				inputs[aa].onchange = Custom.clear;
				span[aa].onmousedown = Custom.pushed;
				span[aa].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(var aa = 0; aa < inputs.length; aa++) {
			if(inputs[aa].className == "styled") {
				option = inputs[aa].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(bb = 0; bb < option.length; bb++) {
					if(option[bb].selected == true) {
						textnode = document.createTextNode(option[bb].childNodes[0].nodeValue);
					}
				}
				span[aa] = document.createElement("span");
				span[aa].className = "select";
				span[aa].id = "select" + inputs[aa].name;
				span[aa].appendChild(textnode);
				inputs[aa].parentNode.insertBefore(span[aa], inputs[aa]);
				inputs[aa].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(aa = 0; aa < inputs.length; aa++) {
					if(inputs[aa].name == group && inputs[aa] != this.nextSibling) {
						inputs[aa].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var bb = 0; bb < inputs.length; bb++) {
			if(inputs[bb].type == "checkbox" && inputs[bb].checked == true && inputs[bb].className == "styled") {
				inputs[bb].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[bb].type == "checkbox" && inputs[bb].className == "styled") {
				inputs[bb].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[bb].type == "radio" && inputs[bb].checked == true && inputs[bb].className == "styled") {
				inputs[bb].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[bb].type == "radio" && inputs[bb].className == "styled") {
				inputs[bb].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(var dd = 0; dd < option.length; dd++) {
			if(option[dd].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[dd].childNodes[0].nodeValue;
			}
		}
	}
}
window.onload = Custom.init;// JavaScript Document