function color_picker(color, input)
{
    esa = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
    table = "<table class=\"picker\">";
    for($r=15;$r>=0;$r-=3)
    {
        for($g=15;$g>=0;$g-=3)
        {
            for($b=15;$b>=0;$b-=3)
            {
                table += "<td style=\"background-color:#"+esa[$r]+esa[$r]+esa[$g]+esa[$g]+esa[$b]+esa[$b]+";\"";
                table += " onclick=\"color_select('"+esa[$r]+esa[$r]+esa[$g]+esa[$g]+esa[$b]+esa[$b]+"','"+input+"')\"";
                table += " onmouseover=\"color_over('"+esa[$r]+esa[$r]+esa[$g]+esa[$g]+esa[$b]+esa[$b]+"','"+input+"')\" onmouseout=\"color_over('"+color+"','"+input+"')\">&nbsp;</td>";
            }
        }
        table += "</tr>";
    }
    table += "</table>";
    document.getElementById("cp"+input).innerHTML = table;
    document.getElementById("sp"+input).innerHTML = "&laquo; <a href=\"#template\" onclick=\"color_select('"+color+"','"+input+"')\" style=\"color:#a00; font-size:11px; font-weight:bold;\">Annulla l'operazione</a>";
}

function color_select(color,input)
{
    document.getElementById("ip"+input).value = color;
    document.getElementById("picker"+input).style.backgroundColor = "#"+color;
    document.getElementById("cp"+input).innerHTML = "";
    document.getElementById("sp"+input).innerHTML = "&laquo; <a href=\"#template\" onclick=\"color_picker('"+color+"','"+input+"')\">Seleziona il colore</a>";
}

function color_over(color,input)
{
    //document.getElementById("ip"+input).value = color;
    //document.getElementById("picker"+input).style.backgroundColor = "#"+color;
}