/* Copyright 2007 - 2008 Cédric Michaux */
/* This code isn't redistributable      */

function styleCheckBoxesAndRadio(checkboxesObjects){
	for(i=0;checkboxesObjects[i];i++){
		chkbx = checkboxesObjects[i];
		chkbx.style.display = "none";
		divElement = document.createElement("div");
		(chkbx.checked) ? divElement.className = chkbx.className+"-checked" : divElement.className = chkbx.className+"-unchecked";
		divElement.relative = chkbx;
		chkbx.relative = divElement;
		

		divElement.onclick = function(){
			if(this.relative.checked){
				if(this.relative.type == "radio")
					return false;
				else
					this.relative.checked = false;
			}
			else{
				if(this.relative.type == "radio"){
					groupItems = (function(name){
						inputs = document.getElementsByTagName("input");
						var tabInput = new Array();
						for(k=0; inputs[k];k++){
							if(inputs[k].name == name)
								tabInput.push(inputs[k]);
						}
						return tabInput;
					})(this.relative.name);
					
					for(j=0; groupItems[j]; j++){
						groupItems[j].checked = false;
						groupItems[j].relative.className = groupItems[j].className + "-unchecked";
					}
				}
				this.relative.checked = true;
			}
			(this.relative.checked) ? this.className = this.relative.className+"-checked" : this.className = this.relative.className+"-unchecked";
		}
		chkbx.parentNode.appendChild(divElement);
	}
}