var pathToColorCharts = 'http://site.wigavenue.com/color-charts';
var thumbSize = { 'width' : 30, 'height' : 30 };
var imgSize = { 'width' : 100, 'height' : 100 };

var colorCharts = {
	'Forever-Young' : {
		'1' : 'jet black',
		'1B' : 'off black',
		'F1B/BUR' : 'off black frosted with burgundy',
		'T1B/BUR' : 'off black mixed and tipped with burgundy',
		'T1B/RED' : 'off black mixed and tipped with absolute red',
		'F1B/27' : 'off black frosted with strawberry blonde',
		'M1B/27' : 'off black and strawberry blonde mix',
		'T1B/27' : 'off black mixed and tipped with strawberry blonde',
		'TT1B/27' : 'two-tone off-black on top of strawberry blonde',
		'F1B/30' : 'off black frosted with light auburn',
		'M1B/30' : 'off black and light auburn mix',
		'T1B/30' : 'off black mixed and tipped with light auburn',
		'F1B/33' : 'off black frosted with dark auburn',
		'M1B/33' : 'off black and dark auburn mix',
		'T1B/33' : 'off black mixed and tipped with dark auburn',
		'F1B/35' : 'off black frosted with mahogany red',
		'T1B/35' : 'off black mixed and tipped with mahogany red',
		'T1B/39' : 'off black mixed and tipped with deep burgundy red',
		'T1B/99J' : 'off black mixed and tipped with dark red wine',
		'F1B/130' : 'off black frosted with copper red',
		'T1B/130' : 'off black mixed and tipped with copper red',
		'TT1B/130' : 'two-tone off black on top of copper red',
		'T1B/144' : 'off black mixed and tipped with deep gold',
		'HL1B/335' : 'off black with highlights of copper red',
		'F1B/350' : 'off black frosted with light copper red',
		'T1B/350' : 'off black mixed and tipped with light copper red',
		'1B/613HL' : 'off black highlighted with french vanilla blonde',
		'M1B/613' : 'off black and french vanilla blonde mix',
		'NT1B/3348' : 'amber and dark auburn in the center with an undertone of off black',
		'NT1B/3536' : 'fiery copper red tipped with an undertone of off black',
		'NT1B350145' : 'frosted side bangs fiery copper undertone off black',
		'2' : 'dark brown',
		'2TB' : 'dark brown with a tint of fiery copper red',
		'F2/BUR' : 'dark brown frosted with burgundy',
		'HL2/BUR' : 'dark brown highlighted with burgundy',
		'T2/BUR' : 'dark brown mixed and tipped with burgundy',
		'2/10/613M' : 'a mix of dark brown, medium golden brown and french vanilla blonde',
		'2/18/613HL' : 'dark brown and dark ash blonde with french vanilla blonde highlights',
		'HL2/27' : 'dark brown highlighted with strawberry blonde',
		'T2/27' : 'dark brown mixed and tipped with strawberry blonde',
		'HL2/30' : 'dark brown highlighted with light auburn',
		'T2/30' : 'dark brown mixed and tipped with light auburn',
		'2/30+33HE' : 'dark brown highlighted with light and dark auburn',
		'2(30+145T)' : 'dark brown base with highlights with light auburn and dark amber',
		'F2/33' : 'dark brown frosted with dark auburn',
		'HL2/33' : 'dark brown highlighted with dark auburn',
		'T2/33' : 'dark brown mixed and tipped with dark auburn',
		'T2/33T/W8' : 'dark brown mixed with dark auburn, tipped with amber',
		'HL2/35+BUR' : 'dark brown highlighted blend of mahogany red and burgundy',
		'F2/130' : 'dark brown frosted with copper red',
		'HL2/130' : 'dark brown highlighted with copper red',
		'T2/130' : 'dark brown mixed and tipped with copper red',
		'F2/350' : 'dark brown frosted with light copper red',
		'HL2/350' : 'dark chestnut brown highlighted with light copper red',
		'T2/350' : 'dark brown mixed and tipped with light copper red',
		'HL3/BUR' : 'medium dark brown highlighted with burgundy',
		'NEON3' : 'electric blue',
		'3T1B/27/30' : 'off black at the root and tip with strawberry blonde and light auburn mix in the center',
		'3T1B/33' : 'off black at the root and tip with dark auburn in the center',
		'3T1B/M145' : 'root and tip with off black and fiery copper in the center',
		'3T1B/350' : 'root and tip with off black and light copper red in the center',
		'3T1B/M835' : 'off black at the root and tip with mix of burgundy and mahogany red in the center',
		'3T1B/M3509' : 'root and tip with off black with light copper and a hint of mahogany in the center',
		'3T4/24B102' : 'medium brown at the root and tip with butterscotch cr&egrave;me blonde swirled with ash French vanilla blonde',
		'3T4/M27/30' : 'medium brown at the root and tip with a mix of strawberry blonde and light auburn in the center',
		'3T4/M144' : 'medium brown at the root and tip with deep gold and butterscotch cr&egrave;me blonde in the center',
		'3T4/M145' : 'medium brown at the root and tip with fiery copper in the center',
		'3T4/M613' : 'medium brown at the root and tip with french vanilla blonde and butterscotch cr&egrave;me blonde in the center',
		'3T4/M1448' : 'medium brown at the root and tip with deep gold with a hint of french vanilla blonde in the center',
		'3T4/M3508' : 'medium brown at the root and tip with coveted mahogany bronze in the center',
		'3T4/M3509' : 'medium brown at the root and tip with coveted mahogany bronze and a hint of french vanilla',
		'4' : 'medium dark brown',
		'F4/BUR' : 'medium dark brown frosted with burgundy',
		'HL4/BUR' : 'medium dark brown highlighted with burgundy',
		'T4/BUR' : 'medium brown mixed and tipped with burgundy',
		'T4/BUR' : 'medium dark brown mixed and tipped with burgundy',
		'HL4/12' : 'medium dark brown highlighted with light golden brown',
		'HL4/15' : 'medium dark brown highlighted with honey golden brown',
		'T4/24' : 'medium brown mixed and tipped with golden blonde',
		'4/27/30' : 'medium dark brown, strawberry blonde and light auburn mix',
		'H4/27/130' : 'medium dark brown highlighted with strawberry blonde and copper red',
		'F4/27' : 'medium dark brown frosted with strawberry blonde',
		'H4/27' : 'medium dark brown highlighted with strawberry blonde',
		'HL4/27' : 'medium dark brown highlighted with strawberry blonde',
		'T4/27' : 'medium brown mixed and tipped with strawberry blonde',
		'4/30HD' : 'medium dark brown highlighted with light auburn',
		'F4/30' : 'medium dark brown frosted with light auburn',
		'H4/30' : 'medium dark brown highlighted with light auburn',
		'HL4/30' : 'medium dark brown highlighted with light auburn',
		'M4/30' : 'medium dark brown and light auburn mix',
		'T4/30' : 'medium brown mixed and tipped with light auburn',
		'F4/33' : 'medium dark brown frosted with dark auburn',
		'HL4/33' : 'medium dark brown highlighted with dark auburn',
		'T4/33' : 'medium brown mixed and tipped with dark auburn',
		'SM4/33M171' : 'medium dark brown on the sides, light auburn with light strawberry blonde going down the middle',
		'F4/35' : 'medium dark brown frosted with mahogany red',
		'F4M35/30' : 'medium dark brown mixed with mahogany red frosted with light auburn',
		'HL4/BUR+39' : 'medium dark brown highlighted with burgundy and deep burgundy red',
		'H4/BUR/99J' : 'medium dark brown highlighted with burgundy and dark red wine',
		'HL4/130' : 'medium dark brown highlighted with copper red',
		'T4/130' : 'medium brown mixed and tipped with copper red',
		'4/144+130T' : 'medium dark brown highlighted with deep gold and tipped with copper red',
		'4A/275GH' : 'medium brown base, front and side bangs are frosted with a mix of golden, strawberry, and butterscotch cr&egrave;me blonde',
		'4A/293/45H' : 'medium dark brown mixed with light auburn and subtle highlights of butterscotch cr&egrave;me',
		'T4/330/145' : 'mixed highlight of medium dark brown, absolute red and copper, tipped with light copper gold',
		'F4/350' : 'medium dark brown frosted with light copper red',
		'HL4/350' : 'medium dark brown highlighted with light copper red',
		'T4/350' : 'medium brown mixed and tipped with light copper red',
		'F4/350/613' : 'medium dark brown frosted with light copper red and french vanilla blonde',
		'4/556HE' : 'medium dark brown highlighted deep gold and light copper',
		'T4A1445' : 'medium dark brown highlighted with champage blonde, tipped with deep orange',
		'4A/2913HE' : 'medium dark brown with highlights of strawberry blonde and light auburn',
		'DF5' : 'blue anime with a touch of subtle shimmer',
		'DF5/P4' : 'blue anime with subtle shimmer and blue tinsel',
		'HL5/M6/27' : 'strawberry blonde highlighted with dark chestnut brown',
		'TH5/M6/27' : 'strawberry blonde with an undertone of dark chestnut brown',
		'6' : 'medium chestnut brown',
		'SH6/24B' : 'medium chestnut brown with top sides frosted with butterscotch cr&egrave;me blonde',
		'M6/27' : 'medium chestnut brown and strawberry blonde mix',
		'P6/27' : 'alternate strands of medium chestnut brown and strawberry blonde',
		'6/27/30HL' : 'medium chestnut brown swirled with light auburn and strawberry blonde highlights',
		'HL6/30' : 'medium chestnut brown highlighted with light auburn',
		'P6/30' : 'alternate strands of medium chestnut brown and light auburn',
		'8' : 'light chestnut brown',
		'8/12/24BHL' : 'light chestnut brown mixed with medium golden brown highlighted with butterscotch cr&egrave;me blonde',
		'8/12/24HL' : 'light chestnut brown swirled with medium golden brown highlighted with golden blonde',
		'8/12/27HL' : 'light chestnut brown mixed with medium golden brown highlighted strawberry blonde',
		'8/15/24BHL' : 'light chestnut brown highlighted with honey golden brown and golden blonde',
		'8/18/30HL' : 'light chestnut brown mixed with dark ash blonde highlighted with light auburn',
		'F8/22' : 'light chestnut brown frosted with champagne blonde',
		'8M24HL' : 'light chestnut brown highlighted golden blonde',
		'P8/24B' : 'light chestnut brown frosted with butterscotch cr&egrave;me',
		'T8/25' : 'light chestnut brown tipped honey blonde',
		'8H27HL24B' : '3 tone highlight of light chestnut brown, strawberry blonde and butterscotch cr&egrave;me blonde',
		'8M350/8H' : 'light chestnut brown mixed with light copper and light ash blonde',
		'NEON9' : 'cotton candy pink',
		'10' : 'medium golden brown',
		'NE10' : 'neon pink',
		'10/12/27HL' : 'light chestnut brown mixed with light golden brown highlighted with strawberry blonde',
		'F10/22' : 'medium golden brown frosted with champagne blonde',
		'12' : 'light golden brown',
		'R12' : 'watermelon red',
		'TH12/26' : 'alternate highlights of ash french vanilla blonde and light golden brown with an undertone of light golden brown',
		'12/27/24HL' : 'light golden brown and strawberry blonde highlighted with golden blonde',
		'12/613HL' : 'light golden brown highlighted with french vanilla blonde',
		'HL12/613' : 'medium golden brown higlighted with french vanilla blonde',
		'14' : 'medium ash blonde',
		'14/22/16' : 'medium ash blonde mixed with honey blonde and champagne blonde',
		'15' : 'honey golden brown',
		'SH15/8' : 'light chestnut brown frosted with honey golden brown on front and side bangs',
		'15/22HL' : 'honey golden brown with champagne blonde highlights',
		'16' : 'honey blonde',
		'F16/18' : 'honey blonde frosted with dark ash blonde',
		'16/22HL' : 'honey blonde highlighted with champagne blonde',
		'F16/24' : 'honey blonde frosted with golden blonde',
		'F16/613' : 'honey blonde frosted with french vanilla blonde',
		'T16/613' : 'honey blonde mixed and tipped with french vanilla blonde',
		'18' : 'dark ash blonde',
		'F18/22' : 'dark ash blonde frosted with champagne blonde',
		'22' : 'champagne blonde',
		'F22/24' : 'champagne blonde frosted with golden blonde',
		'24' : 'golden blonde',
		'24B' : 'butterscotch cr&egrave;me blonde (champagne blonde blended with light strawberry blonde)',
		'SH24/8' : 'light chestnut brown frosted with golden blonde on front and side bangs',
		'24BT18' : 'butterscotch cr&egrave;me blonde swirled with dark ash blonde',
		'24B27C' : 'butterscotch cr&egrave;me blonde swirled with strawberry blonde',
		'24BT102' : 'butterscotch cr&egrave;me blonde swirled with ash french vanilla blonde',
		'24B/613' : 'french vanilla blonde highlighted with butterscotch cr&egrave;me blonde',
		'25B88' : 'light golden blonde',
		'F24/613' : 'golden blonde frosted with french vanilla blonde',
		'LG26' : 'ash french vanilla with hint of light strawberry blonde',
		'26T8' : 'light ash blonde blend with light chestnut brown',
		'27' : 'strawberry blonde',
		'27W' : 'strawberry blonde mixed with light copper red',
		'TT27/4' : 'two-tone strawberry blonde on top of medium dark brown',
		'T27/24' : 'golden blonde mixed and tipped with strawberry blonde',
		'27C/29' : 'strawberry blonde mixed with light blonde and light auburn',
		'F27/30' : 'strawberry blonde frosted with light auburn',
		'27A/33' : 'dark auburn mixed with light strawberry blonde',
		'F27/613' : 'strawberry blonde frosted with french vanilla blonde',
		'F27A/613' : 'light strawberry blonde frosted with french vanilla blonde',
		'HL27/613' : 'strawberry blonde highlighted with french vanilla blonde',
		'H27/613' : 'strawberry blonde highlighted with french vanilla blonde',
		'T27/613' : 'strawberry blonde mixed and tipped with french vanilla blonde',
		'27T613H1B' : 'off black with an undertone of strawberry blonde tipped with french vanilla blonde',
		'RS29' : 'candy blonde swirled with strawberry blonde and medium auburn',
		'30' : 'light auburn',
		'RS30' : 'light auburn swirled with dark chestnut brown and light golden strawberry blonde',
		'30/4HC' : 'light auburn with subtle highlights of medium dark brown',
		'30/27M' : 'light auburn mixed with strawberry blonde',
		'30/130' : 'light auburn and copper red mix',
		'H30/130' : 'light auburn highlighted copper red',
		'HL30/130' : 'light auburn highlighted with copper red',
		'30/130/4' : 'light auburn, copper red, and medium brown mix',
		'30/130/146' : 'light auburn base, tipped with a highlight of copper red, butterscotch cr&egrave;me and french vanilla blonde',
		'F30/144' : 'light auburn frosted with deep gold',
		'30H3514' : 'mix of mohagany, light auburn with soft highlights of medium ash blonde',
		'32A' : 'dark brown mixed with violet and light chestnut brown',
		'33' : 'dark auburn',
		'33/27T' : 'dark auburn mixed and tipped with strawberry blonde',
		'33/27TL' : 'dark auburn frosted and tipped strawberry blonde',
		'TH33/27' : 'dark auburn with an undertone of strawberry blonde',
		'T33M27/144' : 'dark auburn mixed with strawberry blonde tipped with deep gold',
		'33/130' : 'dark auburn and copper red mix',
		'H33/130' : 'dark auburn highlighted with copper red',
		'HL33/130' : 'dark auburn highlighted with copper red',
		'33/144HL' : 'dark auburn with gold highlights',
		'S33/M145' : 'fiery copper red with an undertone of dark auburn',
		'D33/613/35' : 'dark auburn with bangs highlighted in mahogany red and french vanilla blonde',
		'33E/1248HL' : '3 tone highlight of chestnut brown, dark auburn, and light golden brown',
		'34' : 'dark brown with 30% grey',
		'35' : 'mahogany red',
		'TH35/1458' : 'fiery copper highlighted with butterscotch cr&egrave;me, french vanilla blonde with an undertone of fiery copper',
		'39/130' : 'burgundy and copper red mix',
		'HL39/130' : 'copper red highlighted with deep burgundy red',
		'44' : 'dark brown with 50% grey',
		'51' : 'dark brown with 75% grey',
		'60' : 'silver white',
		'96' : 'sandy blonde with french vanilla tip',
		'122/88H' : 'butterscotch cr&egrave;me and strawberry blonde accented with french vanilla blonde',
		'130' : 'copper red',
		'130/28' : 'burnt copper and dark auburn mix',
		'A144' : 'champagne blonde mixed with light amber',
		'144/240HL' : 'dark brown highlighted with deep gold',
		'145C' : 'amber mixed with strawberry blonde',
		'145T' : 'copper',
		'VL200' : 'light violet luster',
		'267/88H' : 'strawberry blonde highlighted with light golden brown and french vanilla blonde',
		'280' : 'off black with 10% gray',
		'FS337/1443' : 'medium ash blonde frosted with burgundy and light auburn',
		'345' : 'amber',
		'350/30/148' : 'strawberry blonde with frosted with light copper, light auburn and butterscotch cr&egrave;me',
		'613' : 'french vanilla blonde',
		'613/27HE' : 'French vanilla blonde accented with a very subtle strawberry blonde',
		'613/PINK' : 'french vanilla with light pink',
		'613/TINSEL' : 'french vanilla blonde accented with blue and purple tinsel',
		'613W' : 'french vanilla blonde and light strawberry blonde mix',
		'BLACK/613' : 'black accented with french vanilla blonde strands in the front',
		'613LG26/24' : 'french vanilla mixed with light ash blonde and champagne blonde',
		'V900' : 'lavendar lane',
		'1001' : 'winter white',
		'F2058' : 'dark auburn higlighted with strawberry blonde and french vanilla blonde',
		'F2068' : '',
		'2435/283T' : 'strawberry blonde mixed and tipped with french vanilla blonde',
		'2613' : 'french vanilla blonde accented with butterscotch cr&egrave;me',
		'FS4730' : '3 tone highlight of light auburn, french vanilla blonde, and butterscotch cr&egrave;me',
		'AMARANTH' : 'Pinkish red raspberry with sheen finish',
		'AUTUMN PALETTE' : 'alternating streaks of strawberry blonde, french vanilla, and dark auburn',
		'BABY BLONDE' : 'light blonde also considered french vanilla',
		'BLACK' : '',
		'BLACK/BLUE' : 'black accented with electric blue strands in the front',
		'BLACK/VL' : 'black accented with violet strands in the front',
		'BLND/RED' : 'light blonde accented with bright red strands in the front',
		'BLUE' : '',
		'CANDY BLONDE' : 'french vanilla blonde accented with a hint of strawberry blonde',
		'CAPPUCCINO' : 'medium chestnut brown swirled with dark chestnut brown',
		'CINNAMON' : '3 tone highlights of light golden brown, light copper, and dark auburn',
		'COCOA SWIRL' : 'medium dark brown base, front side bangs are highlighted with amber, deep gold and white',
		'COFFEE BEAN' : 'medium dark brown with mixed highlights of light auburn and dark auburn',
		'FUCHSIA' : '',
		'HAMPTON' : 'french vanilla blonde with alternating streaks of medium golden brown',
		'HAZELNUT' : 'alternative highlight of medium golden brown and light auburn, with a slight undertone of strawberry blonde and french vanilla blonde',
		'HONEY GINGER' : 'honey blonde blended with strawberry blonde',
		'HOT CARAMEL' : '3 tone highlight with golden and french vanilla blonde and light auburn with undertone of light auburn',
		'I HEART ESPRESSO' : 'medium dark brown accented with a higlight mix of light chestnut brown, dark auburn, and amber',
		'LIGHT PINK' : 'cotton candy pink',
		'MEDIUM BROWN' : '',
		'MULTI' : 'white base with multiple highlights of blue, yellow, orange, purple',
		'ORANGE' : 'absolute orange',
		'PINK' : '',
		'POPPY' : 'bright, vivid red with a sheen finish',
		'PURPLE' : 'royal purple',
		'RAINBOW' : 'multiple highlights of blue, yellow, orange, and white',
		'RED' : 'absolute red',
		'RUSSETT TUMBLE' : 'medium brown at the crown and medium auburn at the tips',
		'RWG' : 'red, white and green',
		'SIENNA' : 'light auburn frosted with copper red, strawberry brown and medium dark brown',
		'STTROPEZ' : 'french vanilla highlighted with butterscotch cr&egrave;me blonde',
		'TIRAMISU' : 'medium ash blonde frosted with french vanilla blonde',
		'VIOLET' : '',
		'VPURPLE' : 'dark purple',
		'WHITE' : ''
	},
	'HairDo' : {
		'R2' : 'Ebony: Black',
		'R4' : 'Midnight Brown: Off-Black or Black / Brown',
		'R6' : 'Dark Chocolate: Rich, Dark Brown',
		'R6-30H' : 'Chocolate Copper: Dark Brown with soft, Coppery highlights',
		'R10' : 'Chestnut: Rich Dark Brown with Coffee Brown highlights all over',
		'R830' : 'Ginger Brown: Warm, Medium Brown',
		'R29S' : 'Glazed Strawberry: Strawberry Blonde with Pale Blonde highlights',
		'R25' : 'Ginger Blonde: Golden Blonde with subtle highlights',
		'R1416T' : 'Buttered Toast: Dishwater or Mousey Blonde with sun kissed highlights',
		'R14-25' : 'Honey Ginger: Dark Golden Blonde with light Gold highlights',
		'R14-88H' : 'Golden Wheat: Medium Blonde streaked with pale Gold highlights, Medium Brown roots',
		'R435S' : 'Glazed Black Cherry: Glazed black cherry with highlights',
		'R829S' : 'Glazed Hazelnut: Medium Brown with Ginger highlighting on top',
		'R11S' : 'Glazed Mocha: Medium Brown with Gold Blonde highlighting on top',
		'R3025S' : 'Glazed Cinnamon: Medium Reddish Brown with Ginger highlights on top',
		'R3329S' : 'Glazed Auburn: Rich dark reddish brown with pale Peach Blonde highlights',
		'R8-25' : 'Golden Walnut: Rich, Dark Brown with Gold highlights',
		'R21T' : 'Sandy Blonde: Cool, pale Blonde with Ash Blonde tips',
		'R22' : 'Swedish Blonde: Pale Baby Blonde or salon processed Blonde',
		'R33' : 'Dark Auburn: Dark Reddish Brown',
		'R130' : 'Dark Copper: Bright Reddish Brown with subtle Copper highlights',
		'R1HH' : 'Black',
		'R3HH' : 'Dark Brown',
		'R4HH' : 'Chestnut Brown',
		'R5HH' : 'Light Reddish Brown',
		'R6HH' : 'Medium Auburn',
		'R7HH' : 'Strawberry Blonde',
		'R8HH' : 'Golden Blonde',
		'R9HH' : 'Light Golden Blonde',
		'R10HH' : 'Palest Blonde'
	},
	'Sepia-Elegante' : {
		'1' : 'Black',
		'2' : 'Darkest Brown',
		'3' : 'Darker Brown',
		'4' : 'Dark Brown',
		'6' : 'Medium Chestnut Brown',
		'8' : 'Light Chestnut Brown',
		'10' : 'Medium Golden Brown',
		'12' : 'Light Golden Brown',
		'14' : 'Light Golden Blonde',
		'18' : 'Light Ash Blonde',
		'22' : 'Beige Blonde',
		'24' : 'Golden Blonde',
		'24B' : 'butterscotch blonde',
		'27' : 'Strawberry Blonde',
		'30' : 'Light auburn',
		'33' : 'Dark Auburn',
		'34' : 'Dark Brown with 10% Grey',
		'44' : 'Off Black with 50% Grey',
		'51' : 'Dark Brown with 70% Grey',
		'56' : 'Medium Brown with 90% Grey',
		'60' : 'White',
		'130' : 'Bright Red Auburn',
		'144' : 'Deep Gold (Orange Blonde)',
		'270' : 'Light Copper',
		'280' : 'Off-Black with 10% Grey',
		'350' : 'Jessica Rabbit orange red',
		'375' : 'vibrant Jessica Rabbit orange red',
		'613' : 'Bleach Blonde',
		'127R' : 'Deep Gold, light auburn and strawberry blonde mix',
		'130HL33' : 'bright red auburn with highlights of dark auburn',
		'133E' : 'Dark Brown with Maroon tips',
		'144L' : 'Bright Golden Orange Blonde',
		'144M' : 'Golden Orange Blonde Blended with Off-Black and Medium Auburn',
		'16HL8' : 'Light Chestnut Brown with highlights of Light Golden Blonde',
		'1B' : 'Off-Black',
		'24BT18' : 'Light Ash Blonde tipped with Butterscotch Blonde',
		'26R' : '',
		'27S' : 'Auburn Blonde',
		'280A' : 'Off Black with 20% Grey',
		'2T328' : 'dark brown with light red tips',
		'33R' : '',
		'613A' : 'White Blonde',
		'ANGELS BREATH' : 'pink, light blue and white stripes',
		'AURORA' : 'pink, violet and white stripes',
		'BLACK & WHITE' : 'half black and half white',
		'BLACK CHERRY' : 'black and purple mix',
		'BLACK WINE' : 'off-black and deep bordeaux red blend',
		'BLUE MOON' : '2 tone blue (top/bottom)',
		'BORDEAUX' : 'black and burgundy blended',
		'BUBBLE GUM' : 'pink and hot pink stripes',
		'BURGUNDY' : '',
		'CHESTNUT' : '',
		'CONCORD' : '2 tone purple and violet (top/bottom)',
		'COPPER' : '',
		'DARK RED' : '',
		'EMERALD' : 'dark green',
		'F130/33' : 'bright red auburn frosted with dark auburn',
		'F14/24' : 'light golden blonde frosted with golden blonde',
		'F16/22' : 'light honey blonde frosted with beige blonde',
		'F18/22' : 'light ash blonde frosted with beige blonde',
		'F24/613' : 'golden blonde frosted with bleach blonde',
		'F27/613' : 'strawberry blonde frosted with bleach blonde',
		'F4/27' : 'Dark Brown frosted with Strawberry blonde',
		'F4/30' : 'Dark Brown frosted with Light Auburn',
		'FANCY CHESTNUT' : 'medium dark brown with extra long chestnut brown tips',
		'FANCY HENNA' : 'medium dark brown with extra long Henna Red (bright auburn red) tips',
		'FANCY MAROON' : 'medium dark brown with extra long maroon tips',
		'FANCY WINE' : 'medium dark brown with extra long wine red tips',
		'FIRESTORM' : 'black and red blended',
		'FLAMINGO' : '2 tone hot pink and pink (top/bottom)',
		'FS1B/130' : 'off-black frosted with bright red auburn',
		'FS1B/142' : '',
		'FS1B/144' : 'off-black frosted with deep gold',
		'FS1B/30' : 'off-black frosted with medium light auburn',
		'FS1B/350' : 'off-black frosted with orange red',
		'FS2/12' : 'darkest brown frosted with light golden brown',
		'FS33/27' : 'dark auburn frosted with strawberry blonde',
		'FS4/12' : 'dark brown frosted with light golden brown',
		'FS4/27' : 'dark brown frosted with strawberry blonde',
		'FS4/30' : 'dark brown frosted with medium light auburn',
		'FS99J/182' : '',
		'GRAPEVINE' : 'purple and voilet stripes',
		'GREEN' : 'apple green',
		'H130/4' : 'bright red auburn highlighted with dark brown',
		'H24-613A' : 'golden blonde highlighted with white blonde',
		'H27/4' : 'strawberry blond highlighted with medium dark brown',
		'H27/4/30' : 'strawberry blond highlighted with medium dark brown and light auburn',
		'HENNA RED' : 'bright auburn red',
		'HL130/4' : 'bright red auburn highlighted with dark brown',
		'HOT PINK' : 'bright pink',
		'LAVA' : 'red and orange blended',
		'LEMON DROP' : '2 tone neon green and green (top/bottom)',
		'LIGHT BLUE' : 'baby blue (turquoise)',
		'M108' : '',
		'M2/30' : 'darkest brown mixed with medium light auburn',
		'M2/33' : 'darkest brown mixed with dark auburn',
		'M30/144' : 'medium light auburn mixed with yellow blonde',
		'M4/30' : 'dark brown mixed with medium light auburn',
		'M6/30' : 'medium chestnut brown mixed with light auburn',
		'MAGENTA' : 'fuschia',
		'MF4/27/30' : '',
		'MIDNIGHT BLUE' : 'black and dark blue blended',
		'MOONGLOW' : 'pale white',
		'N18' : 'yellow blonde base with golden orange on top',
		'N18R' : 'golden orange base with yellow blonde on top',
		'N19R' : 'bleach blonde base with copper carrot orange on top',
		'NEON GREEN' : '',
		'NEON ORANGE' : 'bright orange',
		'OCEAN PACIFIC' : 'dark blue and light blue stripes',
		'ORANGE' : '',
		'P1B/27' : 'piano blend of off-black and strawberry blonde',
		'P1B/30' : 'piano blend of off-black and light auburn',
		'P1B/33' : 'piano blend of off-black and dark auburn',
		'P1B/BURGUNDY' : 'piano blend of off-black and burgundy',
		'P1B/DARK RED' : 'piano blend of off-black and dark red',
		'P2/33' : 'piano blend of darkest brown and dark auburn',
		'P4/27' : 'piano blend of dark brown and strawberry blonde',
		'P4/27/30' : 'piano blend of medium dark brown, light auburn and medium auburn',
		'P4/30' : 'piano blend of dark brown and medium light auburn',
		'PIANO DARK BLUE GLOW' : 'dark blue and white piano key stripes',
		'PIANO ORANGE GLOW' : 'orange and white piano key stripes',
		'PIANO PINK GLOW' : 'pastel pink and white piano key stripes',
		'PIANO PURPLE GLOW' : 'purple and white piano key stripes',
		'PINK' : 'cotton candy (pastel) pink',
		'PURPLE' : '',
		'RED' : '',
		'RS29' : '',
		'RS32' : '',
		'SAND' : '',
		'SUNSHINE' : 'yellow and orange stripes',
		'T1B/12' : 'off-black with light golden brown tips',
		'T1B/130' : 'off-black with bright auburn tips',
		'T1B/30' : 'off-black with medium light auburn tips',
		'T1B/33' : 'off-black with dark auburn tips',
		'T1B/BURGUNDY' : 'off-black with burgundy tips',
		'T1B/DARK RED' : 'off-black with dark red tips',
		'T27/613' : 'strawberry blonde with bleach blonde tips',
		'T33/130' : 'dark auburn with bright red auburn tips',
		'T4/27' : 'dark brown with strawberry blonde tips',
		'T80' : 'golden brown mixed with ash blonde',
		'T85' : 'golden scotch blonde with medium chestnut brown roots',
		'TA472' : '',
		'TT1B/144' : 'two-tone off-black on top of yellow blonde',
		'TT1B/27' : 'two-tone off-black on top of strawberry blonde',
		'TT1B/30' : 'two-tone off-black on top of medium light auburn',
		'TT1B/33' : 'two-tone off-black on top of light auburn',
		'UNITED' : 'red, white and blue stripes',
		'VENUS' : 'pink, light blue and violet blend',
		'VIOLET' : '',
		'YELLOW' : ''
	}
};

