/*
www.thebanditsociety.com
This is the code used to control the hover effect on the header buttons
*/
function SwapImg(el,source){
        el.src=el.getAttribute(source || "original");
}
function SwapImgSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var hover = x[i].getAttribute("hover");
    if (!hover) continue;
    x[i].hover_img = new Image();
    x[i].hover_img.src=hover;
    x[i].onmouseover = new Function("SwapImg(this,'hover');");
    x[i].onmouseout = new Function("SwapImg(this);");
    x[i].setAttribute("original",x[i].src);
  }
}

var SwapImgOnload =(window.onload)? window.onload : function(){};
window.onload = function(){SwapImgOnload(); SwapImgSetup();}

/*
Base code from www.ryanfait.com check it out! I altered it slighty to achieve the effect I was looking for
This makes the custom feelings radio buttons
*/

var checkboxHeight = "25";
var radioHeight = "41";
document.write('<style type="text/css">input.styled { display: none; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].type == "radio") {
				if(inputs[a].className == "styled"){
					span[a] = document.createElement("span");
					span[a].className = inputs[a].value;
	
					if(inputs[a].checked == true) {
						if(inputs[a].type == "checkbox") {
							position = "0 -" + (checkboxHeight*2) + "px";
							span[a].style.backgroundPosition = position;
						} else {
							position = "0 -" + (radioHeight*2) + "px";
							span[a].style.backgroundPosition = position;
						}
					}
					inputs[a].parentNode.insertBefore(span[a], inputs[a]);
					inputs[a].onchange = Custom.clear;
					span[a].onmousedown = Custom.pushed;
					span[a].onmouseup = Custom.check;
					document.onmouseup = Custom.clear;
				}
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
		group = this.nextSibling.name;
		inputs = document.getElementsByTagName("input");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].name == group && inputs[a] != this.nextSibling) {
				inputs[a].previousSibling.style.backgroundPosition = "0 0";
			}
		}
		element.checked = true;
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	}
}
window.onload = Custom.init;