ns4 = (document.layers)? true:false; ie4 = (document.all)? true:false; color_array = new Array("red", "green", "blue"); num_colors = color_array.length; hexArray = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); current_picker = ""; function compareStrings(a, b) { if ( a < b ) return -1; if ( a > b ) return 1; return 0; } function WriteColorSelect(picker_id, original_picker_id) { var tmp_onchange = "tmp_val = document.getElementById('" + picker_id + "_color_name').value; if (tmp_val != 'null') { convertHex('" + picker_id + "', tmp_val); }"; if (typeof name_custom_on_change != "undefined") { tmp_onchange += " " + unescape(name_custom_on_change); } str = "'; document.getElementById(picker_id + "_color_select").innerHTML = str; init(picker_id); if (picker_id != original_picker_id) { if (typeof checkFormTasks != "undefined") { checkFormTasks[checkFormTasks.length] = "document.viz_form['" + original_picker_id + "'].value = document.viz_form['" + picker_id + "'].value;"; } } } function ReSortColors(current_picker) { if (eval(current_picker + "_sort_order > 1")) { eval(current_picker + "_sort_order = 0;"); } options = document.getElementById(current_picker + "_color_name").options; selected = document.getElementById(current_picker + "_color_name").selectedIndex; if (selected != -1) { selected_value = options[selected].value; } else { selected_value = options[0].value; } num_options = options.length; tmp_options = new Array; j = 0; for (i = 0; i< num_options; ++i) { if (options[i].text != "Not In List") { tmp_options[j] = options[i].text; ++j; } } for (i = options.length; i>=0;--i) { options[i] = null; } max_options = tmp_options.length; if (eval(current_picker + "_sort_order == 0")) { for (z = 0; z < max_options; ++z) { t = tmp_options[z]; first_b = t.indexOf("["); last_b = t.indexOf("]"); t = t.substring(first_b, last_b+1) + " " + t.substring(0, first_b); tmp_options[z] = t; } tmp_options.sort(compareStrings); } else if (eval(current_picker + "_sort_order == 1")) { for (z = 0; z < max_options; ++z) { t = tmp_options[z]; first_b = t.indexOf("["); last_b = t.indexOf("]"); t = t.substring(last_b+2) + t.substring(first_b, last_b+2); tmp_options[z] = t; } } tmp_options.sort(compareStrings); options[0] = new Option("Not In List", "null", false, false); for (z = 1; z < max_options; ++z) { t = tmp_options[z]; first_b = t.indexOf("["); last_b = t.indexOf("]"); y = t.substring(first_b+2, last_b); //alert(t + " " + y); options[z] = new Option(t, y, false, false); } document.getElementById(current_picker + "_color_name").value = selected_value; eval("++" + current_picker + "_sort_order;"); } function init(tmp_current_picker) { if (tmp_current_picker != "") { eval(tmp_current_picker + "_pickerMin = 0;"); eval(tmp_current_picker + "_pickerMax = 255;"); eval(tmp_current_picker + "_rValue = 0;"); eval(tmp_current_picker + "_gValue = 0;"); eval(tmp_current_picker + "_bValue = 0;"); eval(tmp_current_picker + "_r1 = '0';"); eval(tmp_current_picker + "_r2 = '0';"); eval(tmp_current_picker + "_g1 = '0';"); eval(tmp_current_picker + "_g2 = '0';"); eval(tmp_current_picker + "_b1 = '0';"); eval(tmp_current_picker + "_b2 = '0';"); eval(tmp_current_picker + "_red = '0';"); eval(tmp_current_picker + "_grn = '0';"); eval(tmp_current_picker + "_blu = '0';"); eval(tmp_current_picker + "_rActive = false;"); eval(tmp_current_picker + "_gActive = false;"); eval(tmp_current_picker + "_bActive = false;"); eval(tmp_current_picker + "_firstload = true;"); eval(tmp_current_picker + "_domValue = document.getElementById(\"" + tmp_current_picker + "\");"); eval(tmp_current_picker + "_dom_redValue = document.getElementById(\"" + tmp_current_picker + "_redDisp\");"); eval(tmp_current_picker + "_dom_greenValue = document.getElementById(\"" + tmp_current_picker + "_grnDisp\");"); eval(tmp_current_picker + "_dom_blueValue = document.getElementById(\"" + tmp_current_picker + "_bluDisp\");"); eval("convertHex(tmp_current_picker, " + tmp_current_picker + "_domValue.value);"); eval(tmp_current_picker + "_firstload = false;"); } } function calcValue(tmp_current_picker, base, color) { if (base < 16) { first = 0; } else { first = parseInt(base/16); } if (base <= 0 ) { second = 0; base = 0; } else { second = parseInt(base%16); } eval(tmp_current_picker + "_c1 = hexArray[first];"); eval(tmp_current_picker + "_c2 = hexArray[second]; "); if (eval("color == '" + tmp_current_picker + "_red'")) { eval(tmp_current_picker + "_r1 = " + tmp_current_picker + "_c1;"); eval(tmp_current_picker + "_r2 = " + tmp_current_picker + "_c2;"); eval(tmp_current_picker + "_red = base; "); } else if (eval("color == '" + tmp_current_picker + "_green'")) { eval(tmp_current_picker + "_g1 = " + tmp_current_picker + "_c1;"); eval(tmp_current_picker + "_g2 = " + tmp_current_picker + "_c2;"); eval(tmp_current_picker + "_grn = base;"); } else { eval(tmp_current_picker + "_b1 = " + tmp_current_picker + "_c1;"); eval(tmp_current_picker + "_b2 = " + tmp_current_picker + "_c2;"); eval(tmp_current_picker + "_blu = base;"); } eval(tmp_current_picker + "_domValue.value = '" + eval(tmp_current_picker + "_r1") + eval(tmp_current_picker + "_r2") + eval(tmp_current_picker + "_g1") + eval(tmp_current_picker + "_g2") + eval(tmp_current_picker + "_b1") + eval(tmp_current_picker + "_b2") + "';"); eval(tmp_current_picker + "_dom_redValue.value = " + eval(tmp_current_picker + "_red") + ";"); eval(tmp_current_picker + "_dom_greenValue.value = " + eval(tmp_current_picker + "_grn") + ";"); eval(tmp_current_picker + "_dom_blueValue.value = " + eval(tmp_current_picker + "_blu") + ";"); eval("document.getElementById(tmp_current_picker + \"_color_box\").style.backgroundColor = \"#\" + " + tmp_current_picker + "_domValue.value;"); eval(tmp_current_picker + "_hex_val = " + tmp_current_picker + "_domValue.value;"); if (document.getElementById('target_input')) { eval("document.getElementById(target_input).value = '#" + eval(tmp_current_picker + "_hex_val") + "';"); } eval("num_names = document.viz_form." + tmp_current_picker + "_color_name.options.length;"); new_tmp_color_name_index = 0; for (cn = 1; cn < num_names; ++cn) { if (eval("document.viz_form." + tmp_current_picker + "_color_name.options[cn].value == " + tmp_current_picker + "_hex_val")) { new_tmp_color_name_index = cn; break; } } eval("document.viz_form." + tmp_current_picker + "_color_name.selectedIndex = new_tmp_color_name_index;"); return true; } function convertHex(tmp_current_picker, hexString) { if (hexString == "" || hexString == "transparent" || hexString == "#transparent") { eval("document.viz_form." + tmp_current_picker + "_color_name.value = '';"); eval(tmp_current_picker + "_dom_redValue.value = '';"); eval(tmp_current_picker + "_dom_greenValue.value = '';"); eval(tmp_current_picker + "_dom_blueValue.value = '';"); eval(tmp_current_picker + "_domValue.value = 'transparent';"); document.getElementById(tmp_current_picker + "_color_box").style.background = ""; } else { if (hexString.indexOf("#") != -1) { hexString = hexString.substr(1, hexString.length); } if (hexString != null) { hexString = hexString.toUpperCase(); } if (hexString == null) { eval("hexString = " + tmp_current_picker + "_domValue.value;"); } inputHexArray = new Array(6); for (i = 0; i <= 5; ++i) { inputHexArray[i] = hexString.charAt(i); } for (i = 0; i <= 5; ++i) { tempHexVal = inputHexArray[i]; for (j = 0; j <= 15; ++j) { if (eval("tempHexVal == hexArray[j]")) { tempHexVal = j; } } inputHexArray[i] = tempHexVal; } tmp_red = (inputHexArray[0]*16) + inputHexArray[1]; calcValue(tmp_current_picker, tmp_red, tmp_current_picker + '_red'); tmp_grn = (inputHexArray[2]*16) + inputHexArray[3]; calcValue(tmp_current_picker, tmp_grn, tmp_current_picker + '_green'); tmp_blu = (inputHexArray[4]*16) + inputHexArray[5]; calcValue(tmp_current_picker, tmp_blu, tmp_current_picker + '_blue'); } }