/*
CUSTOM FORM ELEMENTS
Created by Ryan Fait
www.ryanfait.com
The only things you may need to change in this file are the following
variables: checkboxHeight, radioHeight and selectWidth (lines 24, 25, 26)
The numbers you set for checkboxHeight and radioHeight should be one quarter
of the total height of the image want to use for checkboxes and radio
buttons. Both images should contain the four stages of both inputs stacked
on top of each other in this order: unchecked, unchecked-clicked,
checked, checked-clicked.
You may need to adjust your images a bit if there is a slight vertical
movement during the different stages of the button activation.
The value of selectWidth should be the width of your select list image.
Visit http://ryanfait.com/ for more information.
*/
var checkboxHeight="25",radioHeight="25",selectWidth="190";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: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>");var Custom={init:function(){var e,t,i,n=document.getElementsByTagName("input"),o=Array();for(a=0;a<n.length;a++)("checkbox"==n[a].type||"radio"==n[a].type)&&n[a].className.indexOf("styled")>-1&&(o[a]=document.createElement("span"),o[a].className=n[a].type,1==n[a].checked&&("checkbox"==n[a].type?(position="0 -"+2*checkboxHeight+"px",o[a].style.backgroundPosition=position):(position="0 -"+2*radioHeight+"px",o[a].style.backgroundPosition=position)),n[a].parentNode.insertBefore(o[a],n[a]),n[a].onchange=Custom.clear,n[a].getAttribute("disabled")?o[a].className=o[a].className+=" disabled":(o[a].onmousedown=Custom.pushed,o[a].onmouseup=Custom.check));for(n=document.getElementsByTagName("select"),a=0;a<n.length;a++)if(n[a].className.indexOf("styled")>-1){for(t=n[a].getElementsByTagName("option"),i=t[0].childNodes[0].nodeValue,e=document.createTextNode(i),b=0;b<t.length;b++)1==t[b].selected&&(e=document.createTextNode(t[b].childNodes[0].nodeValue));o[a]=document.createElement("span"),o[a].className="select",o[a].id="select"+n[a].name,o[a].appendChild(e),n[a].parentNode.insertBefore(o[a],n[a]),n[a].getAttribute("disabled")?n[a].previousSibling.className=n[a].previousSibling.className+=" disabled":n[a].onchange=Custom.choose}document.onmouseup=Custom.clear},pushed:function(){element=this.nextSibling,this.style.backgroundPosition=1==element.checked&&"checkbox"==element.type?"0 -"+3*checkboxHeight+"px":1==element.checked&&"radio"==element.type?"0 -"+3*radioHeight+"px":1!=element.checked&&"checkbox"==element.type?"0 -"+checkboxHeight+"px":"0 -"+radioHeight+"px"},check:function(){if(element=this.nextSibling,1==element.checked&&"checkbox"==element.type)this.style.backgroundPosition="0 0",element.checked=!1;else{if("checkbox"==element.type)this.style.backgroundPosition="0 -"+2*checkboxHeight+"px";else for(this.style.backgroundPosition="0 -"+2*radioHeight+"px",group=this.nextSibling.name,inputs=document.getElementsByTagName("input"),a=0;a<inputs.length;a++)inputs[a].name==group&&inputs[a]!=this.nextSibling&&(inputs[a].previousSibling.style.backgroundPosition="0 0");element.checked=!0}},clear:function(){inputs=document.getElementsByTagName("input");for(var e=0;e<inputs.length;e++)"checkbox"==inputs[e].type&&1==inputs[e].checked&&inputs[e].className.indexOf("styled")>-1?inputs[e].previousSibling.style.backgroundPosition="0 -"+2*checkboxHeight+"px":"checkbox"==inputs[e].type&&inputs[e].className.indexOf("styled")>-1?inputs[e].previousSibling.style.backgroundPosition="0 0":"radio"==inputs[e].type&&1==inputs[e].checked&&inputs[e].className.indexOf("styled")>-1?inputs[e].previousSibling.style.backgroundPosition="0 -"+2*radioHeight+"px":"radio"==inputs[e].type&&inputs[e].className.indexOf("styled")>-1&&(inputs[e].previousSibling.style.backgroundPosition="0 0")},choose:function(){for(option=this.getElementsByTagName("option"),d=0;d<option.length;d++)1==option[d].selected&&(document.getElementById("select"+this.name).childNodes[0].nodeValue=option[d].childNodes[0].nodeValue)}};window.onload=Custom.init;