/*
    颜色选择框
*/
var colorTable = "";

//fun 颜色值存放控件ID title 改变文本框文字颜色
function colorpicker(fun, title) {
    if (colorTable == "") {
        colorTable += "<div class='TableColorH' >";
        colorTable += "<div id='TableColorShow' class='TableColorShow' ></div>";
        colorTable += "<div id='TableColorShowText' class='TableColorShowText' ></div>";
        colorTable += "<a class='TableColorClear' href=\"javascript:clear_title('" + fun + "','" + title + "')\" >清除</a>";
        colorTable += "<a class='TableColorClose' href=\"javascript:closeBox('" + fun + "')\" >关闭</a>";
        colorTable += "</div>";

        colorTable += "<div class='TableColorMain' >";
        var ColorHex = new Array('00', '33', '66', '99', 'CC', 'FF');
        var SpColorHex = new Array('FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF');

        for (i = 0; i < 2; i++) {
            for (j = 0; j < 6; j++) {
                colorTable += '<a onmouseover="onmouseover_color(\'#000\')" onclick="select_color(\'#000\',\'' + fun + '\',\'' + title + '\')" style="background-color:#000"></a>'
                if (i == 0)
                    colorTable += '<a onmouseover="onmouseover_color(\'#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '\')" onclick="select_color(\'#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '\',\'' + fun + '\',\'' + title + '\')" style="background-color:#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '"></a>'
                else
                    colorTable += '<a onmouseover="onmouseover_color(\'#' + SpColorHex[j] + '\')" onclick="select_color(\'#' + SpColorHex[j] + '\',\'' + fun + '\',\'' + title + '\')" style="background-color:#' + SpColorHex[j] + '"></a>'

                colorTable += '<a onmouseover="onmouseover_color(\'#000\')" onclick="select_color(\'#000\',\'' + fun + '\',\'' + title + '\')" style="background-color:#000"></a>'
                for (k = 0; k < 3; k++) {
                    for (l = 0; l < 6; l++) {
                        colorTable += '<a onmouseover="onmouseover_color(\'#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '\')" onclick="select_color(\'#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '\',\'' + fun + '\',\'' + title + '\')"  style="background-color:#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '"></a>'
                    }
                }

                colorTable += "<br />";
            }
        }
        colorTable += "</div>";
    }

    $('#Color' + fun).html(colorTable);
    $("#TableColorShow").attr("style", 'background:' + $('#' + fun).val());
    $("#TableColorShowText").html($('#' + fun).val());
}
function onmouseover_color(color) {
    $('#TableColorShow').attr("style", 'background:' + color);
    $('#TableColorShowText').html(color);
}
function select_color(color, fun, title) {
    $("#" + title).attr("style", 'color:' + color);
    $('#' + fun).val(color);
    $('#Color' + fun).html("");
}
function closeBox(fun) {
    $('#Color' + fun).html("");
}
function clear_title(fun, title) {
    $("#" + title).removeAttr("style");
    $('#' + fun).val("");
    $('#Color' + fun).html("");
}