var colorList, colorImages, colorPicker, colorSelect, colorViewer, sortedColors;

function LoadChart() {
	if (colorCharts[SBI_ColorChart] != undefined) {
		var missing = new Array();
		$('#product-info-table .options td select').each(function() {
			if (colorSelect == undefined) {
				var i, key;
				colorList = new Array();
				missing = new Array();
				for (i = 0; i < this.options.length; i++) {
					var key = this.options[i].text;
					if (colorCharts[SBI_ColorChart][key] == undefined)
						missing.push(key);
					else
						colorList[i] = key;
				}
				if (colorList != undefined && colorList.length > 0 && missing.length == 0 && colorList.length == this.options.length) {
					colorSelect = this;
					sortedColors = colorList;
					sortedColors.sort(ColorSorter);
				}
				else {
					colorList = undefined;
				}
			}
		});
		if (colorList != undefined && colorList.length > 0 && colorSelect != undefined)
			BuildChart();
		if (missing.length > 0)
			throw new Error('Missing colors: ' + missing.join(', '));
	}
}

function ColorSorter(a, b) {
	var x = a
		.replace(' ', '_')
		.replace(/[^0-9_A-Z]/g, ' ')
		.replace(/^\s+|\s+$/g, '')
		.replace(' ', '-');
	while (x.indexOf('--') > -1)
		x = x.replace('--', '-');
	x = x
		.replace(/[A-Z]/, '')
		.split('-');
	var y = b
		.replace(' ', '_')
		.replace(/[^0-9_A-Z]/g, ' ')
		.replace(/^\s+|\s+$/g, '')
		.replace(' ', '-');
	while (y.indexOf('--') > -1)
		y = y.replace('--', '-');
	y = y
		.replace(/[A-Z]/, '')
		.split('-');
	var i = 0;
	while (i < x.length && i < y.length) {
		var xi = parseInt(x[i].replace(/[^0-9]/g, '')), yi = parseInt(y[i].replace(/[^0-9]/g, ''));
		var xn = isNaN(xi), yn = isNaN(yi);

		if (xn && yn) {
			if (a < b)
				return -1;
			if (a > b)
				return 1;
		}
		else if (yn)
			return -1;
		else if (xn)
			return 1;

		if (x.length < y.length)
			return -1;
		else if (x.length > y.length)
			return 1;

		if (xi < yi)
			return -1;
		else if (xi > yi)
			return 1;

		i++;
	}
	return 0;
}

