var checkboxHeight="25";var radioHeight="25";var selectWidth="190";var Custom={init:function(){var inputs=document.getElementsByTagName("input"),span=Array(),textnode,option,active;$('input').each(function()
{var inputType=$(this).attr('type');if((inputType=="checkbox"||inputType=="radio")&&$(this).hasClass("styled")){$(this).before('<span class="'+inputType+'"></span>');var $inputSpan=$(this).prev('span:first');$(this).next('span:first').addClass('inputText');if($(this).checked==true)
{if(inputType=="checkbox")$inputSpan.css('background-Position','0 - '+(checkboxHeight*2)+'px');else $inputSpan.css('background-Position','0 - '+(radioHeight*2)+'px');}
$(this).onchange=Custom.clear;if($(this).attr('disabled')==false)
{$inputSpan.mousedown(Custom.pushed);$inputSpan.mouseup(Custom.check);}else $inputSpan.addClass('disabled');}});inputs=document.getElementsByTagName("select");$('select').each(function()
{if($(this).hasClass("styled"))
{var curOption=$(this).children('option:first').text();if($(this).children('option:selected').length)curOption=$(this).children('option:selected').text();if($(this).hasClass("half"))$(this).before('<span class="select half" id="select'+$(this).attr('name')+'">'+curOption+'</span>');else $(this).before('<span class="select" id="select'+$(this).attr('name')+'">'+curOption+'</span>');var $inputSpan=$(this).prev('span:first');if($(this).attr('disabled')==false)
{$(this).change(Custom.choose);}else $inputSpan.addClass('disabled');}});document.onmouseup=Custom.clear;},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(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=="checkbox"&&inputs[b].checked==true&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 -"+checkboxHeight*2+"px";}else if(inputs[b].type=="checkbox"&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 0";}else 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";}}},choose:function(){option=this.getElementsByTagName("option");for(d=0;d<option.length;d++){if(option[d].selected==true){document.getElementById("select"+this.name).childNodes[0].nodeValue=option[d].childNodes[0].nodeValue;}}}}
