var ancho=10;
var alto=10;
var sep=1;
creaPaleta=function(element,callBack){
	var clip,col,top,left;
	var aColors=["00","33","66","99","CC","FF"];
	for(var x=0;x<6;x++){
		for(var y=0;y<6;y++){
			for(var z=0,d=0;z<6;z++,d++){
				col="#"+aColors[z]+aColors[x]+aColors[y];

				clip=document.createElement("a");
				clip.href="Color: "+col;
				clip.funcio=callBack;
				clip.onclick=function(){
					this.funcio(this.color);
					return false;
				}
				cs=clip.style;
				cs.backgroundColor=clip.color=col;
				top=sep+y*(alto+sep);
				cs.top=top+"px";
				left=sep+(z*((sep+ancho)*6))+(x*(ancho+sep));
				cs.left=left+"px";
				cs.width=ancho+"px";
				cs.height=alto+"px";
				cs.position="absolute";
				cs.overflow="hidden";

				element.appendChild(clip);
			}
		}
	}
	element.style.position="relative";
	element.style.height=(6*(alto+sep)+1)+"px";
	element.style.width=(6*6*(ancho+sep)+1)+"px";
}
function funcionRetorno(e){alert(e);}
creaPaleta(document.getElementById("paleta"),funcionRetorno);