function BuildChart() {
	if (colorList != undefined && colorList.length > 0 && colorSelect != undefined && colorImages == undefined && colorPicker == undefined && colorViewer == undefined) {
		colorImages = new Array();
		colorPicker = document.createElement('div');
		$(colorPicker).addClass('colorPicker');
		colorViewer = document.createElement('div');
		$(colorViewer)
			.addClass('colorViewer')
			.addClass('centered')
			.html('<br/><br/><br/>Choose a color');
		for (var i = 0; i < sortedColors.length; i++) {
			var key = sortedColors[i];
			colorImages[i] = new Image(100,100);
			colorImages[i].src = Key2Img(key);
			var a = document.createElement('a');
				a.setAttribute('href', '#');
				$(a).data('index', i)
					.click(function() {
						SelectColor($(this).data('index'));
						return false;
					});
				var img = document.createElement('img');
					img.setAttribute('alt', '');
					img.src = colorImages[i].src;
					img.setAttribute('width', thumbSize.width);
					img.setAttribute('height', thumbSize.height);
				a.appendChild(img);
			colorPicker.appendChild(a);
		}
		$(colorSelect).after(colorViewer);
		$(colorViewer).after(colorPicker);
		$(colorSelect).hide();
	}
}

function SelectColor(i) {
	var key = sortedColors[i];
	if (key != undefined && colorCharts[SBI_ColorChart] != undefined) {
		var anchors = $(colorPicker).children('a');
		anchors.removeClass('sel');
		$(colorViewer).empty();
		for (var o = 0; o < colorSelect.options.length; o++) {
			if (colorSelect.options[o].text == key) {
				var desc = colorCharts[SBI_ColorChart][key];
				colorSelect.selectedIndex = (colorSelect.options[o].disabled ? -1 : o);
				var img = document.createElement('img');
					img.setAttribute('src', colorImages[i].src);
					img.setAttribute('width', imgSize.width);
					img.setAttribute('height', imgSize.height);
					img.setAttribute('align', 'left');
					img.setAttribute('alt', '');
				$(colorViewer)
					.removeClass('centered')
					.append(img)
					.append('<b>' + key.replace('&', '&amp;') + '</b>' + (colorSelect.options[o].disabled ? '<span> - Unavailable</span>' : '') + '<br/><br/>')
					.append(desc);
				anchors.eq(i).addClass('sel');
				break;
			}
		}
	}
}

function Key2Img(key) {
	return pathToColorCharts + '/' + SBI_ColorChart + '/' + key.replace(/[^A-Z0-9]/g, '-') + '.jpg';
}

$(document).ready(function() {
	if (typeof(SBI_ColorChart) != "undefined") {
		LoadChart();
		if (colorSelect != undefined) {
			colorSelect.selectedIndex = -1;
			if (colorSelect.options.length == 1)
				SelectColor(0);
		}
	}
});
