colorpicker.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. // ===================================================================
  2. // Author: Matt Kruse <matt@mattkruse.com>
  3. // WWW: http://www.mattkruse.com/
  4. //
  5. // NOTICE: You may use this code for any purpose, commercial or
  6. // private, without any further permission from the author. You may
  7. // remove this notice from your final code if you wish, however it is
  8. // appreciated by the author if at least my web site address is kept.
  9. //
  10. // You may *NOT* re-distribute this code in any way except through its
  11. // use. That means, you can include it in your product, or your web
  12. // site, or any other form where the code is actually being used. You
  13. // may not put the plain javascript up on your site for download or
  14. // include it in your javascript libraries for download.
  15. // If you wish to share this code with others, please just point them
  16. // to the URL instead.
  17. // Please DO NOT link directly to my .js files from your site. Copy
  18. // the files to your server and use them there. Thank you.
  19. // ===================================================================
  20. /* SOURCE FILE: AnchorPosition.js */
  21. /*
  22. AnchorPosition.js
  23. Author: Matt Kruse
  24. Last modified: 10/11/02
  25. DESCRIPTION: These functions find the position of an <A> tag in a document,
  26. so other elements can be positioned relative to it.
  27. COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
  28. positioning errors - usually with Window positioning - occur on the
  29. Macintosh platform.
  30. FUNCTIONS:
  31. getAnchorPosition(anchorname)
  32. Returns an Object() having .x and .y properties of the pixel coordinates
  33. of the upper-left corner of the anchor. Position is relative to the PAGE.
  34. getAnchorWindowPosition(anchorname)
  35. Returns an Object() having .x and .y properties of the pixel coordinates
  36. of the upper-left corner of the anchor, relative to the WHOLE SCREEN.
  37. NOTES:
  38. 1) For popping up separate browser windows, use getAnchorWindowPosition.
  39. Otherwise, use getAnchorPosition
  40. 2) Your anchor tag MUST contain both NAME and ID attributes which are the
  41. same. For example:
  42. <A NAME="test" ID="test"> </A>
  43. 3) There must be at least a space between <A> </A> for IE5.5 to see the
  44. anchor tag correctly. Do not do <A></A> with no space.
  45. */
  46. // getAnchorPosition(anchorname)
  47. // This function returns an object having .x and .y properties which are the coordinates
  48. // of the named anchor, relative to the page.
  49. function getAnchorPosition(anchorname) {
  50. // This function will return an Object with x and y properties
  51. var useWindow=false;
  52. var coordinates=new Object();
  53. var x=0,y=0;
  54. // Browser capability sniffing
  55. var use_gebi=false, use_css=false, use_layers=false;
  56. if (document.getElementById) { use_gebi=true; }
  57. else if (document.all) { use_css=true; }
  58. else if (document.layers) { use_layers=true; }
  59. // Logic to find position
  60. if (use_gebi && document.all) {
  61. x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  62. y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  63. }
  64. else if (use_gebi) {
  65. var o=document.getElementById(anchorname);
  66. x=AnchorPosition_getPageOffsetLeft(o);
  67. y=AnchorPosition_getPageOffsetTop(o);
  68. }
  69. else if (use_css) {
  70. x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  71. y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  72. }
  73. else if (use_layers) {
  74. var found=0;
  75. for (var i=0; i<document.anchors.length; i++) {
  76. if (document.anchors[i].name==anchorname) { found=1; break; }
  77. }
  78. if (found==0) {
  79. coordinates.x=0; coordinates.y=0; return coordinates;
  80. }
  81. x=document.anchors[i].x;
  82. y=document.anchors[i].y;
  83. }
  84. else {
  85. coordinates.x=0; coordinates.y=0; return coordinates;
  86. }
  87. coordinates.x=x;
  88. coordinates.y=y;
  89. return coordinates;
  90. }
  91. // getAnchorWindowPosition(anchorname)
  92. // This function returns an object having .x and .y properties which are the coordinates
  93. // of the named anchor, relative to the window
  94. function getAnchorWindowPosition(anchorname) {
  95. var coordinates=getAnchorPosition(anchorname);
  96. var x=0;
  97. var y=0;
  98. if (document.getElementById) {
  99. if (isNaN(window.screenX)) {
  100. x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  101. y=coordinates.y-document.body.scrollTop+window.screenTop;
  102. }
  103. else {
  104. x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  105. y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  106. }
  107. }
  108. else if (document.all) {
  109. x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  110. y=coordinates.y-document.body.scrollTop+window.screenTop;
  111. }
  112. else if (document.layers) {
  113. x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  114. y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  115. }
  116. coordinates.x=x;
  117. coordinates.y=y;
  118. return coordinates;
  119. }
  120. // Functions for IE to get position of an object
  121. function AnchorPosition_getPageOffsetLeft (el) {
  122. var ol=el.offsetLeft;
  123. while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
  124. return ol;
  125. }
  126. function AnchorPosition_getWindowOffsetLeft (el) {
  127. return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
  128. }
  129. function AnchorPosition_getPageOffsetTop (el) {
  130. var ot=el.offsetTop;
  131. while((el=el.offsetParent) != null) { ot += el.offsetTop; }
  132. return ot;
  133. }
  134. function AnchorPosition_getWindowOffsetTop (el) {
  135. return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
  136. }
  137. /* SOURCE FILE: PopupWindow.js */
  138. /*
  139. PopupWindow.js
  140. Author: Matt Kruse
  141. Last modified: 02/16/04
  142. DESCRIPTION: This object allows you to easily and quickly popup a window
  143. in a certain place. The window can either be a DIV or a separate browser
  144. window.
  145. COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
  146. positioning errors - usually with Window positioning - occur on the
  147. Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
  148. window with <STYLE> tags may cause errors.
  149. USAGE:
  150. // Create an object for a WINDOW popup
  151. var win = new PopupWindow();
  152. // Create an object for a DIV window using the DIV named 'mydiv'
  153. var win = new PopupWindow('mydiv');
  154. // Set the window to automatically hide itself when the user clicks
  155. // anywhere else on the page except the popup
  156. win.autoHide();
  157. // Show the window relative to the anchor name passed in
  158. win.showPopup(anchorname);
  159. // Hide the popup
  160. win.hidePopup();
  161. // Set the size of the popup window (only applies to WINDOW popups
  162. win.setSize(width,height);
  163. // Populate the contents of the popup window that will be shown. If you
  164. // change the contents while it is displayed, you will need to refresh()
  165. win.populate(string);
  166. // set the URL of the window, rather than populating its contents
  167. // manually
  168. win.setUrl("http://www.site.com/");
  169. // Refresh the contents of the popup
  170. win.refresh();
  171. // Specify how many pixels to the right of the anchor the popup will appear
  172. win.offsetX = 50;
  173. // Specify how many pixels below the anchor the popup will appear
  174. win.offsetY = 100;
  175. NOTES:
  176. 1) Requires the functions in AnchorPosition.js
  177. 2) Your anchor tag MUST contain both NAME and ID attributes which are the
  178. same. For example:
  179. <A NAME="test" ID="test"> </A>
  180. 3) There must be at least a space between <A> </A> for IE5.5 to see the
  181. anchor tag correctly. Do not do <A></A> with no space.
  182. 4) When a PopupWindow object is created, a handler for 'onmouseup' is
  183. attached to any event handler you may have already defined. Do NOT define
  184. an event handler for 'onmouseup' after you define a PopupWindow object or
  185. the autoHide() will not work correctly.
  186. */
  187. // Set the position of the popup window based on the anchor
  188. function PopupWindow_getXYPosition(anchorname) {
  189. var coordinates;
  190. if (this.type == "WINDOW") {
  191. coordinates = getAnchorWindowPosition(anchorname);
  192. }
  193. else {
  194. coordinates = getAnchorPosition(anchorname);
  195. }
  196. this.x = coordinates.x;
  197. this.y = coordinates.y;
  198. }
  199. // Set width/height of DIV/popup window
  200. function PopupWindow_setSize(width,height) {
  201. this.width = width;
  202. this.height = height;
  203. }
  204. // Fill the window with contents
  205. function PopupWindow_populate(contents) {
  206. this.contents = contents;
  207. this.populated = false;
  208. }
  209. // Set the URL to go to
  210. function PopupWindow_setUrl(url) {
  211. this.url = url;
  212. }
  213. // Set the window popup properties
  214. function PopupWindow_setWindowProperties(props) {
  215. this.windowProperties = props;
  216. }
  217. // Refresh the displayed contents of the popup
  218. function PopupWindow_refresh() {
  219. if (this.divName != null) {
  220. // refresh the DIV object
  221. if (this.use_gebi) {
  222. document.getElementById(this.divName).innerHTML = this.contents;
  223. }
  224. else if (this.use_css) {
  225. document.all[this.divName].innerHTML = this.contents;
  226. }
  227. else if (this.use_layers) {
  228. var d = document.layers[this.divName];
  229. d.document.open();
  230. d.document.writeln(this.contents);
  231. d.document.close();
  232. }
  233. }
  234. else {
  235. if (this.popupWindow != null && !this.popupWindow.closed) {
  236. if (this.url!="") {
  237. this.popupWindow.location.href=this.url;
  238. }
  239. else {
  240. this.popupWindow.document.open();
  241. this.popupWindow.document.writeln(this.contents);
  242. this.popupWindow.document.close();
  243. }
  244. this.popupWindow.focus();
  245. }
  246. }
  247. }
  248. // Position and show the popup, relative to an anchor object
  249. function PopupWindow_showPopup(anchorname) {
  250. this.getXYPosition(anchorname);
  251. this.x += this.offsetX;
  252. this.y += this.offsetY;
  253. if (!this.populated && (this.contents != "")) {
  254. this.populated = true;
  255. this.refresh();
  256. }
  257. if (this.divName != null) {
  258. // Show the DIV object
  259. if (this.use_gebi) {
  260. document.getElementById(this.divName).style.left = this.x + "px";
  261. document.getElementById(this.divName).style.top = this.y;
  262. document.getElementById(this.divName).style.visibility = "visible";
  263. }
  264. else if (this.use_css) {
  265. document.all[this.divName].style.left = this.x;
  266. document.all[this.divName].style.top = this.y;
  267. document.all[this.divName].style.visibility = "visible";
  268. }
  269. else if (this.use_layers) {
  270. document.layers[this.divName].left = this.x;
  271. document.layers[this.divName].top = this.y;
  272. document.layers[this.divName].visibility = "visible";
  273. }
  274. }
  275. else {
  276. if (this.popupWindow == null || this.popupWindow.closed) {
  277. // If the popup window will go off-screen, move it so it doesn't
  278. if (this.x<0) { this.x=0; }
  279. if (this.y<0) { this.y=0; }
  280. if (screen && screen.availHeight) {
  281. if ((this.y + this.height) > screen.availHeight) {
  282. this.y = screen.availHeight - this.height;
  283. }
  284. }
  285. if (screen && screen.availWidth) {
  286. if ((this.x + this.width) > screen.availWidth) {
  287. this.x = screen.availWidth - this.width;
  288. }
  289. }
  290. var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
  291. this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
  292. }
  293. this.refresh();
  294. }
  295. }
  296. // Hide the popup
  297. function PopupWindow_hidePopup() {
  298. if (this.divName != null) {
  299. if (this.use_gebi) {
  300. document.getElementById(this.divName).style.visibility = "hidden";
  301. }
  302. else if (this.use_css) {
  303. document.all[this.divName].style.visibility = "hidden";
  304. }
  305. else if (this.use_layers) {
  306. document.layers[this.divName].visibility = "hidden";
  307. }
  308. }
  309. else {
  310. if (this.popupWindow && !this.popupWindow.closed) {
  311. this.popupWindow.close();
  312. this.popupWindow = null;
  313. }
  314. }
  315. }
  316. // Pass an event and return whether or not it was the popup DIV that was clicked
  317. function PopupWindow_isClicked(e) {
  318. if (this.divName != null) {
  319. if (this.use_layers) {
  320. var clickX = e.pageX;
  321. var clickY = e.pageY;
  322. var t = document.layers[this.divName];
  323. if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
  324. return true;
  325. }
  326. else { return false; }
  327. }
  328. else if (document.all) { // Need to hard-code this to trap IE for error-handling
  329. var t = window.event.srcElement;
  330. while (t.parentElement != null) {
  331. if (t.id==this.divName) {
  332. return true;
  333. }
  334. t = t.parentElement;
  335. }
  336. return false;
  337. }
  338. else if (this.use_gebi && e) {
  339. var t = e.originalTarget;
  340. while (t.parentNode != null) {
  341. if (t.id==this.divName) {
  342. return true;
  343. }
  344. t = t.parentNode;
  345. }
  346. return false;
  347. }
  348. return false;
  349. }
  350. return false;
  351. }
  352. // Check an onMouseDown event to see if we should hide
  353. function PopupWindow_hideIfNotClicked(e) {
  354. if (this.autoHideEnabled && !this.isClicked(e)) {
  355. this.hidePopup();
  356. }
  357. }
  358. // Call this to make the DIV disable automatically when mouse is clicked outside it
  359. function PopupWindow_autoHide() {
  360. this.autoHideEnabled = true;
  361. }
  362. // This global function checks all PopupWindow objects onmouseup to see if they should be hidden
  363. function PopupWindow_hidePopupWindows(e) {
  364. for (var i=0; i<popupWindowObjects.length; i++) {
  365. if (popupWindowObjects[i] != null) {
  366. var p = popupWindowObjects[i];
  367. p.hideIfNotClicked(e);
  368. }
  369. }
  370. }
  371. // Run this immediately to attach the event listener
  372. function PopupWindow_attachListener() {
  373. if (document.layers) {
  374. document.captureEvents(Event.MOUSEUP);
  375. }
  376. window.popupWindowOldEventListener = document.onmouseup;
  377. if (window.popupWindowOldEventListener != null) {
  378. document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
  379. }
  380. else {
  381. document.onmouseup = PopupWindow_hidePopupWindows;
  382. }
  383. }
  384. // CONSTRUCTOR for the PopupWindow object
  385. // Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
  386. function PopupWindow() {
  387. if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
  388. if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
  389. if (!window.listenerAttached) {
  390. window.listenerAttached = true;
  391. PopupWindow_attachListener();
  392. }
  393. this.index = popupWindowIndex++;
  394. popupWindowObjects[this.index] = this;
  395. this.divName = null;
  396. this.popupWindow = null;
  397. this.width=0;
  398. this.height=0;
  399. this.populated = false;
  400. this.visible = false;
  401. this.autoHideEnabled = false;
  402. this.contents = "";
  403. this.url="";
  404. this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
  405. if (arguments.length>0) {
  406. this.type="DIV";
  407. this.divName = arguments[0];
  408. }
  409. else {
  410. this.type="WINDOW";
  411. }
  412. this.use_gebi = false;
  413. this.use_css = false;
  414. this.use_layers = false;
  415. if (document.getElementById) { this.use_gebi = true; }
  416. else if (document.all) { this.use_css = true; }
  417. else if (document.layers) { this.use_layers = true; }
  418. else { this.type = "WINDOW"; }
  419. this.offsetX = 0;
  420. this.offsetY = 0;
  421. // Method mappings
  422. this.getXYPosition = PopupWindow_getXYPosition;
  423. this.populate = PopupWindow_populate;
  424. this.setUrl = PopupWindow_setUrl;
  425. this.setWindowProperties = PopupWindow_setWindowProperties;
  426. this.refresh = PopupWindow_refresh;
  427. this.showPopup = PopupWindow_showPopup;
  428. this.hidePopup = PopupWindow_hidePopup;
  429. this.setSize = PopupWindow_setSize;
  430. this.isClicked = PopupWindow_isClicked;
  431. this.autoHide = PopupWindow_autoHide;
  432. this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
  433. }
  434. /* SOURCE FILE: ColorPicker2.js */
  435. /*
  436. Last modified: 02/24/2003
  437. DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB
  438. form. It uses a color "swatch" to display the standard 216-color web-safe
  439. palette. The user can then click on a color to select it.
  440. COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js.
  441. Only the latest DHTML-capable browsers will show the color and hex values
  442. at the bottom as your mouse goes over them.
  443. USAGE:
  444. // Create a new ColorPicker object using DHTML popup
  445. var cp = new ColorPicker();
  446. // Create a new ColorPicker object using Window Popup
  447. var cp = new ColorPicker('window');
  448. // Add a link in your page to trigger the popup. For example:
  449. <A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A>
  450. // Or use the built-in "select" function to do the dirty work for you:
  451. <A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A>
  452. // If using DHTML popup, write out the required DIV tag near the bottom
  453. // of your page.
  454. <SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
  455. // Write the 'pickColor' function that will be called when the user clicks
  456. // a color and do something with the value. This is only required if you
  457. // want to do something other than simply populate a form field, which is
  458. // what the 'select' function will give you.
  459. function pickColor(color) {
  460. field.value = color;
  461. }
  462. NOTES:
  463. 1) Requires the functions in AnchorPosition.js and PopupWindow.js
  464. 2) Your anchor tag MUST contain both NAME and ID attributes which are the
  465. same. For example:
  466. <A NAME="test" ID="test"> </A>
  467. 3) There must be at least a space between <A> </A> for IE5.5 to see the
  468. anchor tag correctly. Do not do <A></A> with no space.
  469. 4) When a ColorPicker object is created, a handler for 'onmouseup' is
  470. attached to any event handler you may have already defined. Do NOT define
  471. an event handler for 'onmouseup' after you define a ColorPicker object or
  472. the color picker will not hide itself correctly.
  473. */
  474. ColorPicker_targetInput = null;
  475. function ColorPicker_writeDiv() {
  476. document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
  477. }
  478. function ColorPicker_show(anchorname) {
  479. this.showPopup(anchorname);
  480. }
  481. function ColorPicker_pickColor(color,obj) {
  482. obj.hidePopup();
  483. pickColor(color);
  484. }
  485. // A Default "pickColor" function to accept the color passed back from popup.
  486. // User can over-ride this with their own function.
  487. function pickColor(color) {
  488. if (ColorPicker_targetInput==null) {
  489. alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");
  490. return;
  491. }
  492. ColorPicker_targetInput.value = color;
  493. }
  494. // This function is the easiest way to popup the window, select a color, and
  495. // have the value populate a form field, which is what most people want to do.
  496. function ColorPicker_select(inputobj,linkname) {
  497. if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") {
  498. alert("colorpicker.select: Input object passed is not a valid form input object");
  499. window.ColorPicker_targetInput=null;
  500. return;
  501. }
  502. window.ColorPicker_targetInput = inputobj;
  503. this.show(linkname);
  504. }
  505. // This function runs when you move your mouse over a color block, if you have a newer browser
  506. function ColorPicker_highlightColor(c) {
  507. var thedoc = (arguments.length>1)?arguments[1]:window.document;
  508. var d = thedoc.getElementById("colorPickerSelectedColor");
  509. d.style.backgroundColor = c;
  510. d = thedoc.getElementById("colorPickerSelectedColorValue");
  511. d.innerHTML = c;
  512. }
  513. function ColorPicker() {
  514. var windowMode = false;
  515. // Create a new PopupWindow object
  516. if (arguments.length==0) {
  517. var divname = "colorPickerDiv";
  518. }
  519. else if (arguments[0] == "window") {
  520. var divname = '';
  521. windowMode = true;
  522. }
  523. else {
  524. var divname = arguments[0];
  525. }
  526. if (divname != "") {
  527. var cp = new PopupWindow(divname);
  528. }
  529. else {
  530. var cp = new PopupWindow();
  531. cp.setSize(225,250);
  532. }
  533. // Object variables
  534. cp.currentValue = "#FFFFFF";
  535. // Method Mappings
  536. cp.writeDiv = ColorPicker_writeDiv;
  537. cp.highlightColor = ColorPicker_highlightColor;
  538. cp.show = ColorPicker_show;
  539. cp.select = ColorPicker_select;
  540. // Code to populate color picker window
  541. var colors = new Array( "#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099",
  542. "#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099",
  543. "#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099",
  544. "#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF",
  545. "#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F",
  546. "#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000",
  547. "#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399",
  548. "#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399",
  549. "#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399",
  550. "#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF",
  551. "#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F",
  552. "#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00",
  553. "#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699",
  554. "#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699",
  555. "#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699",
  556. "#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F",
  557. "#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F",
  558. "#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F",
  559. "#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999",
  560. "#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999",
  561. "#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999",
  562. "#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF",
  563. "#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F",
  564. "#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000",
  565. "#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99",
  566. "#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99",
  567. "#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99",
  568. "#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF",
  569. "#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F",
  570. "#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00",
  571. "#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99",
  572. "#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99",
  573. "#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99",
  574. "#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F",
  575. "#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F",
  576. "#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F",
  577. "#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666",
  578. "#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000",
  579. "#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000",
  580. "#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999",
  581. "#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF",
  582. "#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF",
  583. "#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66",
  584. "#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00",
  585. "#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000",
  586. "#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099",
  587. "#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF",
  588. "#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF",
  589. "#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF",
  590. "#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC",
  591. "#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000",
  592. "#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900",
  593. "#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33",
  594. "#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF",
  595. "#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF",
  596. "#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF",
  597. "#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F",
  598. "#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F",
  599. "#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F",
  600. "#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000");
  601. var total = colors.length;
  602. var width = 72;
  603. var cp_contents = "";
  604. var windowRef = (windowMode)?"window.opener.":"";
  605. if (windowMode) {
  606. cp_contents += "<html><head><title>Select Color</title></head>";
  607. cp_contents += "<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>";
  608. }
  609. cp_contents += "<table style='border: none;' cellspacing=0 cellpadding=0>";
  610. var use_highlight = (document.getElementById || document.all)?true:false;
  611. for (var i=0; i<total; i++) {
  612. if ((i % width) == 0) { cp_contents += "<tr>"; }
  613. if (use_highlight) { var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"'; }
  614. else { mo = ""; }
  615. cp_contents += '<td style="background-color: '+colors[i]+';"><a href="javascript:void()" onclick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+'>&nbsp;</a></td>';
  616. if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
  617. cp_contents += "</tr>";
  618. }
  619. }
  620. // If the browser supports dynamically changing TD cells, add the fancy stuff
  621. if (document.getElementById) {
  622. var width1 = Math.floor(width/2);
  623. var width2 = width = width1;
  624. cp_contents += "<tr><td colspan='"+width1+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+width2+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>";
  625. }
  626. cp_contents += "</table>";
  627. if (windowMode) {
  628. cp_contents += "</span></body></html>";
  629. }
  630. // end populate code
  631. // Write the contents to the popup object
  632. cp.populate(cp_contents+"\n");
  633. // Move the table down a bit so you can see it
  634. cp.offsetY = 25;
  635. cp.autoHide();
  636. return cp;
  637. }