/*
	Colorpicker.js
	20080725 adam.prall@thinkingman.com
*/

tmColorPicker = new Class({
	Implements: Options,
	
	options: {
		colors:	{
			'_pan':		'Pantone',
			'_rgb':		'RGB Color',
			'aqua':		'Aqua',
			'black':	'Black',
			'blue':		'Blue',
			'fuchsia':	'Fuchsia',
			'gray':		'Gray',
			'green':	'Green',
			'lime':		'Lime',
			'maroon':	'Maroon',
			'navy':		'Navy',
			'olive':	'Olive',
			'purple':	'Purple',
			'red':		'Red',
			'silver':	'Silver',
			'teal':		'Teal',
			'white':	'White',
			'yellow':	'Yellow'
		},
		disabled:		false
	},
	'pantone':		{
		'100':		'f4ed7c',
		'101':		'f4ed47',
		'102':		'f9e814',
		'103':		'c6ad0f',
		'104':		'ad9b0c',
		'105':		'82750f',
		'106':		'f7e859',
		'107':		'f9e526',
		'108':		'f9dd16',
		'109':		'f9d616',
		'110':		'd8b511',
		'111':		'aa930a',
		'112':		'99840a',
		'113':		'f9e55b',
		'114':		'f9e24c',
		'115':		'f9e04c',
		'116':		'fcd116',
		'116 2x':	'f7b50c',
		'117':		'c6a00c',
		'118':		'aa8e0a',
		'119':		'897719',
		'120':		'f9e27f',
		'1205':		'f7e8aa',
		'121':		'f9e070',
		'1215':		'f9e08c',
		'122':		'fcd856',
		'1225':		'ffcc49',
		'123':		'ffc61e',
		'1235':		'fcb514',
		'124':		'e0aa0f',
		'1245':		'bf910c',
		'125':		'b58c0a',
		'1255':		'a37f14',
		'126':		'a38205',
		'1265':		'7c6316',
		'127':		'f4e287',
		'128':		'f4db60',
		'129':		'f2d13d',
		'130':		'eaaf0f',
		'130 2x':	'e29100',
		'131':		'c6930a',
		'132':		'9e7c0a',
		'133':		'705b0a',
		'134':		'ffd87f',
		'1345':		'ffd691',
		'135':		'fcc963',
		'1355':		'fcce87',
		'136':		'fcbf49',
		'1365':		'fcba5e',
		'137':		'fca311',
		'1375':		'f99b0c',
		'138':		'd88c02',
		'1385':		'cc7a02',
		'139':		'af7505',
		'1395':		'996007',
		'140':		'7a5b11',
		'1405':		'6b4714',
		'141':		'f2ce68',
		'142':		'f2bf49',
		'143':		'efb22d',
		'144':		'e28c05',
		'145':		'c67f07',
		'146':		'9e6b05',
		'147':		'725e26',
		'148':		'ffd69b',
		'1485':		'ffb777',
		'149':		'fccc93',
		'1495':		'ff993f',
		'150':		'fcad56',
		'1505':		'f47c00',
		'151':		'f77f00',
		'152':		'dd7500',
		'1525':		'b55400',
		'153':		'bc6d0a',
		'1535':		'8c4400',
		'154':		'995905',
		'1545':		'4c280f',
		'155':		'f4dbaa',
		'1555':		'f9bf9e',
		'156':		'f2c68c',
		'1565':		'fca577',
		'157':		'eda04f',
		'1575':		'fc8744',
		'158':		'e87511',
		'1585':		'f96b07',
		'159':		'c66005',
		'1595':		'd15b05',
		'160':		'9e540a',
		'1605':		'a04f11',
		'161':		'633a11',
		'1615':		'843f0f',
		'162':		'f9c6aa',
		'1625':		'f9a58c',
		'163':		'fc9e70',
		'1635':		'f98e6d',
		'164':		'fc7f3f',
		'1645':		'f97242',
		'165':		'f96302',
		'165 2x':	'ea4f00',
		'1655':		'f95602',
		'166':		'dd5900',
		'1665':		'dd4f05',
		'167':		'bc4f07',
		'1675':		'a53f0f',
		'168':		'6d3011',
		'1685':		'843511',
		'169':		'f9baaa',
		'170':		'f98972',
		'171':		'f9603a',
		'172':		'f74902',
		'173':		'd14414',
		'174':		'933311',
		'175':		'6d3321',
		'176':		'f9afad',
		'1765':		'f99ea3',
		'1767':		'f9b2b7',
		'177':		'f9827f',
		'1775':		'f9848e',
		'1777':		'fc6675',
		'178':		'f95e59',
		'1785':		'fc4f59',
		'1787':		'f43f4f',
		'1788':		'ef2b2d',
		'1788 2x':	'd62100',
		'179':		'e23d28',
		'1795':		'd62828',
		'1797':		'cc2d30',
		'180':		'c13828',
		'1805':		'af2626',
		'1807':		'a03033',
		'181':		'7c2d23',
		'1810':		'7c211e',
		'1817':		'5b2d28',
		'182':		'f9bfc1',
		'183':		'fc8c99',
		'184':		'fc5e72',
		'185':		'e8112d',
		'185 2x':	'd11600',
		'186':		'ce1126',
		'187':		'af1e2d',
		'188':		'7c2128',
		'189':		'ffa3b2',
		'1895':		'fcbfc9',
		'190':		'fc758e',
		'1905':		'fc9bb2',
		'191':		'f4476b',
		'1915':		'f4547c',
		'192':		'e5053a',
		'1925':		'e00747',
		'193':		'db828c',
		'1935':		'c10538',
		'194':		'992135',
		'1945':		'a80c35',
		'1955':		'931638',
		'196':		'f4c9c9',
		'197':		'ef99a3',
		'198':		'772d35',
		'199':		'd81c3f',
		'200':		'c41e3a',
		'201':		'a32638',
		'202':		'8c2633',
		'203':		'f2afc1',
		'204':		'ed7a9e',
		'205':		'e54c7c',
		'206':		'd30547',
		'207':		'baaa9e',
		'208':		'8e2344',
		'209':		'75263d',
		'210':		'ffa0bf',
		'211':		'ff77a8',
		'212':		'f94f8e',
		'213':		'ea0f6b',
		'214':		'cc0256',
		'215':		'a50544',
		'216':		'7c1e3f',
		'217':		'f4bfd1',
		'218':		'ed72aa',
		'219':		'e22882',
		'220':		'aa004f',
		'221':		'930042',
		'222':		'70193d',
		'223':		'f993c4',
		'224':		'f46baf',
		'225':		'ed2893',
		'226':		'd60270',
		'227':		'ad005b',
		'228':		'8c004c',
		'229':		'6d213f',
		'230':		'ffa0cc',
		'231':		'fc70ba',
		'232':		'f43fa5',
		'233':		'ce007c',
		'234':		'aa0066',
		'235':		'8e0554',
		'236':		'f9afd3',
		'2365':		'f7c4d8',
		'237':		'f484c4',
		'2375':		'ea6bbf',
		'238':		'ed4faf',
		'2385':		'db28a5',
		'239':		'e0219e',
		'239 2x':	'c4057c',
		'2395':		'c4008c',
		'240':		'c40f89',
		'2405':		'a8007a',
		'241':		'ad0075',
		'2415':		'9b0070',
		'242':		'7c1c51',
		'2425':		'87005b',
		'243':		'f2bad8',
		'244':		'eda0d3',
		'245':		'e87fc9',
		'246':		'cc00a0',
		'247':		'b7008e',
		'248':		'a3057f',
		'249':		'7f2860',
		'250':		'edc4dd',
		'251':		'e29ed6',
		'252':		'd36bc6',
		'253':		'af23a5',
		'254':		'a02d96',
		'255':		'772d6b',
		'256':		'e5c4d6',
		'2562':		'd8a8d8',
		'2563':		'd1a0cc',
		'2567':		'bf93cc',
		'257':		'd3a5c9',
		'2572':		'c687d1',
		'2573':		'ba7cbc',
		'2577':		'aa72bf',
		'258':		'9b4f96',
		'2582':		'aa47ba',
		'2583':		'9e4fa5',
		'2587':		'8e47ad',
		'259':		'72166b',
		'2592':		'930fa5',
		'2592 2x':	'720082',
		'2593':		'872b93',
		'2597':		'66008c',
		'260':		'681e5b',
		'2602':		'820c8e',
		'2603':		'70147a',
		'2607':		'5b027a',
		'261':		'5e2154',
		'2612':		'701e72',
		'2613':		'66116d',
		'2617':		'560c70',
		'262':		'542344',
		'2622':		'602d59',
		'2623':		'5b195e',
		'2627':		'4c145e',
		'263':		'e0cee0',
		'2635':		'c9add8',
		'264':		'c6aadb',
		'2645':		'b591d1',
		'265':		'9663c4',
		'2655':		'9b6dc6',
		'266':		'6d28aa',
		'2665':		'894fbf',
		'267':		'59118e',
		'268':		'4f2170',
		'2685':		'56008c',
		'269':		'442359',
		'2695':		'44235e',
		'270':		'baafd3',
		'2705':		'ad9ed3',
		'2706':		'd1cedd',
		'2707':		'bfd1e5',
		'2708':		'afbcdb',
		'271':		'9e91c6',
		'2715':		'937acc',
		'2716':		'a5a0d6',
		'2717':		'a5bae0',
		'2718':		'5b77cc',
		'272':		'8977ba',
		'2725':		'7251bc',
		'2726':		'6656bc',
		'2727':		'5e68c4',
		'2728':		'3044b5',
		'273':		'38197a',
		'2735':		'4f0093',
		'2736':		'4930ad',
		'2738':		'2d008e',
		'274':		'2b1166',
		'2745':		'3f0077',
		'2746':		'3f2893',
		'2747':		'1c146b',
		'2748':		'1e1c77',
		'275':		'260f54',
		'2755':		'35006d',
		'2756':		'332875',
		'2757':		'141654',
		'2758':		'192168',
		'276':		'2b2147',
		'2765':		'2b0c56',
		'2766':		'2b265b',
		'2767':		'14213d',
		'2768':		'112151',
		'277':		'b5d1e8',
		'278':		'99badd',
		'279':		'6689cc',
		'280':		'002b7f',
		'281':		'002868',
		'282':		'002654',
		'283':		'9bc4e2',
		'284':		'75aadb',
		'285':		'3a75c4',
		'286':		'0038a8',
		'287':		'003893',
		'288':		'00337f',
		'289':		'002649',
		'290':		'c4d8e2',
		'2905':		'93c6e0',
		'291':		'a8cee2',
		'2915':		'60afdd',
		'292':		'75b2dd',
		'2925':		'008ed6',
		'293':		'0051ba',
		'2935':		'005bbf',
		'294':		'003f87',
		'2945':		'0054a0',
		'295':		'00386b',
		'2955':		'003d6b',
		'296':		'002d47',
		'2965':		'00334c',
		'297':		'82c6e2',
		'2975':		'bae0e2',
		'298':		'51b5e0',
		'2985':		'51bfe2',
		'299':		'00a3dd',
		'299 2x':	'007fcc',
		'2995':		'00a5db',
		'300':		'0072c6',
		'3005':		'0084c9',
		'301':		'005b99',
		'3015':		'00709e',
		'302':		'004f6d',
		'3025':		'00546b',
		'303':		'003f54',
		'3035':		'004454',
		'304':		'a5dde2',
		'305':		'70cee2',
		'306':		'00bce2',
		'306 2x':	'00a3d1',
		'307':		'007aa5',
		'308':		'00607c',
		'309':		'003f49',
		'310':		'72d1dd',
		'3105':		'7fd6db',
		'311':		'28c4d8',
		'3115':		'2dc6d6',
		'312':		'00adc6',
		'3125':		'00b7c6',
		'313':		'0099b5',
		'3135':		'009baa',
		'314':		'00829b',
		'3145':		'00848e',
		'315':		'006b77',
		'3155':		'006d75',
		'316':		'00494f',
		'3165':		'00565b',
		'317':		'c9e8dd',
		'318':		'93dddb',
		'319':		'4cced1',
		'320':		'009ea0',
		'320 2x':	'007f82',
		'321':		'008789',
		'322':		'007272',
		'323':		'006663',
		'324':		'aaddd6',
		'3242':		'87ddd1',
		'3245':		'8ce0d1',
		'3248':		'7ad3c1',
		'325':		'56c9c1',
		'3252':		'56d6c9',
		'3255':		'47d6c1',
		'3258':		'35c4af',
		'326':		'00b2aa',
		'3262':		'00c1b5',
		'3265':		'00c6b2',
		'3268':		'00af99',
		'327':		'008c82',
		'327 2x':	'008977',
		'3272':		'00aa9e',
		'3275':		'00b2a0',
		'3278':		'009b84',
		'328':		'007770',
		'3282':		'008c82',
		'3285':		'009987',
		'3288':		'008270',
		'329':		'006d66',
		'3292':		'006056',
		'3295':		'008272',
		'3298':		'006b5b',
		'330':		'005951',
		'3302':		'00493f',
		'3305':		'004f42',
		'3308':		'004438',
		'331':		'baead6',
		'332':		'a0e5ce',
		'333':		'5eddc1',
		'334':		'00997c',
		'335':		'007c66',
		'336':		'006854',
		'337':		'9bdbc1',
		'3375':		'8ee2bc',
		'338':		'7ad1b5',
		'3385':		'54d8a8',
		'339':		'00b28c',
		'3395':		'00c993',
		'340':		'009977',
		'3405':		'00b27a',
		'341':		'007a5e',
		'3415':		'007c59',
		'342':		'006b54',
		'3425':		'006847',
		'343':		'00563f',
		'3435':		'024930',
		'344':		'b5e2bf',
		'345':		'96d8af',
		'346':		'70ce9b',
		'347':		'009e60',
		'348':		'008751',
		'349':		'006b3f',
		'350':		'234f33',
		'351':		'b5e8bf',
		'352':		'99e5b2',
		'353':		'84e2a8',
		'354':		'00b760',
		'355':		'009e49',
		'356':		'007a3d',
		'357':		'215b33',
		'358':		'aadd96',
		'359':		'a0db8e',
		'360':		'60c659',
		'361':		'1eb53a',
		'362':		'339e35',
		'363':		'3d8e33',
		'364':		'3a7728',
		'365':		'd3e8a3',
		'366':		'c4e58e',
		'367':		'aadd6d',
		'368':		'5bbf21',
		'368 2x':	'009e0f',
		'369':		'56aa1c',
		'370':		'568e14',
		'371':		'566b21',
		'372':		'd8ed96',
		'373':		'ceea82',
		'374':		'bae860',
		'375':		'8cd600',
		'375 2x':	'54bc00',
		'376':		'7fba00',
		'377':		'709302',
		'378':		'566314',
		'379':		'e0ea68',
		'380':		'd6e542',
		'381':		'cce226',
		'382':		'bad80a',
		'382 2x':	'9ec400',
		'383':		'a3af07',
		'384':		'939905',
		'385':		'707014',
		'386':		'e8ed60',
		'387':		'e0ed44',
		'388':		'd6e80f',
		'389':		'cee007',
		'390':		'bac405',
		'391':		'9e9e07',
		'392':		'848205',
		'393':		'f2ef87',
		'3935':		'f2ed6d',
		'394':		'eaed35',
		'3945':		'efea07',
		'395':		'e5e811',
		'3955':		'ede211',
		'396':		'e0e20c',
		'3965':		'e8dd11',
		'397':		'c1bf0a',
		'3975':		'b5a80c',
		'398':		'afa80a',
		'3985':		'998c0a',
		'399':		'998e07',
		'3995':		'6d6002',
		'400':		'd1c6b5',
		'401':		'c1b5a5',
		'402':		'afa593',
		'403':		'998c7c',
		'404':		'827566',
		'405':		'6b5e4f',
		'406':		'cec1b5',
		'408':		'a8998c',
		'409':		'99897c',
		'410':		'7c6d63',
		'411':		'66594c',
		'412':		'3d3028',
		'413':		'c6c1b2',
		'414':		'b5afa0',
		'415':		'a39e8c',
		'416':		'8e8c7a',
		'417':		'777263',
		'418':		'605e4f',
		'419':		'282821',
		'420':		'd1ccbf',
		'421':		'bfbaaf',
		'422':		'afaaa3',
		'423':		'96938e',
		'424':		'827f77',
		'425':		'60605b',
		'426':		'2b2b28',
		'427':		'dddbd1',
		'428':		'd1cec6',
		'429':		'adafaa',
		'430':		'919693',
		'431':		'666d70',
		'432':		'444f51',
		'433':		'30383a',
		'433 2x':	'0a0c11',
		'434':		'e0d1c6',
		'435':		'd3bfb7',
		'436':		'bca59e',
		'437':		'8c706b',
		'438':		'593f3d',
		'439':		'493533',
		'440':		'3f302b',
		'441':		'd1d1c6',
		'442':		'babfb7',
		'443':		'a3a8a3',
		'444':		'898e8c',
		'445':		'565959',
		'446':		'494c49',
		'447':		'3f3f38',
		'448':		'54472d',
		'4485':		'604c11',
		'449':		'544726',
		'4495':		'877530',
		'450':		'60542b',
		'4505':		'a09151',
		'451':		'ada07a',
		'4515':		'bcad75',
		'452':		'c4b796',
		'452 2x':	'009944',
		'4525':		'ccbf8e',
		'453':		'd6ccaf',
		'4535':		'dbcea5',
		'454':		'e2d8bf',
		'4545':		'e5dbba',
		'455':		'665614',
		'456':		'998714',
		'457':		'b59b0c',
		'458':		'ddcc6b',
		'459':		'e2d67c',
		'460':		'eadd96',
		'461':		'ede5ad',
		'462':		'5b4723',
		'4625':		'472311',
		'463':		'755426',
		'4635':		'8c5933',
		'464':		'876028',
		'464 2x':	'704214',
		'4645':		'b28260',
		'465':		'c1a875',
		'4655':		'c49977',
		'466':		'd1bf91',
		'4665':		'd8b596',
		'467':		'ddcca5',
		'4675':		'e5c6aa',
		'468':		'e2d6b5',
		'4685':		'edd3bc',
		'469':		'603311',
		'4695':		'51261c',
		'470':		'9b4f19',
		'4705':		'7c513d',
		'471':		'bc5e1e',
		'471 2x':	'a34402',
		'4715':		'99705b',
		'472':		'eaaa7a',
		'4725':		'b5917c',
		'473':		'f4c4a0',
		'4735':		'ccaf9b',
		'474':		'f4ccaa',
		'4745':		'd8bfaa',
		'475':		'f7d3b5',
		'4755':		'e2ccba',
		'476':		'593d2b',
		'477':		'633826',
		'478':		'7a3f28',
		'479':		'af8970',
		'480':		'd3b7a3',
		'481':		'e0ccba',
		'482':		'e5d3c1',
		'483':		'6b3021',
		'484':		'9b301c',
		'485':		'd81e05',
		'485 2x':	'cc0c00',
		'486':		'ed9e84',
		'487':		'efb5a0',
		'488':		'f2c4af',
		'489':		'f2d1bf',
		'490':		'5b2626',
		'491':		'752828',
		'492':		'913338',
		'494':		'f2adb2',
		'495':		'f4bcbf',
		'496':		'f7c9c6',
		'497':		'512826',
		'4975':		'441e1c',
		'498':		'6d332b',
		'4985':		'844949',
		'499':		'7a382d',
		'4995':		'a56b6d',
		'500':		'ce898c',
		'5005':		'bc8787',
		'501':		'eab2b2',
		'5015':		'd8ada8',
		'502':		'f2c6c4',
		'5025':		'e2bcb7',
		'503':		'f4d1cc',
		'5035':		'edcec6',
		'504':		'511e26',
		'505':		'661e2b',
		'506':		'7a2638',
		'507':		'd8899b',
		'508':		'e8a5af',
		'509':		'f2babf',
		'510':		'f4c6c9',
		'511':		'602144',
		'5115':		'4f213a',
		'512':		'84216b',
		'5125':		'754760',
		'513':		'9e2387',
		'5135':		'936b7f',
		'514':		'd884bc',
		'5145':		'ad8799',
		'515':		'e8a3c9',
		'5155':		'ccafb7',
		'516':		'f2bad3',
		'5165':		'e0c9cc',
		'517':		'f4ccd8',
		'5175':		'e8d6d1',
		'518':		'512d44',
		'5185':		'472835',
		'519':		'63305e',
		'5195':		'593344',
		'520':		'703572',
		'5205':		'8e6877',
		'521':		'b58cb2',
		'5215':		'b5939b',
		'522':		'c6a3c1',
		'5225':		'ccadaf',
		'523':		'd3b7cc',
		'5235':		'ddc6c4',
		'524':		'e2ccd3',
		'5245':		'e5d3cc',
		'525':		'512654',
		'5255':		'35264f',
		'526':		'68217a',
		'5265':		'493d63',
		'527':		'7a1e99',
		'5275':		'605677',
		'528':		'af72c1',
		'5285':		'8c8299',
		'529':		'cea3d3',
		'5295':		'b2a8b5',
		'530':		'd6afd6',
		'5305':		'ccc1c6',
		'531':		'e5c6db',
		'5315':		'dbd3d3',
		'532':		'353842',
		'533':		'353f5b',
		'534':		'3a4972',
		'535':		'9ba3b7',
		'536':		'adb2c1',
		'537':		'c4c6ce',
		'538':		'd6d3d6',
		'539':		'003049',
		'5395':		'02283a',
		'540':		'00335b',
		'5405':		'3f6075',
		'541':		'003f77',
		'5415':		'607c8c',
		'542':		'6693bc',
		'5425':		'8499a5',
		'543':		'93b7d1',
		'5435':		'afbcbf',
		'544':		'b7ccdb',
		'5445':		'c4cccc',
		'545':		'c4d3dd',
		'5455':		'd6d8d3',
		'546':		'0c3844',
		'5463':		'00353a',
		'5467':		'193833',
		'547':		'003f54',
		'5473':		'26686d',
		'5477':		'3a564f',
		'548':		'004459',
		'5483':		'609191',
		'5487':		'667c72',
		'549':		'5e99aa',
		'5493':		'8cafad',
		'5497':		'91a399',
		'550':		'87afbf',
		'5503':		'aac4bf',
		'5507':		'afbab2',
		'551':		'a3c1c9',
		'5513':		'ced8d1',
		'5517':		'c9cec4',
		'552':		'c4d6d6',
		'5523':		'd6ddd6',
		'5527':		'ced1c6',
		'553':		'234435',
		'5535':		'213d30',
		'554':		'195e47',
		'5545':		'4f6d5e',
		'555':		'076d54',
		'5555':		'779182',
		'556':		'7aa891',
		'5565':		'96aa99',
		'557':		'a3c1ad',
		'5575':		'afbfad',
		'558':		'b7cebc',
		'5585':		'c4cebf',
		'559':		'c6d6c4',
		'5595':		'd8dbcc',
		'560':		'2b4c3f',
		'5605':		'233a2d',
		'561':		'266659',
		'5615':		'546856',
		'562':		'1e7a6d',
		'5625':		'728470',
		'563':		'7fbcaa',
		'5635':		'9eaa99',
		'564':		'05705e',
		'5645':		'bcc1b2',
		'565':		'bcdbcc',
		'5655':		'c6ccba',
		'566':		'd1e2d3',
		'5665':		'd6d6c6',
		'567':		'265142',
		'569':		'008772',
		'570':		'7fc6b2',
		'571':		'aadbc6',
		'572':		'bce2ce',
		'573':		'cce5d6',
		'574':		'495928',
		'5743':		'3f4926',
		'5747':		'424716',
		'575':		'547730',
		'5753':		'5e663a',
		'5757':		'6b702b',
		'576':		'608e3a',
		'5763':		'777c4f',
		'5767':		'8c914f',
		'577':		'b5cc8e',
		'5773':		'9b9e72',
		'5777':		'aaad75',
		'578':		'c6d6a0',
		'5783':		'b5b58e',
		'5787':		'c6c699',
		'579':		'c9d6a3',
		'5793':		'c6c6a5',
		'5797':		'd3d1aa',
		'580':		'd8ddb5',
		'5803':		'd8d6b7',
		'5807':		'e0ddbc',
		'581':		'605e11',
		'5815':		'494411',
		'582':		'878905',
		'5825':		'75702b',
		'583':		'aaba0a',
		'5835':		'9e9959',
		'584':		'ced649',
		'5845':		'b2aa70',
		'585':		'dbe06b',
		'5855':		'ccc693',
		'586':		'e2e584',
		'5865':		'd6cea3',
		'587':		'e8e89b',
		'5875':		'e0dbb5',
		'600':		'f4edaf',
		'601':		'f2ed9e',
		'602':		'f2ea87',
		'603':		'ede85b',
		'604':		'e8dd21',
		'605':		'ddce11',
		'606':		'd3bf11',
		'607':		'f2eabc',
		'608':		'efe8ad',
		'609':		'eae596',
		'610':		'e2db72',
		'611':		'd6ce49',
		'612':		'c4ba00',
		'613':		'afa00c',
		'614':		'eae2b7',
		'615':		'e2dbaa',
		'616':		'ddd69b',
		'617':		'ccc47c',
		'618':		'b5aa59',
		'619':		'968c28',
		'620':		'847711',
		'621':		'd8ddce',
		'622':		'c1d1bf',
		'623':		'a5bfaa',
		'624':		'7fa08c',
		'625':		'5b8772',
		'626':		'21543f',
		'627':		'0c3026',
		'628':		'cce2dd',
		'629':		'b2d8d8',
		'630':		'8cccd3',
		'631':		'54b7c6',
		'632':		'00a0ba',
		'633':		'007f99',
		'634':		'00667f',
		'635':		'bae0e0',
		'636':		'99d6dd',
		'637':		'6bc9db',
		'638':		'00b5d6',
		'639':		'00a0c4',
		'640':		'008cb2',
		'641':		'007aa5',
		'642':		'd1d8d8',
		'643':		'c6d1d6',
		'644':		'9bafc4',
		'645':		'7796b2',
		'646':		'5e82a3',
		'647':		'26547c',
		'648':		'00305e',
		'649':		'd6d6d8',
		'650':		'bfc6d1',
		'651':		'9baabf',
		'652':		'6d87a8',
		'653':		'335687',
		'654':		'0f2b5b',
		'655':		'0c1c47',
		'656':		'd6dbe0',
		'657':		'c1c9dd',
		'658':		'a5afd6',
		'659':		'7f8cbf',
		'660':		'5960a8',
		'661':		'2d338e',
		'662':		'0c1975',
		'663':		'e2d3d6',
		'664':		'd8ccd1',
		'665':		'c6b5c4',
		'666':		'a893ad',
		'667':		'7f6689',
		'668':		'664975',
		'669':		'472b59',
		'670':		'f2d6d8',
		'671':		'efc6d3',
		'672':		'eaaac4',
		'673':		'e08cb2',
		'674':		'd36b9e',
		'675':		'bc3877',
		'676':		'a00054',
		'677':		'edd6d6',
		'678':		'eaccce',
		'679':		'e5bfc6',
		'680':		'd39eaf',
		'681':		'b7728e',
		'682':		'a05175',
		'683':		'7f284f',
		'684':		'efccce',
		'685':		'eabfc4',
		'686':		'e0aaba',
		'687':		'c9899e',
		'688':		'b26684',
		'689':		'934266',
		'690':		'702342',
		'691':		'efd1c9',
		'692':		'e8bfba',
		'693':		'dba8a5',
		'694':		'c98c8c',
		'695':		'b26b70',
		'696':		'8e4749',
		'697':		'7f383a',
		'698':		'f7d1cc',
		'699':		'f7bfbf',
		'700':		'f2a5aa',
		'701':		'e8878e',
		'702':		'd6606d',
		'703':		'b73844',
		'704':		'9e2828',
		'705':		'f9ddd6',
		'706':		'fcc9c6',
		'707':		'fcadaf',
		'708':		'f98e99',
		'709':		'f26877',
		'710':		'e04251',
		'711':		'd12d33',
		'712':		'ffd3aa',
		'713':		'f9c9a3',
		'714':		'f9ba82',
		'715':		'fc9e49',
		'716':		'f28411',
		'717':		'd36d00',
		'718':		'bf5b00',
		'719':		'f4d1af',
		'720':		'efc49e',
		'721':		'e8b282',
		'722':		'd18e54',
		'723':		'ba7530',
		'724':		'8e4905',
		'725':		'753802',
		'726':		'edd3b5',
		'727':		'e2bf9b',
		'728':		'd3a87c',
		'729':		'c18e60',
		'730':		'aa753f',
		'731':		'723f0a',
		'732':		'60330a',
		'801':		'00aacc',
		'801 2x':	'0089af',
		'802':		'60dd49',
		'802 2x':	'1cce28',
		'803':		'ffed38',
		'803 2x':	'ffd816',
		'804':		'ff9338',
		'804 2x':	'ff7f1e',
		'805':		'f95951',
		'805 2x':	'f93a2b',
		'806':		'ff0093',
		'806 2x':	'f7027c',
		'807':		'd6009e',
		'807 2x':	'bf008c',
		'808':		'00b59b',
		'808 2x':	'00a087',
		'809':		'dde00f',
		'809 2x':	'd6d60c',
		'810':		'ffcc1e',
		'810 2x':	'ffbc21',
		'811':		'ff7247',
		'811 2x':	'ff5416',
		'812':		'fc2366',
		'812 2x':	'fc074f',
		'813':		'e50099',
		'813 2x':	'd10084',
		'814':		'8c60c1',
		'814 2x':	'703faf'
	},
	
	field:				null,
	swatchCont:			null,
	addType:			'html',
	addColor:			'white',
	list:				{},
	
	initialize: 		function(fld,opts) {
		fld = $(fld);
		if ( fld ) {
			this.field = fld;
			this.setOptions(opts);
			this.initDivs();
			this.loadFieldValues();
			this.setDisabled( this.options.disabled );
		} else {
			this.error(fld+' is not a field!');
		}
	},
	
	initDivs:			function() {
		this.swatchCont = new Element('div',{'class':'swatchCont clearfix'});
		this.field.setStyle('display','none');
		this.swatchAdd = new Element('div',{'class':'swatch swatchAdd'});
		this.swatchCol= new Element('div',{'class':'swatchCol','html':'+'});
		//
		this.swatchSel= new Element('select',{'class':'swatchSel'});
		this.swatchTxt= new Element('input',{'class':'swatchTxt','disabled':true});
		this.swatchBtn= new Element('input',{'type':'button','value':'Add','disabled':true,'class':'swatchBtn'});
		//
		for ( col in this.options.colors ) {
			new Element('option',{'value':col,'html':this.options.colors[col]}).inject(this.swatchSel,'bottom');
		}
		
		this.swatchCont.inject(this.field,'after');
		this.swatchAdd.inject(this.swatchCont,'bottom');
		this.swatchCol.inject(this.swatchAdd,'bottom');
		this.swatchSel.inject(this.swatchAdd,'bottom');
		this.swatchTxt.inject(this.swatchAdd,'bottom');
		this.swatchBtn.inject(this.swatchAdd,'bottom');
		
		this.swatchSel.tmObj = this.swatchTxt.tmObj = this.swatchBtn.tmObj = this;
		
		this.swatchSel.addEvent('change',function() {
			this.tmObj.chgSel();
		});
		this.swatchTxt.addEvent('keyup',function(event) {
			this.tmObj.chgTxt();
			if ( event.key == 'enter' || event.key == 'return' ) {
				this.tmObj.chgBtn();
				stop();
			}
		});
		this.swatchBtn.addEvent('click',function() {
			this.tmObj.chgBtn();
		});
	},
	
	loadFieldValues:	function() {
		var dispColor='';
		var list = this.field.value.split(', ');
		if (list.length < 1) return;
		for (var key=0;key<list.length;key++) {
			if ( typeof(list[key])==undefined || list[key]=='undefined' || list[key]=='' ) continue;
			//alert(list+','+key+','+list[key]+','+list[key].length);
			var toAdd = list[key].split(':');

			if ( toAdd[0] == 'html' ) {
				dispColor = toAdd[1];
				if ( typeof(this.options.colors[toAdd[1]])==undefined ) {
					window.tm.log('html '+toAdd[1]+' DNE!');
					continue;
				} else {
					this.addName = this.options.colors[toAdd[1]];
				}
			} else if ( toAdd[0] == 'pms' ) {
				if ( typeof(this.pantone[toAdd[1]])==undefined ) {
					window.tm.log('pms '+toAdd[1]+' DNE!');
					continue;
				} else {
					dispColor = '#'+this.pantone[toAdd[1]];
					this.addName = 'PMS '+toAdd[1];
				}
			} else if ( toAdd[0] == 'rgb' ) {
				dispColor = toAdd[1];
				this.addName = 'RGB #'+toAdd[1];
			}
			this.addType = toAdd[0];
			this.addColor = toAdd[1];
			this.chgBtn(dispColor);
		}
		this.updateList();
		this.setCol('#fff','',false,'',true);
	},
	
	setDisabled:		function(dis) {
		dis = dis ? true:false;
		this.disabled = dis;
		if ( this.disabled ) {
			this.swatchAdd.setStyle('opacity',0.3);
		} else {
			this.swatchAdd.setStyle('opacity',1.0);
		}
		
		this.swatchSel.set('disabled',this.disabled);
		
		if ( ! this.disabled ) {
			this.chgSel();
		} else {
			this.swatchTxt.set('disabled',true);
			this.swatchBtn.set('disabled',true);
		}
		
		for ( key in this.list ) {
			if (this.list[key].btnElem != undefined) {
				this.list[key].btnElem.set('disabled',this.disabled);
			}
		}
	},
	
	chgSel:				function() {
		this.swatchTxt.value = '';
		if ( this.swatchSel.selectedIndex < 2 ) {
			this.setCol('#fff','',false);
			this.swatchBtn.set('disabled',true);
			this.swatchTxt.set('disabled',false);
			this.swatchTxt.focus();
			if (this.swatchSel.selectedIndex==0) {
				this.addType = 'pms';
			} else {
				this.addType = 'rgb';
			}
			
		} else {
			this.addType = 'html';
			this.swatchTxt.set('disabled',true);
			this.swatchBtn.set('disabled',false);
			var sel = this.swatchSel.getSelected();
			if ( sel[0] ) {
				this.setCol( sel[0].value , sel[0].value , true , sel[0].get('html') ); //sel[0].html
			} else {
				this.error('unknown selection');
			}
		}
	},
	chgTxt:				function() {
		var interp = '';
		var rgb = '';
		
		if ( this.addType == 'pms' ) {
			//trim whitespace
			interp = this.swatchTxt.value.replace(/^\s*(.*)\s*$/,"$1");
			//convert any multiple whitespace chars into one space char
			interp = interp.replace(/\s+/," ");
			//delete any illegal chars (non digits and alphabet)
			interp = interp.replace(/[^0-9a-z ]/,'');
			interp = interp.toLowerCase();
			if ( this.pantone[interp] ) {
				rgb = this.pantone[interp];
				this.setCol( '#'+rgb , interp , true , 'PMS '+interp );
			} else {
				rgb = 'fff';
				this.setCol( '#'+rgb , '' , false );
			}
		} else if ( this.addType == 'rgb' ) {
			//trim whitespace
			interp = this.swatchTxt.value.replace(/^\s*(.*)\s*$/,"$1");
			//delete whitespace
			interp = interp.replace(/\s+/,"");
			//delete any illegal chars (non hex)
			interp = interp.replace(/[^0-9a-f]/,'');
			interp = interp.toLowerCase();
			if ( interp.length == 3 || interp.length == 6 ) {
				this.setCol( '#'+interp , '#'+interp , true , 'RGB #'+interp );
			} else {
				this.setCol( '#fff' , '' , false );
			}
		}
	},
	chgBtn:				function(dispCol) {
		str = this.addType+':'+this.addColor;
		if ( this.list[str] ) {
			alert('This color is already in the list.');
		} else {
			var elem = new Element('div',{'class':'swatch'});
			var update = false;
			if ( !dispCol ) {
				update = true;
				dispCol = this.swatchCol.getStyle('background-color');
			}
			new Element('div',{'class':'swatchCol','style':'background-color:'+dispCol}).inject(
				elem,'bottom');
			new Element('div',{'class':'swatchLbl','html':this.addName}).inject(
				elem,'bottom');
			var btnElem = new Element('input',{'type':'button','value':'Delete','class':'swatchBtn'}).inject(
				elem,'bottom');
			btnElem.tmKey = str;
			btnElem.tmObj = this;
			btnElem.addEvent('click',function() {
				this.tmObj.delBtn(this.tmKey);
			});
			
			elem.inject(
				this.swatchAdd,
				'before'
			);

			this.list[str] = {
				'type':		this.addType,
				'color':	this.addColor,
				'elem':		elem,
				'btn':		btnElem
			};
			
			if (update) {
				this.updateList();
				this.setCol('#fff','',false,'',true);
			}
		}
	},
	
	delBtn:				function(key) {
		if ( typeof(this.list[key])==undefined ) {
			window.tm.log('list key '+key+' DNE!');
		} else {
			this.list[key].elem.dispose();
			delete this.list[key];
		}
	},
	
	updateList:			function() {
		var str = [];
		var c = 0;
		for ( key in this.list ) {
			str[c] = key;
			c++;
		}
		str = str.join(', ');
		this.field.value = str;
	},
	
	setCol:				function(color,real,valid,name,reset) {
		this.addColor = real;
		this.addName = name;
		this.swatchCol.setStyle('background-color',color);
		this.swatchBtn.set('disabled',!valid);
		if ( reset ) {
			this.swatchSel.selectedIndex = -1;
		}
	},
	
	error:				function(str) {
		alert('tmColorPicker Class Error: '+str);
	}
	
});

