JS File

 var Title = [[TitleDefault],TitleA,TitleB]
var Wincode = [[WincodeDefault],WincodeA,WincodeB];
var Red = [[RedDefault],RedA,RedB];
var Blue = [[BlueDefault],BlueA,BlueB];
var Yellow = [[YellowDefault],YellowA,YellowB];
var Green = [[GreenDefault],GreenA,GreenB];
var Orange = [[OrangeDefault],OrangeA,OrangeB];
var Purple = [[PurpleDefault],PurpleA,PurpleB];
var Teal = [[TealDefault],TealA,TealB];
var Violet = [[VioletDefault],VioletA,VioletB];
var RedCandidate = [[RedCandidateDefault],RedCandidateA,RedCandidateB];
var BlueCandidate = [[BlueCandidateDefault],BlueCandidateA,BlueCandidateB];
var YellowCandidate = [[YellowCandidateDefault],YellowCandidateA,YellowCandidateB];
var GreenCandidate = [[GreenCandidateDefault],GreenCandidateA,GreenCandidateB];
var OrangeCandidate = [[OrangeCandidateDefault],OrangeCandidateA,OrangeCandidateB];
var PurpleCandidate = [[PurpleCandidateDefault],PurpleCandidateA,PurpleCandidateB];
var TealCandidate = [[TealCandidateDefault],TealCandidateA,TealCandidateB];
var VioletCandidate = [[VioletCandidateDefault],VioletCandidateA,VioletCandidateB];
var RedStatewidePCT = [[RedStatewidePCTDefault],RedStatewidePCTA,RedStatewidePCTB];
var BlueStatewidePCT = [[BlueStatewidePCTDefault],BlueStatewidePCTA,BlueStatewidePCTB];
var YellowStatewidePCT = [[YellowStatewidePCTDefault],YellowStatewidePCTA,YellowStatewidePCTB];
var GreenStatewidePCT = [[GreenStatewidePCTDefault],GreenStatewidePCTA,GreenStatewidePCTB];
var OrangeStatewidePCT = [[OrangeStatewidePCTDefault],OrangeStatewidePCTA,OrangeStatewidePCTB];
var PurpleStatewidePCT = [[PurpleStatewidePCTDefault],PurpleStatewidePCTA,PurpleStatewidePCTB];
var TealStatewidePCT = [[TealStatewidePCTDefault],TealStatewidePCTA,TealStatewidePCTB];
var VioletStatewidePCT = [[VioletStatewidePCTDefault],VioletStatewidePCTA,VioletStatewidePCTB];
var Precinct = [[PrecinctDefault],PrecinctA,PrecinctB];
var StatewideVotes = [[StatewideVotesDefault],StatewideVotesA,StatewideVotesB];
var TotalVotes = [[TotalVotesDefault],TotalVotesA,TotalVotesB];
var Tog1 = [[Tog1Default],Tog1A,Tog1B];
var clickedLayer = [[clickedLayerDefault],clickedLayerA,clickedLayerB];
var relevanttype = [[relevanttypeDefault],relevanttypeA,relevanttypeB];
var state = [[stateDefault], stateA, stateB];
var colorstep =[[colorstepDefault],colorstepA,colorstepB];
var startvalue = [[startvalueDefault],startvalueA,startvalueB]
var maxslider = [[maxsliderDefault],maxsliderA,maxsliderB]
var toggleableLayerIdsA = menuIDsA;
var toggleableLayerNamesA = menuNamesA;
var toggleableLayerIdsB = menuIDsB;
var toggleableLayerNamesB = menuNamesB;
var clickedLayerMenuA = [];
var clickedLayerMenuB = [];
var clickedLayerMainMenu = [];
var Multi = []

var LegendColor = ['#c0c0c0','#ffc3ec','#8b4513','#ff4500','#008084','#0004fb','#24a605','#6b0a7d','#ff7e00','#909008','#ffffff','#deb988','#ffa500','#707070','#c53bfc','#3c3f79','#fef200','#eeebec','#6b8e23','#c2c0bc','#ae0402','#f4c89d','#e3a583','#d1826a','#ef7663','#ae3c37','#fddaaa','#f5ca9e','#edb992','#e5a986','#dd997a','#d4886f','#cc7863','#c46857','#bc574b','#b4473f','#ab3633','#ffdfff','#ffc5ff','#ffaaff','#ff90ff','#ff75ff','#ff5bff','#ff40ff','#ff26ff','#ff0bff','#acacf7','#5959d3','#0606ae','#b20404','#b30a0a','#b51010','#b71616','#b91c1c','#bb2222','#bd2828','#be2d2d','#c03333','#c23939','#c43f3f','#c64545','#c84b4b','#c95151','#cb5757','#cd5d5d','#cf6363','#d16969','#d36f6f','#d47575','#d67a7a','#d88080','#da8686','#dc8c8c','#de9292','#df9898','#e19e9e','#e3fba4','#e5aaaa','#e7b0b0','#e9b6b6','#eabcbc','#ecc2c2','#eec7c7','#f0cdcd','#f2d3d3','#f4d9d9','#f5dfdf','#f7e5e5','#f9ebeb','#fbf1f1','#fdf7f7','#fffdfd','#e9ffe6','#daffd4','#cbffc2','#bcffaf','#aeff9d','#9fff8a','#90ff78','#81ff65','#72ff53','#64ff40','#55ff2e','#46ff1b','#37ff09','#dcffd6','#87ff6c','#32ff02','#05d8a8','#11cb77','#1dbe47','#2ab017','#ffeccf','#ffd390','#ffba51','#ffa112','#fff0d9','#ffe5bc','#ffd9a0','#ffce83','#ffc267','#ffb74a','#ffac2e','#ffa011','#dddddd','#c8c8c8','#b2b2b2','#9d9d9d','#dcdcdc','#c9c9c9','#b5b5b5','#a2a2a2','#b3b480','#b6fcfc','#87e2e2','#59c9c9','#2ab0b0','#2bb1b1','#b3fafa','#a4f2f2','#95eaea','#86e2e2','#77dada','#68d1d1','#59c9c9','#4ac1c1','#3bb9b9','#2cb1b1','#1da9a9','#0ea1a1','#049292','#404040','#641919','#d3f8ff','#acdfff','#84c5ff','#5dacff','#3592ff','#dafdff','#bfebff','#a5daff','#8ac9ff','#70b8ff','#56a7ff','#3b96ff','#2185ff','#6e709d','#45509e','#eddce8','#e9bcda','#e49dcd','#df7ebf','#da5eb2','#d63fa4','#d11f97','#cc0089','#edd8e6','#e6acd3','#e081c1','#d956ae','#d32b9c','#cc0089','#e9e3a3','#e2dc9a','#dbd591','#d4ce88','#cdc77f','#d7d080','#bfb96d','#ebe5a6','#e6e09f','#e0da98','#dbd591','#d5cf8a','#d0ca83','#cac47c','#c5bf75','#c0ba6e','#cdfff3','#bdffee','#aeffe9','#9effe5','#8effe0','#7fffdb','#6fffd7','#60ffd2','#50ffcd','#40ffc9','#31ffc4','#21ffbf','#11ffbb','#02ffb6','#c9fff2','#b9ffed','#a9ffe8','#9affe3','#8affdf','#7bffda','#6bffd5','#5bffd1','#4cffcc','#3cffc7','#2dffc3','#1dffbe','#0dffb9','#32efb8','#c0c0c0'];

var main = 1;
var lv = 1;
var relevantState = '';
var firstmatrix = 0;
var secondmatrix = 0;
var thirdmatrix = 0;
//define slider values
var slider = document.getElementById('slider');
var sliderValue = document.getElementById('slider-value');
var csslider = document.getElementById('csslider');
var cssliderValue = document.getElementById('csslider-value');
var legendA = document.getElementById("Legend-A");
var legendB = document.getElementById("Legend-B");
var legendC = document.getElementById("Legend-C");
var legendD = document.getElementById("Legend-D");
var legendE = document.getElementById("Legend-E");
var legendF = document.getElementById("Legend-F");
var legendG = document.getElementById("Legend-G");
var legendH = document.getElementById("Legend-H");
legendA.style.opacity = 0.9;
legendB.style.opacity = 0.9;
legendC.style.opacity = 0.9;
legendD.style.opacity = 0.9;
legendE.style.opacity = 0.9;
legendF.style.opacity = 0.9;
legendG.style.opacity = 0.9;
legendH.style.opacity = 0.9;
//define legend slider values
var colorpct500b = document.getElementById('color-pct-0');
var colorpct510 = document.getElementById('color-pct-10');
var colorpct520 = document.getElementById('color-pct-20');
var colorpct530 = document.getElementById('color-pct-30');
var colorpct540 = document.getElementById('color-pct-40');
var colorpct550 = document.getElementById('color-pct-50');
var colorpct560 = document.getElementById('color-pct-60');
var colorpct570 = document.getElementById('color-pct-70');
var colorpct580 = document.getElementById('color-pct-80');
var colorpct590 = document.getElementById('color-pct-90');
var colorpct600 = document.getElementById('color-pct-100');
var colorpct600c = document.getElementById('color-pct-100c');
var colorpct600d = document.getElementById('color-pct-100d');
var colorpct600e = document.getElementById('color-pct-100e');
var colorpct600f = document.getElementById('color-pct-100f');
var colorpct600g = document.getElementById('color-pct-100g');
var colorpct600h = document.getElementById('color-pct-100h');
var colorpct600i = document.getElementById('color-pct-100i');
var colorpct600j = document.getElementById('color-pct-100j');
var colorpct600a = document.getElementById('color-pct-110');
//change interactive legend percents
colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue [firstmatrix][secondmatrix][thirdmatrix]
cssliderValue.textContent = colorscale + ' points';
csslider.value = colorscale
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
if (relevantColor === 'JMCWincode') {JMClabel ()}
else if (relevantColor === 'PopPCT') {PPlabel ()}
else if (relevantColor === 'PopNUM') {cssliderValue.textContent = colorscale + ' residents';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.value = colorscale;
PNlabel()}
else if (relevantColor === 'Margin7') {m7label ()}
else {otherlabel()}

//define legend values
var colorvalue0b = document.getElementById('color-value-0-0');
var colorvalue10 = document.getElementById('color-value-10');
var colorvalue20 = document.getElementById('color-value-20');
var colorvalue30 = document.getElementById('color-value-30');
var colorvalue40 = document.getElementById('color-value-40');
var colorvalue50 = document.getElementById('color-value-50');
var colorvalue60 = document.getElementById('color-value-60');
var colorvalue70 = document.getElementById('color-value-70');
var colorvalue80 = document.getElementById('color-value-80');
var colorvalue90 = document.getElementById('color-value-90');
var colorvalue100 = document.getElementById('color-value-100');
var colorvalue100a = document.getElementById('color-value-1-10');
var colorvalue100b = document.getElementById('color-value-1-0');
var colorvalue110 = document.getElementById('color-value-110');
var colorvalue120 = document.getElementById('color-value-120');
var colorvalue130 = document.getElementById('color-value-130');
var colorvalue140 = document.getElementById('color-value-140');
var colorvalue150 = document.getElementById('color-value-150');
var colorvalue160 = document.getElementById('color-value-160');
var colorvalue170 = document.getElementById('color-value-170');
var colorvalue180 = document.getElementById('color-value-180');
var colorvalue190 = document.getElementById('color-value-190');
var colorvalue200 = document.getElementById('color-value-200');
var colorvalue200a = document.getElementById('color-value-2-10');
var colorvalue200b = document.getElementById('color-value-2-0');
var colorvalue210 = document.getElementById('color-value-210');
var colorvalue220 = document.getElementById('color-value-220');
var colorvalue230 = document.getElementById('color-value-230');
var colorvalue240 = document.getElementById('color-value-240');
var colorvalue250 = document.getElementById('color-value-250');
var colorvalue260 = document.getElementById('color-value-260');
var colorvalue270 = document.getElementById('color-value-270');
var colorvalue280 = document.getElementById('color-value-280');
var colorvalue290 = document.getElementById('color-value-290');
var colorvalue300 = document.getElementById('color-value-300');
var colorvalue300a = document.getElementById('color-value-3-10');
var colorvalue300b = document.getElementById('color-value-3-0');
var colorvalue310 = document.getElementById('color-value-310');
var colorvalue320 = document.getElementById('color-value-320');
var colorvalue330 = document.getElementById('color-value-330');
var colorvalue340 = document.getElementById('color-value-340');
var colorvalue350 = document.getElementById('color-value-350');
var colorvalue360 = document.getElementById('color-value-360');
var colorvalue370 = document.getElementById('color-value-370');
var colorvalue380 = document.getElementById('color-value-380');
var colorvalue390 = document.getElementById('color-value-390');
var colorvalue400 = document.getElementById('color-value-400');
var colorvalue400a = document.getElementById('color-value-4-10');
var colorvalue400b = document.getElementById('color-value-4-0');
var colorvalue410 = document.getElementById('color-value-410');
var colorvalue420 = document.getElementById('color-value-420');
var colorvalue430 = document.getElementById('color-value-430');
var colorvalue440 = document.getElementById('color-value-440');
var colorvalue450 = document.getElementById('color-value-450');
var colorvalue460 = document.getElementById('color-value-460');
var colorvalue470 = document.getElementById('color-value-470');
var colorvalue480 = document.getElementById('color-value-480');
var colorvalue490 = document.getElementById('color-value-490');
var colorvalue500 = document.getElementById('color-value-500');
var colorvalue500a = document.getElementById('color-value-5-10');
var colorvalue500b = document.getElementById('color-value-5-0');
var colorvalue510 = document.getElementById('color-value-510');
var colorvalue520 = document.getElementById('color-value-520');
var colorvalue530 = document.getElementById('color-value-530');
var colorvalue540 = document.getElementById('color-value-540');
var colorvalue550 = document.getElementById('color-value-550');
var colorvalue560 = document.getElementById('color-value-560');
var colorvalue570 = document.getElementById('color-value-570');
var colorvalue580 = document.getElementById('color-value-580');
var colorvalue590 = document.getElementById('color-value-590');
var colorvalue600 = document.getElementById('color-value-600');
var colorvalue600a = document.getElementById('color-value-6-10');
var colorvalue600b = document.getElementById('color-value-6-0');
var colorvalue610 = document.getElementById('color-value-610');
var colorvalue620 = document.getElementById('color-value-620');
var colorvalue630 = document.getElementById('color-value-630');
var colorvalue640 = document.getElementById('color-value-640');
var colorvalue650 = document.getElementById('color-value-650');
var colorvalue660 = document.getElementById('color-value-660');
var colorvalue670 = document.getElementById('color-value-670');
var colorvalue680 = document.getElementById('color-value-680');
var colorvalue690 = document.getElementById('color-value-690');
var colorvalue700 = document.getElementById('color-value-700');
var colorvalue700a = document.getElementById('color-value-7-10');
var colorvalue700c = document.getElementById('color-value-700c');
var colorvalue700d = document.getElementById('color-value-700d');
var colorvalue700e = document.getElementById('color-value-700e');
var colorvalue700f = document.getElementById('color-value-700f');
var colorvalue700g = document.getElementById('color-value-700g');
var colorvalue700h = document.getElementById('color-value-700h');
var colorvalue700i = document.getElementById('color-value-700i');
var colorvalue700j = document.getElementById('color-value-700j');
var colorvalue700b = document.getElementById('color-value-7-0');
var colorvalue710 = document.getElementById('color-value-710');
var colorvalue720 = document.getElementById('color-value-720');
var colorvalue730 = document.getElementById('color-value-730');
var colorvalue740 = document.getElementById('color-value-740');
var colorvalue750 = document.getElementById('color-value-750');
var colorvalue760 = document.getElementById('color-value-760');
var colorvalue770 = document.getElementById('color-value-770');
var colorvalue780 = document.getElementById('color-value-780');
var colorvalue790 = document.getElementById('color-value-790');
var colorvalue800 = document.getElementById('color-value-800');
var colorvalue800a = document.getElementById('color-value-8-10');
var colorvalue800c = document.getElementById('color-value-800c');
var colorvalue800d = document.getElementById('color-value-800d');
var colorvalue800e = document.getElementById('color-value-800e');
var colorvalue800f = document.getElementById('color-value-800f');
var colorvalue800g = document.getElementById('color-value-800g');
var colorvalue800h = document.getElementById('color-value-800h');
var colorvalue800i = document.getElementById('color-value-800i');
var colorvalue800j = document.getElementById('color-value-800j');
var background = 'background:';
var candidateA = document.getElementById('legend-CandidateA');
var candidateB = document.getElementById('legend-CandidateB');
var candidateC = document.getElementById('legend-CandidateC');
var candidateD = document.getElementById('legend-CandidateD');
var candidateE = document.getElementById('legend-CandidateE');
var candidateF = document.getElementById('legend-CandidateF');
var candidateG = document.getElementById('legend-CandidateG');
var candidateH = document.getElementById('legend-CandidateH');
var apct = document.getElementById('legend-A-pct');
var bpct = document.getElementById('legend-B-pct');
var cpct = document.getElementById('legend-C-pct');
var dpct = document.getElementById('legend-D-pct');
var epct = document.getElementById('legend-E-pct');
var fpct = document.getElementById('legend-F-pct');
var gpct = document.getElementById('legend-G-pct');
var hpct = document.getElementById('legend-H-pct');
var legendtitle = document.getElementById('legend-title');
//define colors
if (WinColors === 'JMC')
{var reds = ['#909090','#FFD5D9','#FFAAAE','#FB6666','#EB4747','#CC3333','#AC2929','#8C1C1C','#6C1717','#531515','#321111','#2C0F0F'];
var blues = ['#909090','#D5D9FF','#AAAEFF','#6666FB','#4747EB','#3333CC','#2929AC','#1C1C8C','#17176C','#151553','#11113C','#0F0F2C'];
var greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
var yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
var oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
var purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
var teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
var violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
var reds7 = ['#909090','#FFBBBB','#F58181','#EB4747','#CC3333','#AA2222','#881111','#660000'];
var blues7 = ['#909090','#BBBBFF','#8181F5','#4747EB','#3333CC','#2222AA','#111188','#000066'];
var reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
var greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
var oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
var purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
var teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
var violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
var blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
var yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
var greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
var oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
var purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
var teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
var violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}

else if (WinColors === 'Atlas')
{var reds = ['#909090','#00ffff','#00ddff','#00bbff','#0099ff','#0000ff','#0000dd','#0000bb','#000099','#000088','#000077','#000066'];
var blues = ['#909090','#ff99ff','#ff66ff','#ff33cc','#ff0099','#ff0000','#dd0000','#bb0000','#990000','#880000','#770000','#660000'];
var greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
var yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
var oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
var purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
var teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
var violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
var reds7 = ['#909090','#33CCFF','#0E0E0E','#0000FF','#0000DD','#0000BB','#000099','#000088'];
var blues7 =['#909090','#FF33CC','#FF0099', '#FF0000', '#DD0000', '#BB0000', "#990000", '#880000']
var reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
var greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
var oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
var purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
var teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
var violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
var blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
var yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
var greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
var oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
var purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
var teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
var violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}
else if (WinColors === 'ReverseAtlas')
{var reds = ['#909090','#ff99ff','#ff66ff','#ff33cc','#ff0099','#ff0000','#dd0000','#bb0000','#990000','#880000','#770000','#660000'];
var blues = ['#909090','#00ffff','#00ddff','#00bbff','#0099ff','#0000ff','#0000dd','#0000bb','#000099','#000088','#000077','#000066'];
var greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
var yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
var oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
var purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
var teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
var violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
var reds7 =['#909090','#FF33CC','#FF0099', '#FF0000', '#DD0000', '#BB0000', "#990000", '#880000'];
var blues7 = ['#909090','#33CCFF','#0E0E0E','#0000FF','#0000DD','#0000BB','#000099','#000088'];
var reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
var greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
var oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
var purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
var teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
var violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
var blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
var yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
var greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
var oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
var purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
var teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
var violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}
else
{var reds = ['#909090','#ffbfbf','#ffacac','#ff9898','#ff8585','#ff7171','#ff5d5d','#ff4a4a','#ff3636','#ff2323','#ff0f0f','#ff0000'];
var blues = ['#909090','#bbbbfe','#a8a8f5','#9595ed','#8282e5','#6f6fdc','#5c5cd4','#4848cb','#3535c3','#2222bb','#0f0fb2','#0909aa'];
var greens = ['#909090','#abe6ab','#9ae099','#88d988','#77d376','#65cc64','#54c653','#42c041','#31b92f','#1fb31e','#0ead0c','#00a500'];
var yellows = ['#909090','#fcfcb9','#f0f0a6','#e4e492','#d8d87e','#cccc6b','#c0c057','#b4b443','#a8a830','#9c9c1c','#909008','#7a7a00'];
var oranges = ['#909090','#ffdbb7','#ffd1a4','#ffc790','#ffbc7d','#ffb269','#ffa855','#ff9e42','#ff932e','#ff891b','#ff7f07','#ff6e02'];
var purples = ['#909090','#e2a4e2','#da92da','#d280d2','#ca6fca','#c25dc2','#b94bb9','#b13ab1','#a928a9','#a116a1','#990599','#860081'];
var teals = ['#909090','#b3fbfb','#9ff4f4','#8becec','#76e5e5','#62dddd','#4ed6d6','#3acfcf','#25c7c7','#11c0c0','#4dbbcf','#3ab7c7'];
var violets = ['#909090','#ffb2ff','#ff9eff','#ff8aff','#ff77ff','#ff63ff','#ff50ff','#ff3cff','#ff29ff','#ff15ff','#ff01ff','#ff00ef'];
var reds7 = ['#909090','#febdbd','#f4a3a3', '#e98a8a', '#df7171', '#d45757', '#c93e3e', '#bf2525'];
var blues7 = ['#909090', '#b0b4f9', '#979aef', '#7e81e4', '#6467da', '#4b4dd0', '#3233c5', '#1919bb'];
var reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
var greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
var oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
var purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
var teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
var violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
var blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
var reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
var blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
var yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
var greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
var oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
var purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
var teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
var violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}

var tie = '#c0c0c0';
var novotes = '#707070';
var whites = '#ffffff';

Wincolor1 = new Array(20);
Wincolor2 = new Array(20);
Wincolor3 = new Array(20);
Wincolor4 = new Array(20);
Wincolor5 = new Array(20);
Wincolor6 = new Array(20);
Wincolor7 = new Array(20);
Wincolor8 = new Array(20);
Winstatus1 = new Array(30);
JMCcolor1 = new Array(20);
JMCcolor2 = new Array(20);
JMCcolor3 = new Array(20);
JMCcolor4 = new Array(20);
JMCcolor5 = new Array(20);
JMCcolor6 = new Array(20);
JMCcolor7 = new Array(20);
JMCcolor8 = new Array(20);
JMCstatus1 = new Array(30);
Margincolor1 = new Array(11);
Margincolor2 = new Array(11);
Marginstatus1 = new Array(30);
Marginstatus2 = new Array(30);
Margin7color1 = new Array(7);
Margin7color2 = new Array(7);
Margin7status1 = new Array(30);
Margin7status2 = new Array(30);
PCTcolor1 = new Array(15);
PCTcolor2 = new Array(15);
PCTstatus1 = new Array(30);
PCTstatus2 = new Array(30);
NUMcolor1 = new Array(19);
NUMcolor2 = new Array(19);
NUMstatus1 = new Array(30);
NUMstatus2 = new Array(30);

if (margincolornegative === 'blues') {margincolor1 = blues; margin1default = blues; margincolor1txt = 'Blue'}
else if (margincolornegative === 'reds') {margincolor1 = reds; margin1default = reds; margincolor1txt = 'Red'}
else if (margincolornegative === 'greens') {margincolor1 = greens; margin1default = greens; margincolor1txt = 'Green'}
else if (margincolornegative === 'yellows') {margincolor1 = yellows; margin1default = yellows; margincolor1txt = 'Yellow'}
else if (margincolornegative === 'oranges') {margincolor1 = oranges; margin1default = oranges; margincolor1txt = 'Orange'}
else if (margincolornegative === 'purples') {margincolor1 = purples; margin1default = purples; margincolor1txt = 'Purple'}
else if (margincolornegative === 'teals') {margincolor1 = teals; margin1default = teals; margincolor1txt = 'Teal'}
else if (margincolornegative === 'violets') {margincolor1 = violets; margin1default = violets; margincolor1txt = 'Violet'}
else {margincolor1 = blues; margin1default = blues; margincolor1txt = 'Blue'}


if (margincolorpositive === 'reds') {margincolor2 = reds; margin2default = reds; margincolor2txt = 'Red'}
else if (margincolorpositive === 'blues') {margincolor2 = blues; margin2default = blues; margincolor2txt = 'Blue'}
else if (margincolorpositive === 'greens') {margincolor2 = greens; margin2default = greens; margincolor2txt = 'Green'}
else if (margincolorpositive === 'yellows') {margincolor2 = yellows; margin2default = yellows; margincolor2txt = 'Yellow'}
else if (margincolorpositive === 'oranges') {margincolor2 = oranges; margin2default = oranges; margincolor2txt = 'Orange'}
else if (margincolorpositive === 'purples') {margincolor2 = purples; margin2default = purples; margincolor2txt = 'Purple'}
else if (margincolorpositive === 'teals') {margincolor2 = teals; margin2default = teals; margincolor2txt = 'Teal'}
else if (margincolorpositive === 'violets') {margincolor2 = violets; margin2default = violets; margincolor2txt = 'Violet'}
else {margincolor2 = reds; margin2default = reds; margincolor2txt = 'Red'}

if (margin7colornegative === 'blues') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'reds') {margincolor71 = reds7; margin71default = reds7; margincolor71txt = 'Red'}
else if (margin7colornegative === 'greens') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'yellows') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'oranges') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'purples') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'teals') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else if (margin7colornegative === 'violets') {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}
else {margincolor71 = blues7; margin71default = blues7; margincolor71txt = 'Blue'}

if (margin7colorpositive === 'reds') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'blues') {margincolor72 = blues7; margin72default = blues7; margincolor72txt = 'Blue'}
else if (margin7colorpositive === 'greens') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'yellows') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'oranges') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'purples') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'teals') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else if (margin7colorpositive === 'violets') {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}
else {margincolor72 = reds7; margin72default = reds7; margincolor72txt = 'Red'}

if (PopPCTcolornegative === 'blues') {PopPCTcolor1 = blues15; PopPCTcolor1txt = 'Blue'; PopPCT1default = blues15}
else if (PopPCTcolornegative === 'reds') {PopPCTcolor1 = reds15; PopPCTcolor1txt = 'Red'; PopPCT1default = reds15}
else if (PopPCTcolornegative === 'greens') {PopPCTcolor1 = greens15; PopPCTcolor1txt = 'Green'; PopPCT1default = greens}
else if (PopPCTcolornegative === 'yellows') {PopPCTcolor1 = yellows15; PopPCTcolor1txt = 'Yellow'; PopPCT1default = yellows}
else if (PopPCTcolornegative === 'oranges') {PopPCTcolor1 = oranges15; PopPCTcolor1txt = 'Orange'; PopPCT1default = oranges}
else if (PopPCTcolornegative === 'purples') {PopPCTcolor1 = purples15; PopPCTcolor1txt = 'Purple'; PopPCT1default = purples}
else if (PopPCTcolornegative === 'teals') {PopPCTcolor1 = teals15; PopPCTcolor1txt = 'Teal'; PopPCT1default = teals}
else if (PopPCTcolornegative === 'violets') {PopPCTcolor1 = violets15; PopPCTcolor1txt = 'Violet'; PopPCT1default = violets}
else {PopPCTcolor1 = blues15; PopPCT1default = blues; PopPCTcolor1txt = 'Blue'}

if (PopPCTcolorpositive === 'reds') {PopPCTcolor2 = reds15; PopPCTcolor2txt = 'Red'; PopPCT2default = reds}
else if (PopPCTcolorpositive === 'blues') {PopPCTcolor2 = blues15; PopPCTcolor2txt = 'Blue'; PopPCT2default = blues}
else if (PopPCTcolorpositive === 'greens') {PopPCTcolor2 = greens15; PopPCTcolor2txt = 'Green'; PopPCT2default = greens}
else if (PopPCTcolorpositive === 'yellows') {PopPCTcolor2 = yellows15; PopPCTcolor2txt = 'Yellow'; PopPCT2default = yellows}
else if (PopPCTcolorpositive === 'oranges') {PopPCTcolor2 = oranges15; PopPCTcolor2txt = 'Orange'; PopPCT2default = oranges}
else if (PopPCTcolorpositive === 'purples') {PopPCTcolor2 = purples15; PopPCTcolor2txt = 'Purple'; PopPCT2default = purples}
else if (PopPCTcolorpositive === 'teals') {PopPCTolor2 = teals15; PopPCTcolor2txt = 'Teal'; PopPCT2default = teals}
else if (PopPCTcolorpositive === 'violets') {PopPCTcolor2 = violets15; PopPCTcolor2txt = 'Violet'; PopPCT2default = violets}
else {PopPCTcolor2 = reds15; PopPCT2default = reds; PopPCTcolor2txt = 'Red'}

if (PopNUMcolornegative === 'blues') {PopNUMcolor1 = blues19; PopNUM1default = blues; PopNUMcolor1txt = 'Blue'}
else if (PopNUMcolornegative === 'reds') {PopNUMcolor1 = reds19; PopNUM1default = reds; PopNUMcolor1txt = 'Red'}
else if (PopNUMcolornegative === 'greens') {PopNUMcolor1 = greens19; PopNUM1default = greens; ; PopNUMcolor1txt = 'Green'}
else if (PopNUMcolornegative === 'yellows') {PopNUMcolor1 = yellows19; PopNUM1default = yellows; PopNUMcolor1txt = 'Yellow'}
else if (PopNUMcolornegative === 'oranges') {PopNUMcolor1 = oranges19; PopNUM1default = oranges; PopNUMcolor1txt = 'Orange'}
else if (PopNUMcolornegative === 'purples') {PopNUMcolor1 = purples19; PopNUM1default = purples; PopNUMcolor1txt = 'Purple'}
else if (PopNUMcolornegative === 'teals') {PopNUMcolor1 = teals19; PopNUM1default = teals; PopNUMcolor1txt = 'Teal'}
else if (PopNUMcolornegative === 'violets') {PopNUMcolor1 = violets19; PopNUM1default = violets; PopNUMcolor1txt = 'Violet'}
else {PopNUMcolor1 = blues19; PopNUM1default = blues; PopNUMcolor1txt = 'Blue'}


if (PopNUMcolorpositive === 'reds') {PopNUMcolor2 = reds19; PopNUM2default = reds; PopNUMcolor2txt = 'Red'}
else if (PopNUMcolorpositive === 'blues') {PopNUMcolor2 = blues19; PopNUM2default = blues; PopNUMcolor2txt = 'Blue'}
else if (PopNUMcolorpositive === 'greens') {PopNUMcolor2 = greens19; PopNUM2default = greens; PopNUMcolor2txt = 'Green'}
else if (PopNUMcolorpositive === 'yellows') {PopNUMcolor2 = yellows19; PopNUM2default = yellows; PopNUMcolor2txt = 'Yellow'}
else if (PopNUMcolorpositive === 'oranges') {PopNUMcolor2 = oranges19; PopNUM2default = oranges; PopNUMcolor2txt = 'Orange'}
else if (PopNUMcolorpositive === 'purples') {PopNUMcolor2 = purple19s; PopNUM2default = purples; PopNUMcolor2txt = 'Purple'}
else if (PopNUMcolorpositive === 'teals') {PopNUMcolor2 = teals19; PopNUM2default = teals; PopNUMcolor2txt = 'Teal'}
else if (PopNUMcolorpositive === 'violets') {PopNUMcolor2 = violets19; PopNUM2default = violets; PopNUMcolor2txt = 'Violet'}
else {PopNUMcolor2 = reds19; PopNUM2default = reds; PopNUMcolor2txt = 'Red'}

// Default colorschemes.
for (var i = 0; i < layer.length; i++)
{if(layer[i] === ''){} else {
if (Fillcolor[i] === 'ColorAnc')
{chosenvariable = Wincode[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; ancestrycolor (); Multi[i] = chosencolor}

else if (Fillcolor[i] === 'ColorMargin') {chosenvariable = Wincode[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; mcolor (); Multi[i] = chosencolor3}
else if (Fillcolor[i] === 'ColorPopPCT') {chosenvariable = Wincode[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; ppcolor (); Multi[i] = chosencolor6}
else if (Fillcolor[i] === 'ColorPopNUM') {chosenvariable = Wincode[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; pncolor (); Multi[i] = chosencolor7}
else if (Fillcolor[i] === 'ColorMargin7') {chosenvariable = Wincode[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; m7color (); Multi[i] = chosencolor4}
else if (Fillcolor[i] === 'ColorJMCWincode') {JMCsecondcolor = blues; JMCthirdcolor = reds; JMCfourthcolor = greens; JMCfifthcolor = oranges; JMCsixthcolor = yellows ; JMCseventhcolor = purples; JMCeighthcolor = teals;
if (clickedLayer[1][firstshow[i]][0] === 'W') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = violets; JMCcolor1txt = 'Violet'; chosenvariable = Wincode[1][firstshow[i]][0]; jmccolor (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'R') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = reds; JMCcolor1txt = 'Red'; chosenvariable = Red[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'B') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = blues; JMCcolor1txt = 'Blue'; chosenvariable = Blue[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'Y') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = yellows; JMCcolor1txt = 'Yellow'; chosenvariable = Yellow[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'G') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = greens; JMCcolor1txt = 'Green'; chosenvariable = Green[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'O') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = oranges; JMCcolor1txt = 'Orange'; chosenvariable = Orange[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'P') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = purples; JMCcolor1txt = 'Purple'; chosenvariable = Purple[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'T') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = teals; JMCcolor1txt = 'Teal'; chosenvariable = Teal[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else if (clickedLayer[1][firstshow[i]][0] === 'V') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = violets; JMCcolor1txt = 'Violet'; chosenvariable = Violet[1][firstshow[i]][0]; jmc1color (); Multi[i] = chosencolor5}
else {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; JMCfirstcolor = violets; JMCcolor1txt = 'Violet'; chosenvariable = Wincode[1][firstshow[i]][0]; jmccolor (); Multi[i] = chosencolor5}
}
else {secondcolor = greens; thirdcolor = blues; fourthcolor = yellows; fifthcolor = oranges; sixthcolor = purples; seventhcolor = teals; eighthcolor = violets;
if (clickedLayer[1][firstshow[i]][0] === 'W') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = reds; secondcolor = greens; thirdcolor = blues; fourthcolor = yellows; fifthcolor = oranges; sixthcolor = purples; seventhcolor = teals; eighthcolor = violets; Wincolor1txt = 'Red'; chosenvariable = Wincode[1][firstshow[i]][0]; wcolor (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'R') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = reds; Wincolor1txt = 'Red'; chosenvariable = Red[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'B') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = blues; Wincolor1txt = 'Blue'; chosenvariable = Blue[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'Y') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = yellows; Wincolor1txt = 'Yellow'; chosenvariable = Yellow[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'G') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = greens; Wincolor1txt = 'Green'; chosenvariable = Green[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'O') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = oranges; Wincolor1txt = 'Orange'; chosenvariable = Orange[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'P') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = purples; Wincolor1txt = 'Purple'; chosenvariable = Purple[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'T') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = teals; Wincolor1txt = 'Teal'; chosenvariable = Teal[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else if (clickedLayer[1][firstshow[i]][0] === 'V') {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = violets; Wincolor1txt = 'Violet'; chosenvariable = Violet[1][firstshow[i]][0]; w1color (); Multi[i] = chosencolor2}
else {colorscale = colorstep[1][firstshow[i]][0]; startwincode = startvalue[1][firstshow[i]][0]; firstcolor = reds; Wincolor1txt = 'Red'; chosenvariable = Wincode[1][firstshow[i]][0]; wcolor (); Multi[i] = chosencolor2}
}
colorscale = colorstep[0][0][0]}
}
function ancestrycolor () {chosencolor = ["step",
["number",
["get", chosenvariable]
],
reds[0],
0, reds[0],
1, '#ffc3ec',
2, '#8b4513',
3, '#ff4500',
4, '#008084',
5, '#0004fb',
6, '#24a605',
7, '#6b0a7d',
8, '#ff7e00',
9, '#909008',
10, '#ffffff',
11, '#deb988',
12, '#ffa500',
13, '#707070',
14, '#c53bfc',
15, '#3c3f79',
16, '#fef200',
17, '#eeebec',
18, '#6b8e23',
19, '#c2c0bc',
20, '#ae0402',
21, '#f4c89d',
22, '#e3a583',
23, '#d1826a',
24, '#ef7663',
25, '#ae3c37',
26, '#fddaaa',
27, '#f5ca9e',
28, '#edb992',
29, '#e5a986',
30, '#dd997a',
31, '#d4886f',
32, '#cc7863',
33, '#c46857',
34, '#bc574b',
35, '#b4473f',
36, '#ab3633',
37, '#ffdfff',
38, '#ffc5ff',
39, '#ffaaff',
40, '#ff90ff',
41, '#ff75ff',
42, '#ff5bff',
43, '#ff40ff',
44, '#ff26ff',
45, '#ff0bff',
46, '#acacf7',
47, '#5959d3',
48, '#0606ae',
49, '#b20404',
50, '#b30a0a',
51, '#b51010',
52, '#b71616',
53, '#b91c1c',
54, '#bb2222',
55, '#bd2828',
56, '#be2d2d',
57, '#c03333',
58, '#c23939',
59, '#c43f3f',
60, '#c64545',
61, '#c84b4b',
62, '#c95151',
63, '#cb5757',
64, '#cd5d5d',
65, '#cf6363',
66, '#d16969',
67, '#d36f6f',
68, '#d47575',
69, '#d67a7a',
70, '#d88080',
71, '#da8686',
72, '#dc8c8c',
73, '#de9292',
74, '#df9898',
75, '#e19e9e',
76, '#e3fba4',
77, '#e5aaaa',
78, '#e7b0b0',
79, '#e9b6b6',
80, '#eabcbc',
81, '#ecc2c2',
82, '#eec7c7',
83, '#f0cdcd',
84, '#f2d3d3',
85, '#f4d9d9',
86, '#f5dfdf',
87, '#f7e5e5',
88, '#f9ebeb',
89, '#fbf1f1',
90, '#fdf7f7',
91, '#fffdfd',
92, '#e9ffe6',
93, '#daffd4',
94, '#cbffc2',
95, '#bcffaf',
96, '#aeff9d',
97, '#9fff8a',
98, '#90ff78',
99, '#81ff65',
100, '#72ff53',
101, '#64ff40',
102, '#55ff2e',
103, '#46ff1b',
104, '#37ff09',
105, '#dcffd6',
106, '#87ff6c',
107, '#32ff02',
108, '#05d8a8',
109, '#11cb77',
110, '#1dbe47',
111, '#2ab017',
112, '#ffeccf',
113, '#ffd390',
114, '#ffba51',
115, '#ffa112',
116, '#fff0d9',
117, '#ffe5bc',
118, '#ffd9a0',
119, '#ffce83',
120, '#ffc267',
121, '#ffb74a',
122, '#ffac2e',
123, '#ffa011',
124, '#dddddd',
125, '#c8c8c8',
126, '#b2b2b2',
127, '#9d9d9d',
128, '#dcdcdc',
129, '#c9c9c9',
130, '#b5b5b5',
131, '#a2a2a2',
132, '#b3b480',
133, '#b6fcfc',
134, '#87e2e2',
135, '#59c9c9',
136, '#2ab0b0',
137, '#2bb1b1',
138, '#b3fafa',
139, '#a4f2f2',
140, '#95eaea',
141, '#86e2e2',
142, '#77dada',
143, '#68d1d1',
144, '#59c9c9',
145, '#4ac1c1',
146, '#3bb9b9',
147, '#2cb1b1',
148, '#1da9a9',
149, '#0ea1a1',
150, '#049292',
151, '#404040',
152, '#641919',
153, '#d3f8ff',
154, '#acdfff',
155, '#84c5ff',
156, '#5dacff',
157, '#3592ff',
158, '#dafdff',
159, '#bfebff',
160, '#a5daff',
161, '#8ac9ff',
162, '#70b8ff',
163, '#56a7ff',
164, '#3b96ff',
165, '#2185ff',
166, '#6e709d',
167, '#45509e',
168, '#eddce8',
169, '#e9bcda',
170, '#e49dcd',
171, '#df7ebf',
172, '#da5eb2',
173, '#d63fa4',
174, '#d11f97',
175, '#cc0089',
176, '#edd8e6',
177, '#e6acd3',
178, '#e081c1',
179, '#d956ae',
180, '#d32b9c',
181, '#cc0089',
182, '#e9e3a3',
183, '#e2dc9a',
184, '#dbd591',
185, '#d4ce88',
186, '#cdc77f',
187, '#d7d080',
188, '#bfb96d',
189, '#ebe5a6',
190, '#e6e09f',
191, '#e0da98',
192, '#dbd591',
193, '#d5cf8a',
194, '#d0ca83',
195, '#cac47c',
196, '#c5bf75',
197, '#c0ba6e',
198, '#cdfff3',
199, '#bdffee',
200, '#aeffe9',
201, '#9effe5',
202, '#8effe0',
203, '#7fffdb',
204, '#6fffd7',
205, '#60ffd2',
206, '#50ffcd',
207, '#40ffc9',
208, '#31ffc4',
209, '#21ffbf',
210, '#11ffbb',
211, '#02ffb6',
212, '#c9fff2',
213, '#b9ffed',
214, '#a9ffe8',
215, '#9affe3',
216, '#8affdf',
217, '#7bffda',
218, '#6bffd5',
219, '#5bffd1',
220, '#4cffcc',
221, '#3cffc7',
222, '#2dffc3',
223, '#1dffbe',
224, '#0dffb9',
225, '#32efb8',
226, '#c0c0c0',
];
colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = 'N/A';
csslider.max = 1;
csslider.min = 1;
csslider.step = 1;
csslider.value = colorscale

}

function w1color () {chosencolor2 = ["step",
["number",
["get", chosenvariable]
],
firstcolor[0],
0+startwincode/100, firstcolor[0],
0.0000001+startwincode/100, firstcolor[1],
(0.01*colorscale)+startwincode/100, firstcolor[2],
(0.02*colorscale)+startwincode/100, firstcolor[3],
(0.03*colorscale)+startwincode/100, firstcolor[4],
(0.04*colorscale)+startwincode/100, firstcolor[5],
(0.05*colorscale)+startwincode/100, firstcolor[6],
(0.06*colorscale)+startwincode/100, firstcolor[7],
(0.07*colorscale)+startwincode/100, firstcolor[8],
(0.08*colorscale)+startwincode/100, firstcolor[9],
(0.09*colorscale)+startwincode/100, firstcolor[10],
(0.1*colorscale)+startwincode/100, firstcolor[11],
]
}
function wcolor () {chosencolor2 = ["step",
["number",
["get", chosenvariable]
],
reds[0],
0, firstcolor[0],
0.00000000000001, firstcolor[1],
(0.01*colorscale)+startwincode/100, firstcolor[2],
(0.02*colorscale)+startwincode/100, firstcolor[3],
(0.03*colorscale)+startwincode/100, firstcolor[4],
(0.04*colorscale)+startwincode/100, firstcolor[5],
(0.05*colorscale)+startwincode/100, firstcolor[6],
(0.06*colorscale)+startwincode/100, firstcolor[7],
(0.07*colorscale)+startwincode/100, firstcolor[8],
(0.08*colorscale)+startwincode/100, firstcolor[9],
(0.09*colorscale)+startwincode/100, firstcolor[10],
1, firstcolor[11],
1.00000000000001, secondcolor[1],
1+(.01*colorscale)+startwincode/100, secondcolor[2],
1+(.02*colorscale)+startwincode/100, secondcolor[3],
1+(.03*colorscale)+startwincode/100, secondcolor[4],
1+(.04*colorscale)+startwincode/100, secondcolor[5],
1+(.05*colorscale)+startwincode/100, secondcolor[6],
1+(.06*colorscale)+startwincode/100, secondcolor[7],
1+(.07*colorscale)+startwincode/100, secondcolor[8],
1+(.08*colorscale)+startwincode/100, secondcolor[9],
1+(.09*colorscale)+startwincode/100, secondcolor[10],
2, secondcolor[11],
2.00000000000001, thirdcolor[1],
2+(.01*colorscale)+startwincode/100, thirdcolor[2],
2+(.02*colorscale)+startwincode/100, thirdcolor[3],
2+(.03*colorscale)+startwincode/100, thirdcolor[4],
2+(.04*colorscale)+startwincode/100, thirdcolor[5],
2+(.05*colorscale)+startwincode/100, thirdcolor[6],
2+(.06*colorscale)+startwincode/100, thirdcolor[7],
2+(.07*colorscale)+startwincode/100, thirdcolor[8],
2+(.08*colorscale)+startwincode/100, thirdcolor[9],
2+(.09*colorscale)+startwincode/100, thirdcolor[10],
3, thirdcolor[11],
3.00000000000001, fourthcolor[1],
3+(.01*colorscale)+startwincode/100, fourthcolor[2],
3+(.02*colorscale)+startwincode/100, fourthcolor[3],
3+(.03*colorscale)+startwincode/100, fourthcolor[4],
3+(.04*colorscale)+startwincode/100, fourthcolor[5],
3+(.05*colorscale)+startwincode/100, fourthcolor[6],
3+(.06*colorscale)+startwincode/100, fourthcolor[7],
3+(.07*colorscale)+startwincode/100, fourthcolor[8],
3+(.08*colorscale)+startwincode/100, fourthcolor[9],
3+(.09*colorscale)+startwincode/100, fourthcolor[10],
4, fourthcolor[11],
4.00000000000001, fifthcolor[1],
4+(.01*colorscale)+startwincode/100, fifthcolor[2],
4+(.02*colorscale)+startwincode/100, fifthcolor[3],
4+(.03*colorscale)+startwincode/100, fifthcolor[4],
4+(.04*colorscale)+startwincode/100, fifthcolor[5],
4+(.05*colorscale)+startwincode/100, fifthcolor[6],
4+(.06*colorscale)+startwincode/100, fifthcolor[7],
4+(.07*colorscale)+startwincode/100, fifthcolor[8],
4+(.08*colorscale)+startwincode/100, fifthcolor[9],
4+(.09*colorscale)+startwincode/100, fifthcolor[10],
5, fifthcolor[11],
5.00000000000001, sixthcolor[1],
5+(.01*colorscale)+startwincode/100, sixthcolor[2],
5+(.02*colorscale)+startwincode/100, sixthcolor[3],
5+(.03*colorscale)+startwincode/100, sixthcolor[4],
5+(.04*colorscale)+startwincode/100, sixthcolor[5],
5+(.05*colorscale)+startwincode/100, sixthcolor[6],
5+(.06*colorscale)+startwincode/100, sixthcolor[7],
5+(.07*colorscale)+startwincode/100, sixthcolor[8],
5+(.08*colorscale)+startwincode/100, sixthcolor[9],
5+(.09*colorscale)+startwincode/100, sixthcolor[10],
6, sixthcolor[11],
6.00000000000001, seventhcolor[1],
6+(.01*colorscale)+startwincode/100, seventhcolor[2],
6+(.02*colorscale)+startwincode/100, seventhcolor[3],
6+(.03*colorscale)+startwincode/100, seventhcolor[4],
6+(.04*colorscale)+startwincode/100, seventhcolor[5],
6+(.05*colorscale)+startwincode/100, seventhcolor[6],
6+(.06*colorscale)+startwincode/100, seventhcolor[7],
6+(.07*colorscale)+startwincode/100, seventhcolor[8],
6+(.08*colorscale)+startwincode/100, seventhcolor[9],
6+(.09*colorscale)+startwincode/100, seventhcolor[10],
7, seventhcolor[11],
7.00000000000001, eighthcolor[1],
7+(.01*colorscale)+startwincode/100, eighthcolor[2],
7+(.02*colorscale)+startwincode/100, eighthcolor[3],
7+(.03*colorscale)+startwincode/100, eighthcolor[4],
7+(.04*colorscale)+startwincode/100, eighthcolor[5],
7+(.05*colorscale)+startwincode/100, eighthcolor[6],
7+(.06*colorscale)+startwincode/100, eighthcolor[7],
7+(.07*colorscale)+startwincode/100, eighthcolor[8],
7+(.08*colorscale)+startwincode/100, eighthcolor[9],
7+(.09*colorscale)+startwincode/100, eighthcolor[10],
8, eighthcolor[11],
9, tie,
10, novotes,]}
function mcolor () {chosencolor3 = ["step",
["number",
["get", chosenvariable]
],
margincolor1[11],
(-0.10*colorscale)+startwincode/100, margincolor1[11],
(-0.09*colorscale)+startwincode/100, margincolor1[10],
(-0.08*colorscale)+startwincode/100, margincolor1[9],
(-0.07*colorscale)+startwincode/100, margincolor1[8],
(-0.06*colorscale)+startwincode/100, margincolor1[7],
(-0.05*colorscale)+startwincode/100, margincolor1[6],
(-0.04*colorscale)+startwincode/100, margincolor1[5],
(-0.03*colorscale)+startwincode/100, margincolor1[4],
(-0.02*colorscale)+startwincode/100, margincolor1[3],
(-0.01*colorscale)+startwincode/100, margincolor1[2],
(-0.00000000000001*colorscale)+startwincode/100, margincolor1[1],
0+startwincode/100, margincolor1[0],
(0.00000000000001*colorscale)+startwincode/100, margincolor2[1],
(0.01*colorscale)+startwincode/100, margincolor2[2],
(0.02*colorscale)+startwincode/100, margincolor2[3],
(0.03*colorscale)+startwincode/100, margincolor2[4],
(0.04*colorscale)+startwincode/100, margincolor2[5],
(0.05*colorscale)+startwincode/100, margincolor2[6],
(0.06*colorscale)+startwincode/100, margincolor2[7],
(0.07*colorscale)+startwincode/100, margincolor2[8],
(0.08*colorscale)+startwincode/100, margincolor2[9],
(0.09*colorscale)+startwincode/100, margincolor2[10],
(0.10*colorscale)+startwincode/100, margincolor2[11],
]}
function m7color () {chosencolor4 = ["step",
["number",
["get", chosenvariable]
],
margincolor71[7],
(-0.06*colorscale)+startwincode/100, margincolor71[7],
(-0.05*colorscale)+startwincode/100, margincolor71[6],
(-0.04*colorscale)+startwincode/100, margincolor71[5],
(-0.03*colorscale)+startwincode/100, margincolor71[4],
(-0.02*colorscale)+startwincode/100, margincolor71[3],
(-0.01*colorscale)+startwincode/100, margincolor71[2],
(-0.00000000000001*colorscale)+startwincode/100, margincolor71[1],
0+startwincode/100, margincolor71[0],
(0.00000000000001*colorscale)+startwincode/100, margincolor72[1],
(0.01*colorscale)+startwincode/100, margincolor72[2],
(0.02*colorscale)+startwincode/100, margincolor72[3],
(0.03*colorscale)+startwincode/100, margincolor72[4],
(0.04*colorscale)+startwincode/100, margincolor72[5],
(0.05*colorscale)+startwincode/100, margincolor72[6],
(0.06*colorscale)+startwincode/100, margincolor72[7],
]}
function ppcolor () {chosencolor6 = ["step",
["number",
["get", chosenvariable]
],
PopPCTcolor1[15],
(-0.14*colorscale)+startwincode/100, PopPCTcolor1[15],
(-0.13*colorscale)+startwincode/100, PopPCTcolor1[14],
(-0.12*colorscale)+startwincode/100, PopPCTcolor1[13],
(-0.11*colorscale)+startwincode/100, PopPCTcolor1[12],
(-0.10*colorscale)+startwincode/100, PopPCTcolor1[11],
(-0.09*colorscale)+startwincode/100, PopPCTcolor1[10],
(-0.08*colorscale)+startwincode/100, PopPCTcolor1[9],
(-0.07*colorscale)+startwincode/100, PopPCTcolor1[8],
(-0.06*colorscale)+startwincode/100, PopPCTcolor1[7],
(-0.05*colorscale)+startwincode/100, PopPCTcolor1[6],
(-0.04*colorscale)+startwincode/100, PopPCTcolor1[5],
(-0.03*colorscale)+startwincode/100, PopPCTcolor1[4],
(-0.02*colorscale)+startwincode/100, PopPCTcolor1[3],
(-0.01*colorscale)+startwincode/100, PopPCTcolor1[2],
(-0.00000000000001*colorscale)+startwincode/100, PopPCTcolor1[1],
0+startwincode/100, PopPCTcolor1[0],
(0.00000000000001*colorscale)+startwincode/100, PopPCTcolor2[1],
(0.01*colorscale)+startwincode/100, PopPCTcolor2[2],
(0.02*colorscale)+startwincode/100, PopPCTcolor2[3],
(0.03*colorscale)+startwincode/100, PopPCTcolor2[4],
(0.04*colorscale)+startwincode/100, PopPCTcolor2[5],
(0.05*colorscale)+startwincode/100, PopPCTcolor2[6],
(0.06*colorscale)+startwincode/100, PopPCTcolor2[7],
(0.07*colorscale)+startwincode/100, PopPCTcolor2[8],
(0.08*colorscale)+startwincode/100, PopPCTcolor2[9],
(0.09*colorscale)+startwincode/100, PopPCTcolor2[10],
(0.10*colorscale)+startwincode/100, PopPCTcolor2[11],
(0.11*colorscale)+startwincode/100, PopPCTcolor2[12],
(0.12*colorscale)+startwincode/100, PopPCTcolor2[13],
(0.13*colorscale)+startwincode/100, PopPCTcolor2[14],
(0.14*colorscale)+startwincode/100, PopPCTcolor2[15],
]}

function pncolor () {chosencolor7 = ["step",
["number",
["get", chosenvariable]
],
PopNUMcolor1[19],
(-100000000*colorscale)+startwincode, PopNUMcolor1[19],
(-200*colorscale)+startwincode, PopNUMcolor1[18],
(-100*colorscale)+startwincode, PopNUMcolor1[17],
(-50*colorscale)+startwincode, PopNUMcolor1[16],
(-20*colorscale)+startwincode, PopNUMcolor1[15],
(-14*colorscale)+startwincode, PopNUMcolor1[14],
(-13*colorscale)+startwincode, PopNUMcolor1[13],
(-12*colorscale)+startwincode, PopNUMcolor1[12],
(-11*colorscale)+startwincode, PopNUMcolor1[11],
(-10*colorscale)+startwincode, PopNUMcolor1[10],
(-9*colorscale)+startwincode, PopNUMcolor1[9],
(-8*colorscale)+startwincode, PopNUMcolor1[8],
(-7*colorscale)+startwincode, PopNUMcolor1[7],
(-6*colorscale)+startwincode, PopNUMcolor1[6],
(-5*colorscale)+startwincode, PopNUMcolor1[5],
(-4*colorscale)+startwincode, PopNUMcolor1[4],
(-3*colorscale)+startwincode, PopNUMcolor1[3],
(-2*colorscale)+startwincode, PopNUMcolor1[2],
(-1*colorscale)+startwincode, PopNUMcolor1[1],
0+startwincode/100, PopNUMcolor1[0],
(0.00000000000001*colorscale)+startwincode/100, PopNUMcolor2[1],
(1*colorscale)+startwincode, PopNUMcolor2[2],
(2*colorscale)+startwincode, PopNUMcolor2[3],
(3*colorscale)+startwincode, PopNUMcolor2[4],
(4*colorscale)+startwincode, PopNUMcolor2[5],
(5*colorscale)+startwincode, PopNUMcolor2[6],
(6*colorscale)+startwincode, PopNUMcolor2[7],
(7*colorscale)+startwincode, PopNUMcolor2[8],
(8*colorscale)+startwincode, PopNUMcolor2[9],
(9*colorscale)+startwincode, PopNUMcolor2[10],
(10*colorscale)+startwincode, PopNUMcolor2[11],
(11*colorscale)+startwincode, PopNUMcolor2[12],
(12*colorscale)+startwincode, PopNUMcolor2[13],
(13*colorscale)+startwincode, PopNUMcolor2[14],
(14*colorscale)+startwincode, PopNUMcolor2[15],
(20*colorscale)+startwincode, PopNUMcolor2[16],
(50*colorscale)+startwincode, PopNUMcolor2[17],
(100*colorscale)+startwincode, PopNUMcolor2[18],
(200*colorscale)+startwincode, PopNUMcolor2[19]
]}
function jmc1color () {chosencolor5 = ["step",
["number",
["get", chosenvariable]
],
JMCfirstcolor[0],
0+startwincode/100, JMCfirstcolor[0],
0.00000000000001+startwincode/100, JMCfirstcolor[1],
(0.005*colorscale)+startwincode/100, JMCfirstcolor[2],
(0.01*colorscale)+startwincode/100, JMCfirstcolor[3],
(0.02*colorscale)+startwincode/100, JMCfirstcolor[4],
(0.03*colorscale)+startwincode/100, JMCfirstcolor[5],
(0.04*colorscale)+startwincode/100, JMCfirstcolor[6],
(0.05*colorscale)+startwincode/100, JMCfirstcolor[7],
(0.06*colorscale)+startwincode/100, JMCfirstcolor[8],
(0.07*colorscale)+startwincode/100, JMCfirstcolor[9],
(0.08*colorscale)+startwincode/100, JMCfirstcolor[10],
(0.09*colorscale)+startwincode/100, JMCfirstcolor[11],
]
}
function jmccolor () {chosencolor5 = ["step",
["number",
["get", chosenvariable]
],
reds[0],
0, JMCfirstcolor[0],
0.00000000000001, JMCfirstcolor[1],
(0.005*colorscale)+startwincode/100, JMCfirstcolor[2],
(0.01*colorscale)+startwincode/100, JMCfirstcolor[3],
(0.02*colorscale)+startwincode/100, JMCfirstcolor[4],
(0.03*colorscale)+startwincode/100, JMCfirstcolor[5],
(0.04*colorscale)+startwincode/100, JMCfirstcolor[6],
(0.05*colorscale)+startwincode/100, JMCfirstcolor[7],
(0.06*colorscale)+startwincode/100, JMCfirstcolor[8],
(0.07*colorscale)+startwincode/100, JMCfirstcolor[9],
(0.08*colorscale)+startwincode/100, JMCfirstcolor[10],
(0.09*colorscale)+startwincode/100, JMCfirstcolor[11],
1, JMCfirstcolor[11],
1.00000000000001, JMCsecondcolor[1],
1+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[2],
1+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[3],
1+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[4],
1+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[5],
1+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[6],
1+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[7],
1+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[8],
1+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[9],
1+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[10],
1+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsecondcolor[11],
2, JMCsecondcolor[11],
2.00000000000001, JMCthirdcolor[1],
2+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[2],
2+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[3],
2+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[4],
2+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[5],
2+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[6],
2+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[7],
2+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[8],
2+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[9],
2+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[10],
2+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCthirdcolor[11],
3, JMCthirdcolor[11],
3.00000000000001, JMCfourthcolor[1],
3+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[2],
3+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[3],
3+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[4],
3+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[5],
3+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[6],
3+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[7],
3+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[8],
3+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[9],
3+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[10],
3+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfourthcolor[11],
4, JMCfourthcolor[11],
4.00000000000001, JMCfifthcolor[1],
4+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[2],
4+(.01.colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[3],
4+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[4],
4+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[5],
4+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[6],
4+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[7],
4+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[8],
4+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[9],
4+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[10],
4+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCfifthcolor[11],
5, JMCfifthcolor[11],
5.00000000000001, JMCsixthcolor[1],
5+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[2],
5+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[3],
5+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[4],
5+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[5],
5+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[6],
5+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[7],
5+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[8],
5+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[9],
5+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[10],
5+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCsixthcolor[11],
6, JMCsixthcolor[11],
6.00000000000001, JMCseventhcolor[1],
6+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[2],
6+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[3],
6+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[4],
6+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[5],
6+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[6],
6+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[7],
6+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[8],
6+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[9],
6+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[10],
6+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCseventhcolor[11],
7, JMCseventhcolor[11],
7.00000000000001, JMCeighthcolor[1],
7+(.005*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[2],
7+(.01*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[3],
7+(.02*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[4],
7+(.03*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[5],
7+(.04*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[6],
7+(.05*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[7],
7+(.06*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[8],
7+(.07*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[9],
7+(.08*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[10],
7+(.09*colorscale)+startvalue[firstmatrix][secondmatrix][thirdmatrix], JMCeighthcolor[11],
8, JMCeighthcolor[11],
9, tie,
10, novotes,
]}
function JMClabel () {if((startwincode)>10) {colorpct500b.textContent = Math.round(startwincode)} else colorpct500b.textContent = Math.round(startwincode*10)/10
if(((startwincode))>10) {colorpct510.textContent = '>' + Math.round(startwincode)} else colorpct510.textContent = '>' + Math.round(startwincode*10)/10
if(((colorscale*0.005+startwincode/100)*100)>10) {colorpct520.textContent = Math.round((colorscale*0.005+startwincode/100)*100)} else colorpct520.textContent = Math.round((colorscale*0.005+startwincode/100)*1000)/10
if(((colorscale*0.01+startwincode/100)*100)>10) {colorpct530.textContent = Math.round((colorscale*0.01+startwincode/100)*100)} else colorpct530.textContent = Math.round((colorscale*0.01+startwincode/100)*1000)/10
if(((colorscale*0.02+startwincode/100)*100)>10) {colorpct540.textContent = Math.round((colorscale*0.02+startwincode/100)*100)} else colorpct540.textContent = Math.round((colorscale*0.02+startwincode/100)*1000)/10
if(((colorscale*0.03+startwincode/100)*100)>10) {colorpct550.textContent = Math.round((colorscale*0.03+startwincode/100)*100)} else colorpct550.textContent = Math.round((colorscale*0.03+startwincode/100)*1000)/10
if(((colorscale*0.04+startwincode/100)*100)>10) {colorpct560.textContent = Math.round((colorscale*0.04+startwincode/100)*100)} else colorpct560.textContent = Math.round((colorscale*0.04+startwincode/100)*1000)/10
if(((colorscale*0.05+startwincode/100)*100)>10) {colorpct570.textContent = Math.round((colorscale*0.05+startwincode/100)*100)} else colorpct570.textContent = Math.round((colorscale*0.05+startwincode/100)*1000)/10
if(((colorscale*0.06+startwincode/100)*100)>10) {colorpct580.textContent = Math.round((colorscale*0.06+startwincode/100)*100)} else colorpct580.textContent = Math.round((colorscale*0.06+startwincode/100)*1000)/10
if(((colorscale*0.07+startwincode/100)*100)>10) {colorpct590.textContent = Math.round((colorscale*0.07+startwincode/100)*100)} else colorpct590.textContent = Math.round((colorscale*0.07+startwincode/100)*1000)/10
if(((colorscale*0.08+startwincode/100)*100)>10) {colorpct600.textContent = Math.round((colorscale*0.08+startwincode/100)*100)} else colorpct600.textContent = Math.round((colorscale*0.08+startwincode/100)*1000)/10
if(((colorscale*0.09+startwincode/100)*100)>10) {colorpct600a.textContent = Math.round((colorscale*0.09+startwincode/100)*100)+"+"} else colorpct600a.textContent = Math.round((colorscale*0.09+startwincode/100)*1000)/10+'+'
colorpct600c.textContent = ''
colorpct600d.textContent = ''
colorpct600e.textContent = ''
colorpct600f.textContent = ''
colorpct600g.textContent = ''
colorpct600h.textContent = ''
colorpct600i.textContent = ''
colorpct600j.textContent = ''}
function PPlabel () {if (((startwincode))>10) {colorpct500b.textContent = Math.round(startwincode)} else colorpct500b.textContent = Math.round(startwincode*10)/10
if(((startwincode))>10) {colorpct510.textContent = '>' + Math.round(startwincode)} else colorpct510.textContent = '>' + Math.round(startwincode*10)/10
if(((colorscale*0.01+startwincode/100)*100)>100) {colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*100)} else colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*1000)/10
if(((colorscale*0.02+startwincode/100)*100)>100) {colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*100)} else colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*1000)/10
if(((colorscale*0.03+startwincode/100)*100)>100) {colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*100)} else colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*1000)/10
if(((colorscale*0.04+startwincode/100)*100)>100) {colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*100)} else colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*1000)/10
if(((colorscale*0.05+startwincode/100)*100)>100) {colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*100)} else colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*1000)/10
if(((colorscale*0.06+startwincode/100)*100)>100) {colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*100)} else colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*1000)/10
if(((colorscale*0.07+startwincode/100)*100)>100) {colorpct580.textContent = Math.round((colorscale*0.07+startwincode/100)*100)} else colorpct580.textContent = Math.round((colorscale*0.07+startwincode/100)*1000)/10
if(((colorscale*0.08+startwincode/100)*100)>100) {colorpct590.textContent = Math.round((colorscale*0.08+startwincode/100)*100)} else colorpct590.textContent = Math.round((colorscale*0.08+startwincode/100)*1000)/10
if(((colorscale*0.09+startwincode/100)*100)>100) {colorpct600.textContent = Math.round((colorscale*0.09+startwincode/100)*100)} else colorpct600.textContent = Math.round((colorscale*0.09+startwincode/100)*1000)/10
if(((colorscale*0.10+startwincode/100)*100)>100) {colorpct600a.textContent = Math.round((colorscale*0.10+startwincode/100)*100)} else colorpct600a.textContent = Math.round((colorscale*0.10+startwincode/100)*1000)/10
if(((colorscale*0.11+startwincode/100)*100)>100) {colorpct600c.textContent = Math.round((colorscale*0.11+startwincode/100)*100)} else colorpct600c.textContent = Math.round((colorscale*0.11+startwincode/100)*1000)/10
if(((colorscale*0.12+startwincode/100)*100)>100) {colorpct600d.textContent = Math.round((colorscale*0.12+startwincode/100)*100)} else colorpct600d.textContent = Math.round((colorscale*0.12+startwincode/100)*1000)/10
if(((colorscale*0.13+startwincode/100)*100)>100) {colorpct600e.textContent = Math.round((colorscale*0.13+startwincode/100)*100)} else colorpct600e.textContent = Math.round((colorscale*0.13+startwincode/100)*1000)/10
if(((colorscale*0.14+startwincode/100)*100)>100) {colorpct600f.textContent = Math.round((colorscale*0.14+startwincode/100)*100) + '+'} else colorpct600f.textContent = Math.round((colorscale*0.14+startwincode/100)*1000)/10 + '+'
colorpct600g.textContent = ''
colorpct600h.textContent = ''
colorpct600i.textContent = ''
colorpct600j.textContent = ''}
function PNlabel () {if((startwincode)>10) {colorpct500b.textContent = Math.round(startwincode/1000)} else colorpct500b.textContent = Math.round((startwincode/100000)*1000)/10
if(((startwincode))>10) {colorpct510.textContent = '>' + Math.round(startwincode*100)} else colorpct510.textContent = '>' +Math.round(startwincode*1000)/10
if(((colorscale/10000+startwincode/100)*100)>100) {colorpct520.textContent = Math.round((colorscale*1/100000+startwincode)*100)} else colorpct520.textContent = Math.round((colorscale*1/100000+startwincode)*1000)/10
if(((colorscale*2/10000+startwincode)*100)>100) {colorpct530.textContent = Math.round((colorscale*2/100000+startwincode)*100)} else colorpct530.textContent = Math.round((colorscale*2/100000+startwincode)*1000)/10
if(((colorscale*3/10000+startwincode)*100)>100) {colorpct540.textContent = Math.round((colorscale*3/100000+startwincode)*100)} else colorpct540.textContent = Math.round((colorscale*3/100000+startwincode)*1000)/10
if(((colorscale*4/10000+startwincode)*100)>100) {colorpct550.textContent = Math.round((colorscale*4/100000+startwincode)*100)} else colorpct550.textContent = Math.round((colorscale*4/100000+startwincode)*1000)/10
if(((colorscale*5/10000+startwincode)*100)>100) {colorpct560.textContent = Math.round((colorscale*5/100000+startwincode)*100)} else colorpct560.textContent = Math.round((colorscale*5/100000+startwincode)*1000)/10
if(((colorscale*6/10000+startwincode)*100)>100) {colorpct570.textContent = Math.round((colorscale*6/100000+startwincode)*100)} else colorpct570.textContent = Math.round((colorscale*6/100000+startwincode)*1000)/10
if(((colorscale*7/10000+startwincode)*100)>100) {colorpct580.textContent = Math.round((colorscale*7/100000+startwincode)*100)} else colorpct580.textContent = Math.round((colorscale*7/100000+startwincode)*1000)/10
if(((colorscale*8/10000+startwincode)*100)>100) {colorpct590.textContent = Math.round((colorscale*8/100000+startwincode)*100)} else colorpct590.textContent = Math.round((colorscale*8/100000+startwincode)*1000)/10
if(((colorscale*9/10000+startwincode)*100)>100) {colorpct600.textContent = Math.round((colorscale*9/100000+startwincode)*100)} else colorpct600.textContent = Math.round((colorscale*9/100000+startwincode)*1000)/10
if(((colorscale*10/10000+startwincode)*100)>100) {colorpct600a.textContent = Math.round((colorscale*10/100000+startwincode)*100)} else colorpct600a.textContent = Math.round((colorscale*10/100000+startwincode)*1000)/10
if(((colorscale*11/10000+startwincode)*100)>100) {colorpct600c.textContent = Math.round((colorscale*11/100000+startwincode)*100)} else colorpct600c.textContent = Math.round((colorscale*11/100000+startwincode)*1000)/10
if(((colorscale*12/10000+startwincode)*100)>100) {colorpct600d.textContent = Math.round((colorscale*12/100000+startwincode)*100)} else colorpct600d.textContent = Math.round((colorscale*12/100000+startwincode)*1000)/10
if(((colorscale*13/10000+startwincode)*100)>100) {colorpct600e.textContent = Math.round((colorscale*13/100000+startwincode)*100)} else colorpct600e.textContent = Math.round((colorscale*13/100000+startwincode)*1000)/10
if(((colorscale*14/10000+startwincode)*100)>100) {colorpct600f.textContent = Math.round((colorscale*14/100000+startwincode)*100)} else colorpct600f.textContent = Math.round((colorscale*14/100000+startwincode)*1000)/10
if(((colorscale*20/10000+startwincode)*100)>100) {colorpct600g.textContent = Math.round((colorscale*20/100000+startwincode)*100)} else colorpct600g.textContent = Math.round((colorscale*20/100000+startwincode)*1000)/10
if(((colorscale*50/10000+startwincode)*100)>100) {colorpct600h.textContent = Math.round((colorscale*50/100000+startwincode)*100)} else colorpct600h.textContent = Math.round((colorscale*50/100000+startwincode)*1000)/10
if(((colorscale*100/10000+startwincode)*100)>100) {colorpct600i.textContent = Math.round((colorscale*100/100000+startwincode)*100)} else colorpct600i.textContent = Math.round((colorscale*100/100000+startwincode)*1000)/10
if(((colorscale*200/10000+startwincode)*100)>100) {colorpct600j.textContent = Math.round((colorscale*200/100000+startwincode)*100)+"+K"} else colorpct600j.textContent = Math.round((colorscale*200/100000+startwincode)*1000)/10+'+K'}
function m7label () {if((startwincode)>10) {colorpct500b.textContent = Math.round(startwincode)} else colorpct500b.textContent = Math.round(startwincode*10)/10
if(((startwincode))>10) {colorpct510.textContent = '>' + Math.round(startwincode)} else colorpct510.textContent = '>' + Math.round(startwincode*10)/10
if(((colorscale*0.01+startwincode/100)*100)>100) {colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*100)} else colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*1000)/10
if(((colorscale*0.02+startwincode/100)*100)>100) {colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*100)} else colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*1000)/10
if(((colorscale*0.03+startwincode/100)*100)>100) {colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*100)} else colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*1000)/10
if(((colorscale*0.04+startwincode/100)*100)>100) {colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*100)} else colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*1000)/10
if(((colorscale*0.05+startwincode/100)*100)>100) {colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*100)} else colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*1000)/10
if(((colorscale*0.06+startwincode/100)*100)>100) {colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*100) +'+'} else colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*1000)/10 + '+'
colorpct580.textContent = ''
colorpct590.textContent = ''
colorpct600.textContent = ''
colorpct600a.textContent = ''
colorpct600c.textContent = ''
colorpct600d.textContent = ''
colorpct600e.textContent = ''
colorpct600f.textContent = ''
colorpct600g.textContent = ''
colorpct600h.textContent = ''
colorpct600i.textContent = ''
colorpct600j.textContent = ''}
function otherlabel () {if((startwincode)>10) {colorpct500b.textContent = Math.round(startwincode)} else colorpct500b.textContent = Math.round(startwincode*10)/10
if(((startwincode)>10)) {colorpct510.textContent = '>' + Math.round(startwincode)} else colorpct510.textContent = '>' + Math.round(startwincode*10)/10
if(((colorscale*0.01+startwincode/100)*100)>100) {colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*100)} else colorpct520.textContent = Math.round((colorscale*0.01+startwincode/100)*1000)/10
if(((colorscale*0.02+startwincode/100)*100)>100) {colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*100)} else colorpct530.textContent = Math.round((colorscale*0.02+startwincode/100)*1000)/10
if(((colorscale*0.03+startwincode/100)*100)>100) {colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*100)} else colorpct540.textContent = Math.round((colorscale*0.03+startwincode/100)*1000)/10
if(((colorscale*0.04+startwincode/100)*100)>100) {colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*100)} else colorpct550.textContent = Math.round((colorscale*0.04+startwincode/100)*1000)/10
if(((colorscale*0.05+startwincode/100)*100)>100) {colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*100)} else colorpct560.textContent = Math.round((colorscale*0.05+startwincode/100)*1000)/10
if(((colorscale*0.06+startwincode/100)*100)>100) {colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*100)} else colorpct570.textContent = Math.round((colorscale*0.06+startwincode/100)*1000)/10
if(((colorscale*0.07+startwincode/100)*100)>100) {colorpct580.textContent = Math.round((colorscale*0.07+startwincode/100)*100)} else colorpct580.textContent = Math.round((colorscale*0.07+startwincode/100)*1000)/10
if(((colorscale*0.08+startwincode/100)*100)>100) {colorpct590.textContent = Math.round((colorscale*0.08+startwincode/100)*100)} else colorpct590.textContent = Math.round((colorscale*0.08+startwincode/100)*1000)/10
if(((colorscale*0.09+startwincode/100)*100)>100) {colorpct600.textContent = Math.round((colorscale*0.09+startwincode/100)*100)} else colorpct600.textContent = Math.round((colorscale*0.09+startwincode/100)*1000)/10
if(((colorscale*0.10+startwincode/100)*100)>100) {colorpct600a.textContent = Math.round((colorscale*0.10+startwincode/100)*100)+'+'} else colorpct600a.textContent = Math.round((colorscale*0.10+startwincode/100)*1000)/10+'+'
colorpct600c.textContent = ''
colorpct600d.textContent = ''
colorpct600e.textContent = ''
colorpct600f.textContent = ''
colorpct600g.textContent = ''
colorpct600h.textContent = ''
colorpct600i.textContent = ''
colorpct600j.textContent = ''
}
//Check for small screen
let mq = window.matchMedia( "(max-width: 575px)" );
if (mq.matches) {var cellphone = 'Y'
// window width is at less than 575px
}
else {var cellphone = 'N'
// window width is greater than 575px
}
//Check for landscape mode
let mh = window.matchMedia( "(max-height: 485px)" );
if (mh.matches) {var cellphone = 'Y'
// window height is at less than 485px
}
//load map
map.on('load',
function () {map.addLayer({
id: layer[1],
type: 'fill',
source: {
type: 'vector',
// Mapbox tileset Map ID - default tileset
url: layerURL[1]
},
'source-layer': layer[1],
paint: {
'fill-color': Multi[1],
'fill-outline-color': Multi[1],
'fill-opacity': 0.9,
},
layout: {'visibility': 'visible'}
})
// Load other tilesets hidden
for (var i = 2; i < layer.length; i++)
{if(layer[i] === ''){} else {
map.addLayer({
id: layer[i],
type: 'fill',
source: {
type: 'vector',
url: layerURL[i]
},
'source-layer': layer[i],
paint: {
'fill-color': Multi[i],
'fill-opacity': 0.9,
},
layout: {'visibility': 'none'}
})
}}
//Menu propagation counter to avoid multiple appendages. Must edit/add variable for new maps
var xstatus = [0,0,0,0,0,0,0,0,0,0,0]
var xAstatus = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var xColorstatus = 0
var xIsolatestatus = 0
var xWinColorstatus = 1
var xWinColorreset = 0
var xWinResetstatus = 0
var xJMCIsolatestatus = 0
var xJMCColorstatus = 1
var xJMCColorreset = 0
var xJMCResetstatus = 0
var xMarginIsolatestatus = 0
var xMarginIsolatestatus2 = 0
var xMarginColorstatus = 1
var xMarginColorreset = 0
var xMarginResetstatus = 0
var xMargin7Isolatestatus = 0
var xMargin7Isolatestatus2 = 0
var xMargin7Colorstatus = 1
var xMargin7Colorreset = 0
var xMargin7Resetstatus = 0
var xPopPCTIsolatestatus = 0
var xPopPCTIsolatestatus2 = 0
var xPopPCTResetstatus = 0
var xPopPCTColorstatus = 1
var xPopPCTColorreset = 0
var xPopNUMIsolatestatus = 0
var xPopNUMIsolatestatus2 = 0
var xPopNUMResetstatus = 0
var xPopNUMColorstatus = 1
var xPopNUMColorreset = 0
var xColorMlstatus = 0
var xColorMhstatus = 0
var xColorMPPstatus = 0
var xColorMPPhstatus = 0
var xColorMPNstatus = 0
var xColorMPNhstatus = 0
//Menu name shortcuts. Must edit/add variable for new maps
var mas = [document.getElementById('ma1'),document.getElementById('ma1'),document.getElementById('ma2'),document.getElementById('ma3'),document.getElementById('ma4'),document.getElementById('ma5'),document.getElementById('ma6'),document.getElementById('ma7'),document.getElementById('ma8'),document.getElementById('ma9'),document.getElementById('ma10')];
var mbs = [document.getElementById('mb1'),document.getElementById('mb1'),document.getElementById('mb2'),document.getElementById('mb3'),document.getElementById('mb4'),document.getElementById('mb5'),document.getElementById('mb6'),document.getElementById('mb7'),document.getElementById('mb8'),document.getElementById('mb9'),document.getElementById('mb10'),
document.getElementById('mb11'),document.getElementById('mb12'),document.getElementById('mb13'),document.getElementById('mb14'),document.getElementById('mb15'),document.getElementById('mb16'),document.getElementById('mb17'),document.getElementById('mb18'),document.getElementById('mb19'),document.getElementById('mb20'),
document.getElementById('mb21'),document.getElementById('mb22'),document.getElementById('mb23'),document.getElementById('mb24'),document.getElementById('mb25'),document.getElementById('mb26'),document.getElementById('mb27'),document.getElementById('mb28'),document.getElementById('mb29'),document.getElementById('mb30'),
document.getElementById('mb31'),document.getElementById('mb32'),document.getElementById('mb33'),document.getElementById('mb34'),document.getElementById('mb35'),document.getElementById('mb36'),document.getElementById('mb37'),document.getElementById('mb38'),document.getElementById('mb39'),document.getElementById('mb40'),
document.getElementById('mb41'),document.getElementById('mb42'),document.getElementById('mb43'),document.getElementById('mb44'),document.getElementById('mb45'),document.getElementById('mb46'),document.getElementById('mb47'),document.getElementById('mb48'),document.getElementById('mb49'),document.getElementById('mb50'),
document.getElementById('mb51'),document.getElementById('mb52'),document.getElementById('mb53'),document.getElementById('mb54'),document.getElementById('mb55'),document.getElementById('mb56'),document.getElementById('mb57'),document.getElementById('mb58'),document.getElementById('mb59'),document.getElementById('mb60'),
document.getElementById('mb61'),document.getElementById('mb62'),document.getElementById('mb63'),document.getElementById('mb64'),document.getElementById('mb65'),document.getElementById('mb66'),document.getElementById('mb67'),document.getElementById('mb68'),document.getElementById('mb69'),document.getElementById('mb70'),
document.getElementById('mb71'),document.getElementById('mb72'),document.getElementById('mb73'),document.getElementById('mb74'),document.getElementById('mb75'),document.getElementById('mb76'),document.getElementById('mb77'),document.getElementById('mb78'),document.getElementById('mb79'),document.getElementById('mb80'),
document.getElementById('mb81'),document.getElementById('mb82'),document.getElementById('mb83'),document.getElementById('mb84'),document.getElementById('mb85'),document.getElementById('mb86'),document.getElementById('mb87'),document.getElementById('mb88'),document.getElementById('mb89'),document.getElementById('mb90'),
document.getElementById('mb91'),document.getElementById('mb92'),document.getElementById('mb93'),document.getElementById('mb94'),document.getElementById('mb95'),document.getElementById('mb96'),document.getElementById('mb97'),document.getElementById('mb98'),document.getElementById('mb99'),document.getElementById('mb100'),
document.getElementById('mb101'),document.getElementById('mb102'),document.getElementById('mb103'),document.getElementById('mb104'),document.getElementById('mb105'),document.getElementById('mb106'),document.getElementById('mb107'),document.getElementById('mb108'),document.getElementById('mb109'),document.getElementById('mb110')];
var legendstatus = document.getElementsByClassName("mylegend");
var colorAmenu = document.getElementById('colorAmenu');
var isolatemenu = document.getElementById('isolatemenu');
var JMCisolatemenu = document.getElementById('JMCisolatemenu');
var PopPCTisolatemenu = document.getElementById('PopPCTisolatemenu');
var PopPCTisolatemenu2 = document.getElementById('PopPCTisolatemenu2');
var PopNUMisolatemenu = document.getElementById('PopNUMisolatemenu');
var PopNUMisolatemenu2 = document.getElementById('PopNUMisolatemenu2');
var Marginisolatemenu = document.getElementById('Marginisolatemenu');
var Marginisolatemenu2 = document.getElementById('Marginisolatemenu2');
var Margin7isolatemenu = document.getElementById('Margin7isolatemenu');
var Margin7isolatemenu2 = document.getElementById('Margin7isolatemenu2');
var colorMlmenu = document.getElementById('colorMlmenu');
var colorMhmenu = document.getElementById('colorMhmenu');
var colorMPPmenu = document.getElementById('colorMPPmenu');
var colorMPPhmenu = document.getElementById('colorMPPhmenu');
var colorMPNmenu = document.getElementById('colorMPNmenu');
var colorMPNhmenu = document.getElementById('colorMPNhmenu');

if (cellphone === 'Y') legendstatus[0].style.display = 'none'
//Function to change map color
function colormap () {
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix]
if (relevantCL === 'W') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'R') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'B') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'Y') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'G') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'O') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
if (relevantCL === 'P') {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
else {chosenvariable = Wincode[main][bmenu][amenu]; firstcolor = reds}
ancestrycolor ()
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor);
}

function colormap2 () {
if (relevantCL === 'W') {firstcolor = reds; secondcolor = greens; thirdcolor = blues; fourthcolor = yellows; fifthcolor = oranges; sixthcolor = purples; seventhcolor = teals; eighthcolor = violets; Wincolor1txt = 'Red'; chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; wcolor ()}
else if (relevantCL === 'R') {chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = reds; Wincolor1txt = 'Red'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'B') {chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = blues; Wincolor1txt = 'Blue'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'Y') {chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = yellows; Wincolor1txt = 'Yellow'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'G') {chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = greens; Wincolor1txt = 'Green'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'O') {chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = oranges; Wincolor1txt = 'Orange'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'P') {chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = purples; Wincolor1txt = 'Purple'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'T') {chosenvariable = Teal[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = teals; Wincolor1txt = 'Teal'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else if (relevantCL === 'V') {chosenvariable = Violet[firstmatrix][secondmatrix][thirdmatrix]; firstcolor = violets; Wincolor1txt = 'Violet'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; w1color ()}
else {firstcolor = reds; Wincolor1txt = 'Red'; secondcolor = greens; thirdcolor = blues; fourthcolor = yellows; fifthcolor = oranges; sixthcolor = purples; seventhcolor = teals; eighthcolor = violets; chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; wcolor ()}
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor2);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor2);
};
function colormap3 () {
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix];
mcolor ();
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor3);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor3);
};
function colormap4 () {
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
if (relevantCL === 'W') {chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = reds7; margincolor72 = blues7; m7color ()}
else if (relevantCL === 'R') {chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = reds7; margincolor72 = blues7; m7color ()}
else if (relevantCL === 'B') {chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'Y') {chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'G') {chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'O') {chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'P') {chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'T') {chosenvariable = Teal[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else if (relevantCL === 'V') {chosenvariable = Violet[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = blues7; margincolor72 = reds7; m7color ()}
else {chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; margincolor71 = reds7; margincolor72 = blues7; m7color ()}
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor4);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor4);
};
function colormap5 () {
if (relevantCL === 'W') {chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = violets; JMCsecondcolor = blues; JMCthirdcolor = reds; JMCcolor1txt = 'Violet'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmccolor ()}
else if (relevantCL === 'R') {chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = reds; JMCcolor1txt = 'Red'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'B') {chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = blues; JMCcolor1txt = 'Blue'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'Y') {chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = yellows; JMCcolor1txt = 'Yellow'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'G') {chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = greens; JMCcolor1txt = 'Green'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'O') {chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = oranges; JMCcolor1txt = 'Orange'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'P') {chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = purples; JMCcolor1txt = 'Purple'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'T') {chosenvariable = Teal[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = teals; JMCcolor1txt = 'Teal'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else if (relevantCL === 'V') {chosenvariable = Violet[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = violets; JMCcolor1txt = 'Violet'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmc1color ()}
else {chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]; JMCfirstcolor = violets; JMCsecondcolor = blues; JMCthirdcolor = reds; JMCcolor1txt = 'Violet'; startwincode=startvalue[firstmatrix][secondmatrix][thirdmatrix]; jmccolor ()}
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor5);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor5);
;}
// PopPCT Color Change
function colormap6 () {
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix];
ppcolor ();
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor6);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor6);
};
// PopNUM Color Change
function colormap7 () {
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix];
pncolor ();
map.setPaintProperty(chosenlayer, 'fill-color', chosencolor7);
map.setPaintProperty(chosenlayer, 'fill-outline-color', chosencolor7);
};
// color stepper funcion
function colorchange () {
csslider.addEventListener('input', function(y) {
// Adjust the colorscale. layer here is arbitrary - this could
// be another layer name found in your style or a custom layer
// added on the fly using `addSource`.
colorscale = y.target.value;
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix]

// Value indicator
cssliderValue.textContent = colorscale + ' points';
if(relevantColor === "JMCWincode"){xJMCResetstatus = 1; JMClabel ()}
else if (relevantColor === 'Ancestry'){cssliderValue.textContent = 'N/A'; otherlabel ()}
else if (relevantColor === 'PopPCT') {xPopPCTResetstatus = 1; PPlabel ()}
else if (relevantColor === 'PopNUM') {xPopNUMResetstatus = 1; cssliderValue.textContent = colorscale + ' residents'; PNlabel ()}
else if (relevantColor === 'Margin7') {xMargin7Resetstatus = 1; m7label ()}
else if (relevantColor === 'Margin') {xMarginResetstatus = 1; otherlabel ()}
else {xWinResetstatus = 1; otherlabel ()}

if(relevantColor === 'Ancestry') {colormap ()} else if (relevantColor === 'Margin') {colormap3 ()} else if (relevantColor === 'Margin7') {colormap4 ()} else if (relevantColor === 'JMCWincode') {colormap5 ()} else if (relevantColor === 'PopPCT') {colormap6 ()} else if (relevantColor === 'PopNUM') {colormap7 ()} else {colormap2 ()}
})}
// Dynamic label function - up to 8 candidates.
function label () {
//labels
if(relevantColor === 'Ancestry'){
var asource = document.getElementsByClassName('legend-source')
asource[0].innerHTML = ancsource
legendA.style.display = 'none'
legendB.style.display = 'none'
if (firsthtml>3) {legendC.style.display = 'none'} else {legendC.style.display = 'block'}
if (firsthtml>4) {legendD.style.display = 'none'} else {legendD.style.display = 'block'}
if (firsthtml>5) {legendE.style.display = 'none'} else {legendE.style.display = 'block'}
if (firsthtml>6) {legendF.style.display = 'none'} else {legendF.style.display = 'block'}
if (firsthtml>7) {legendG.style.display = 'none'} else {legendG.style.display = 'block'}
if (firsthtml>8) {legendH.style.display = 'none'} else {legendH.style.display = 'block'}
resetcolorboxes()
colorpct500b.style.display = 'none'
colorpct510.style.display = 'none'
colorpct520.style.display = 'none'
colorpct530.style.display = 'none'
colorpct540.style.display = 'none'
colorpct550.style.display = 'none'
colorpct560.style.display = 'none'
colorpct570.style.display = 'none'
colorpct580.style.display = 'none'
colorpct590.style.display = 'none'
colorpct600.style.display = 'none'
colorpct600c.style.display = 'none'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600a.style.display = 'none'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
candidateC.textContent = chosencandidateC
colorvalue200b.style = background + colorc
candidateD.textContent = chosencandidateD
colorvalue300b.style = background + colord
candidateE.textContent = chosencandidateE
colorvalue400b.style = background + colore
candidateF.textContent = chosencandidateF
colorvalue500b.style = background + colorf
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + colorg
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + colorh
}
else if(relevantColor === 'Margin'){
var msource = document.getElementsByClassName('legend-source')
msource[0].innerHTML = marginsource
resetcolorboxes()
legendA.style.display = 'none'
legendB.style.display = 'none'
legendC.style.display = 'none'
legendD.style.display = 'none'
legendE.style.display = 'none'
legendF.style.display = 'none'
legendG.style.display = 'block'
legendH.style.display = 'block'
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + margincolor1[0]
colorvalue610.style = background + margincolor1[1]
colorvalue620.style = background + margincolor1[2]
colorvalue630.style = background + margincolor1[3]
colorvalue640.style = background + margincolor1[4]
colorvalue650.style = background + margincolor1[5]
colorvalue660.style = background + margincolor1[6]
colorvalue670.style = background + margincolor1[7]
colorvalue680.style = background + margincolor1[8]
colorvalue690.style = background + margincolor1[9]
colorvalue700.style = background + margincolor1[10]
colorvalue700c.style.display = 'none'
colorvalue700d.style.display = 'none'
colorvalue700e.style.display = 'none'
colorvalue700f.style.display = 'none'
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
colorvalue700a.style = background + margincolor1[11]
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + margincolor2[0]
colorvalue710.style = background + margincolor2[1]
colorvalue720.style = background + margincolor2[2]
colorvalue730.style = background + margincolor2[3]
colorvalue740.style = background + margincolor2[4]
colorvalue750.style = background + margincolor2[5]
colorvalue760.style = background + margincolor2[6]
colorvalue770.style = background + margincolor2[7]
colorvalue780.style = background + margincolor2[8]
colorvalue790.style = background + margincolor2[9]
colorvalue800.style = background + margincolor2[10]
colorvalue800a.style = background + margincolor2[11]
colorvalue800c.style.display = 'none'
colorvalue800d.style.display = 'none'
colorvalue800e.style.display = 'none'
colorvalue800f.style.display = 'none'
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'block'
colorpct590.style.display = 'block'
colorpct600.style.display = 'block'
colorpct600a.style.display = 'block'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
}
else if(relevantColor === 'PopPCT'){
var PPCTsource = document.getElementsByClassName('legend-source')
PPCTsource[0].innerHTML = PopPCTsource
resetcolorboxes()
legendA.style.display = 'none'
legendB.style.display = 'none'
legendC.style.display = 'none'
legendD.style.display = 'none'
legendE.style.display = 'none'
legendF.style.display = 'none'
legendG.style.display = 'block'
legendH.style.display = 'block'
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + PopPCTcolor1[0]
colorvalue610.style = background + PopPCTcolor1[1]
colorvalue620.style = background + PopPCTcolor1[2]
colorvalue630.style = background + PopPCTcolor1[3]
colorvalue640.style = background + PopPCTcolor1[4]
colorvalue650.style = background + PopPCTcolor1[5]
colorvalue660.style = background + PopPCTcolor1[6]
colorvalue670.style = background + PopPCTcolor1[7]
colorvalue680.style = background + PopPCTcolor1[8]
colorvalue690.style = background + PopPCTcolor1[9]
colorvalue700.style = background + PopPCTcolor1[10]
colorvalue700a.style = background + PopPCTcolor1[11]
colorvalue700c.style = background + PopPCTcolor1[12]
colorvalue700d.style = background + PopPCTcolor1[13]
colorvalue700e.style = background + PopPCTcolor1[14]
colorvalue700f.style = background + PopPCTcolor1[15]
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + PopPCTcolor2[0]
colorvalue710.style = background + PopPCTcolor2[1]
colorvalue720.style = background + PopPCTcolor2[2]
colorvalue730.style = background + PopPCTcolor2[3]
colorvalue740.style = background + PopPCTcolor2[4]
colorvalue750.style = background + PopPCTcolor2[5]
colorvalue760.style = background + PopPCTcolor2[6]
colorvalue770.style = background + PopPCTcolor2[7]
colorvalue780.style = background + PopPCTcolor2[8]
colorvalue790.style = background + PopPCTcolor2[9]
colorvalue800.style = background + PopPCTcolor2[10]
colorvalue800a.style = background + PopPCTcolor2[11]
colorvalue800c.style = background + PopPCTcolor2[12]
colorvalue800d.style = background + PopPCTcolor2[13]
colorvalue800e.style = background + PopPCTcolor2[14]
colorvalue800f.style = background + PopPCTcolor2[15]
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'block'
colorpct590.style.display = 'block'
colorpct600.style.display = 'block'
colorpct600a.style.display = 'block'
colorpct600c.style.display = 'block'
colorpct600d.style.display = 'block'
colorpct600e.style.display = 'block'
colorpct600f.style.display = 'block'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
}
else if(relevantColor === 'PopNUM'){
var PNUMsource = document.getElementsByClassName('legend-source')
PNUMsource[0].inner1HTML = PopNUMsource
resetcolorboxes()
legendA.style.display = 'none'
legendB.style.display = 'none'
legendC.style.display = 'none'
legendD.style.display = 'none'
legendE.style.display = 'none'
legendF.style.display = 'none'
legendG.style.display = 'block'
legendH.style.display = 'block'
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + PopNUMcolor1[0]
colorvalue610.style = background + PopNUMcolor1[1]
colorvalue620.style = background + PopNUMcolor1[2]
colorvalue630.style = background + PopNUMcolor1[3]
colorvalue640.style = background + PopNUMcolor1[4]
colorvalue650.style = background + PopNUMcolor1[5]
colorvalue660.style = background + PopNUMcolor1[6]
colorvalue670.style = background + PopNUMcolor1[7]
colorvalue680.style = background + PopNUMcolor1[8]
colorvalue690.style = background + PopNUMcolor1[9]
colorvalue700.style = background + PopNUMcolor1[10]
colorvalue700a.style = background + PopNUMcolor1[11]
colorvalue700c.style = background + PopNUMcolor1[12]
colorvalue700d.style = background + PopNUMcolor1[13]
colorvalue700e.style = background + PopNUMcolor1[14]
colorvalue700f.style = background + PopNUMcolor1[15]
colorvalue700g.style = background + PopNUMcolor1[16]
colorvalue700h.style = background + PopNUMcolor1[17]
colorvalue700i.style = background + PopNUMcolor1[18]
colorvalue700j.style = background + PopNUMcolor1[19]
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + PopNUMcolor2[0]
colorvalue710.style = background + PopNUMcolor2[1]
colorvalue720.style = background + PopNUMcolor2[2]
colorvalue730.style = background + PopNUMcolor2[3]
colorvalue740.style = background + PopNUMcolor2[4]
colorvalue750.style = background + PopNUMcolor2[5]
colorvalue760.style = background + PopNUMcolor2[6]
colorvalue770.style = background + PopNUMcolor2[7]
colorvalue780.style = background + PopNUMcolor2[8]
colorvalue790.style = background + PopNUMcolor2[9]
colorvalue800.style = background + PopNUMcolor2[10]
colorvalue800a.style = background + PopNUMcolor2[11]
colorvalue800c.style = background + PopNUMcolor2[12]
colorvalue800d.style = background + PopNUMcolor2[13]
colorvalue800e.style = background + PopNUMcolor2[14]
colorvalue800f.style = background + PopNUMcolor2[15]
colorvalue800g.style = background + PopNUMcolor2[16]
colorvalue800h.style = background + PopNUMcolor2[17]
colorvalue800i.style = background + PopNUMcolor2[18]
colorvalue800j.style = background + PopNUMcolor2[19]
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'block'
colorpct590.style.display = 'block'
colorpct600.style.display = 'block'
colorpct600a.style.display = 'block'
colorpct600c.style.display = 'block'
colorpct600d.style.display = 'block'
colorpct600e.style.display = 'block'
colorpct600f.style.display = 'block'
colorpct600g.style.display = 'block'
colorpct600h.style.display = 'block'
colorpct600i.style.display = 'block'
colorpct600j.style.display = 'block'}

else if(relevantColor === 'Margin7'){
var m7source = document.getElementsByClassName('legend-source')
m7source[0].innerHTML = marginsource
resetcolorboxes()
legendA.style.display = 'none'
legendB.style.display = 'none'
legendC.style.display = 'none'
legendD.style.display = 'none'
legendE.style.display = 'none'
legendF.style.display = 'none'
legendG.style.display = 'block'
legendH.style.display = 'block'
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + margincolor71[0]
colorvalue610.style = background + margincolor71[1]
colorvalue620.style = background + margincolor71[2]
colorvalue630.style = background + margincolor71[3]
colorvalue640.style = background + margincolor71[4]
colorvalue650.style = background + margincolor71[5]
colorvalue660.style = background + margincolor71[6]
colorvalue670.style = background + margincolor71[7]
colorvalue680.style.display = 'none'
colorvalue690.style.display = 'none'
colorvalue700.style.display = 'none'
colorvalue700c.style.display = 'none'
colorvalue700d.style.display = 'none'
colorvalue700e.style.display = 'none'
colorvalue700f.style.display = 'none'
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
colorvalue700a.style.display = 'none'
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + margincolor72[0]
colorvalue710.style = background + margincolor72[1]
colorvalue720.style = background + margincolor72[2]
colorvalue730.style = background + margincolor72[3]
colorvalue740.style = background + margincolor72[4]
colorvalue750.style = background + margincolor72[5]
colorvalue760.style = background + margincolor72[6]
colorvalue770.style = background + margincolor72[7]
colorvalue780.style.display = 'none'
colorvalue790.style.display = 'none'
colorvalue800.style.display = 'none'
colorvalue800c.style.display = 'none'
colorvalue800d.style.display = 'none'
colorvalue800e.style.display = 'none'
colorvalue800f.style.display = 'none'
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorvalue800a.style.display = 'none'
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'none'
colorpct590.style.display = 'none'
colorpct600.style.display = 'none'
colorpct600a.style.display = 'none'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
}
else if (relevantColor === 'JMCWincode') {
var wsource = document.getElementsByClassName('legend-source')
wsource[0].innerHTML = winsource
resetcolorboxes()
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'block'
colorpct590.style.display = 'block'
colorpct600.style.display = 'block'
colorpct600a.style.display = 'block'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
if (firsthtml>1) {legendA.style.display = 'none'} else {legendA.style.display = 'block'}
if (firsthtml>2) {legendB.style.display = 'none'} else {legendB.style.display = 'block'}
if (firsthtml>3) {legendC.style.display = 'none'} else {legendC.style.display = 'block'}
if (firsthtml>4) {legendD.style.display = 'none'} else {legendD.style.display = 'block'}
if (firsthtml>5) {legendE.style.display = 'none'} else {legendE.style.display = 'block'}
if (firsthtml>6) {legendF.style.display = 'none'} else {legendF.style.display = 'block'}
if (firsthtml>7) {legendG.style.display = 'none'} else {legendG.style.display = 'block'}
if (firsthtml>8) {legendH.style.display = 'none'} else {legendH.style.display = 'block'}
candidateA.textContent = chosencandidateA
colorvalue0b.style = background + colora[0]
colorvalue10.style = background + colora[1]
colorvalue20.style = background + colora[2]
colorvalue30.style = background + colora[3]
colorvalue40.style = background + colora[4]
colorvalue50.style = background + colora[5]
colorvalue60.style = background + colora[6]
colorvalue70.style = background + colora[7]
colorvalue80.style = background + colora[8]
colorvalue90.style = background + colora[9]
colorvalue100.style = background + colora[10]
colorvalue100a.style = background + colora[11]
candidateB.textContent = chosencandidateB
colorvalue100b.style = background + colorb[0]
colorvalue110.style = background + colorb[1]
colorvalue120.style = background + colorb[2]
colorvalue130.style = background + colorb[3]
colorvalue140.style = background + colorb[4]
colorvalue150.style = background + colorb[5]
colorvalue160.style = background + colorb[6]
colorvalue170.style = background + colorb[7]
colorvalue180.style = background + colorb[8]
colorvalue190.style = background + colorb[9]
colorvalue200.style = background + colorb[10]
colorvalue200a.style = background + colorb[11]
candidateC.textContent = chosencandidateC
colorvalue200b.style = background + colorc[0]
colorvalue210.style = background + colorc[1]
colorvalue220.style = background + colorc[2]
colorvalue230.style = background + colorc[3]
colorvalue240.style = background + colorc[4]
colorvalue250.style = background + colorc[5]
colorvalue260.style = background + colorc[6]
colorvalue270.style = background + colorc[7]
colorvalue280.style = background + colorc[8]
colorvalue290.style = background + colorc[9]
colorvalue300.style = background + colorc[10]
colorvalue300a.style = background + colorc[11]
candidateD.textContent = chosencandidateD
colorvalue300b.style = background + colord[0]
colorvalue310.style = background + colord[1]
colorvalue320.style = background + colord[2]
colorvalue330.style = background + colord[3]
colorvalue340.style = background + colord[4]
colorvalue350.style = background + colord[5]
colorvalue360.style = background + colord[6]
colorvalue370.style = background + colord[7]
colorvalue380.style = background + colord[8]
colorvalue390.style = background + colord[9]
colorvalue400.style = background + colord[10]
colorvalue400a.style = background + colord[11]
candidateE.textContent = chosencandidateE
colorvalue400b.style = background + colore[0]
colorvalue410.style = background + colore[1]
colorvalue420.style = background + colore[2]
colorvalue430.style = background + colore[3]
colorvalue440.style = background + colore[4]
colorvalue450.style = background + colore[5]
colorvalue460.style = background + colore[6]
colorvalue470.style = background + colore[7]
colorvalue480.style = background + colore[8]
colorvalue490.style = background + colore[9]
colorvalue500.style = background + colore[10]
colorvalue500a.style = background + colore[11]
candidateF.textContent = chosencandidateF
colorvalue500b.style = background + colorf[0]
colorvalue510.style = background + colorf[1]
colorvalue520.style = background + colorf[2]
colorvalue530.style = background + colorf[3]
colorvalue540.style = background + colorf[4]
colorvalue550.style = background + colorf[5]
colorvalue560.style = background + colorf[6]
colorvalue570.style = background + colorf[7]
colorvalue580.style = background + colorf[8]
colorvalue590.style = background + colorf[9]
colorvalue600.style = background + colorf[10]
colorvalue600a.style = background + colorf[11]
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + colorg[0]
colorvalue610.style = background + colorg[1]
colorvalue620.style = background + colorg[2]
colorvalue630.style = background + colorg[3]
colorvalue640.style = background + colorg[4]
colorvalue650.style = background + colorg[5]
colorvalue660.style = background + colorg[6]
colorvalue670.style = background + colorg[7]
colorvalue680.style = background + colorg[8]
colorvalue690.style = background + colorg[9]
colorvalue700.style = background + colorg[10]
colorvalue700c.style.display = 'none'
colorvalue700d.style.display = 'none'
colorvalue700e.style.display = 'none'
colorvalue700f.style.display = 'none'
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
colorvalue700a.style = background + colorg[11]
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + colorh[0]
colorvalue710.style = background + colorh[1]
colorvalue720.style = background + colorh[2]
colorvalue730.style = background + colorh[3]
colorvalue740.style = background + colorh[4]
colorvalue750.style = background + colorh[5]
colorvalue760.style = background + colorh[6]
colorvalue770.style = background + colorh[7]
colorvalue780.style = background + colorh[8]
colorvalue790.style = background + colorh[9]
colorvalue800.style = background + colorh[10]
colorvalue800c.style.display = 'none'
colorvalue800d.style.display = 'none'
colorvalue800e.style.display = 'none'
colorvalue800f.style.display = 'none'
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorvalue800a.style = background + colorh[11]}
else {
var wsource = document.getElementsByClassName('legend-source')
wsource[0].innerHTML = winsource
resetcolorboxes()
colorpct500b.style.display = 'block'
colorpct510.style.display = 'block'
colorpct520.style.display = 'block'
colorpct530.style.display = 'block'
colorpct540.style.display = 'block'
colorpct550.style.display = 'block'
colorpct560.style.display = 'block'
colorpct570.style.display = 'block'
colorpct580.style.display = 'block'
colorpct590.style.display = 'block'
colorpct600.style.display = 'block'
colorpct600a.style.display = 'block'
colorpct600c.style.display = 'none'
colorpct600d.style.display = 'none'
colorpct600e.style.display = 'none'
colorpct600f.style.display = 'none'
colorpct600g.style.display = 'none'
colorpct600h.style.display = 'none'
colorpct600i.style.display = 'none'
colorpct600j.style.display = 'none'
if (firsthtml>1) {legendA.style.display = 'none'} else {legendA.style.display = 'block'}
if (firsthtml>2) {legendB.style.display = 'none'} else {legendB.style.display = 'block'}
if (firsthtml>3) {legendC.style.display = 'none'} else {legendC.style.display = 'block'}
if (firsthtml>4) {legendD.style.display = 'none'} else {legendD.style.display = 'block'}
if (firsthtml>5) {legendE.style.display = 'none'} else {legendE.style.display = 'block'}
if (firsthtml>6) {legendF.style.display = 'none'} else {legendF.style.display = 'block'}
if (firsthtml>7) {legendG.style.display = 'none'} else {legendG.style.display = 'block'}
if (firsthtml>8) {legendH.style.display = 'none'} else {legendH.style.display = 'block'}
candidateA.textContent = chosencandidateA
colorvalue0b.style = background + colora[0]
colorvalue10.style = background + colora[1]
colorvalue20.style = background + colora[2]
colorvalue30.style = background + colora[3]
colorvalue40.style = background + colora[4]
colorvalue50.style = background + colora[5]
colorvalue60.style = background + colora[6]
colorvalue70.style = background + colora[7]
colorvalue80.style = background + colora[8]
colorvalue90.style = background + colora[9]
colorvalue100.style = background + colora[10]
colorvalue100a.style = background + colora[11]
candidateB.textContent = chosencandidateB
colorvalue100b.style = background + colorb[0]
colorvalue110.style = background + colorb[1]
colorvalue120.style = background + colorb[2]
colorvalue130.style = background + colorb[3]
colorvalue140.style = background + colorb[4]
colorvalue150.style = background + colorb[5]
colorvalue160.style = background + colorb[6]
colorvalue170.style = background + colorb[7]
colorvalue180.style = background + colorb[8]
colorvalue190.style = background + colorb[9]
colorvalue200.style = background + colorb[10]
colorvalue200a.style = background + colorb[11]
candidateC.textContent = chosencandidateC
colorvalue200b.style = background + colorc[0]
colorvalue210.style = background + colorc[1]
colorvalue220.style = background + colorc[2]
colorvalue230.style = background + colorc[3]
colorvalue240.style = background + colorc[4]
colorvalue250.style = background + colorc[5]
colorvalue260.style = background + colorc[6]
colorvalue270.style = background + colorc[7]
colorvalue280.style = background + colorc[8]
colorvalue290.style = background + colorc[9]
colorvalue300.style = background + colorc[10]
colorvalue300a.style = background + colorc[11]
candidateD.textContent = chosencandidateD
colorvalue300b.style = background + colord[0]
colorvalue310.style = background + colord[1]
colorvalue320.style = background + colord[2]
colorvalue330.style = background + colord[3]
colorvalue340.style = background + colord[4]
colorvalue350.style = background + colord[5]
colorvalue360.style = background + colord[6]
colorvalue370.style = background + colord[7]
colorvalue380.style = background + colord[8]
colorvalue390.style = background + colord[9]
colorvalue400.style = background + colord[10]
colorvalue400a.style = background + colord[11]
candidateE.textContent = chosencandidateE
colorvalue400b.style = background + colore[0]
colorvalue410.style = background + colore[1]
colorvalue420.style = background + colore[2]
colorvalue430.style = background + colore[3]
colorvalue440.style = background + colore[4]
colorvalue450.style = background + colore[5]
colorvalue460.style = background + colore[6]
colorvalue470.style = background + colore[7]
colorvalue480.style = background + colore[8]
colorvalue490.style = background + colore[9]
colorvalue500.style = background + colore[10]
colorvalue500a.style = background + colore[11]
candidateF.textContent = chosencandidateF
colorvalue500b.style = background + colorf[0]
colorvalue510.style = background + colorf[1]
colorvalue520.style = background + colorf[2]
colorvalue530.style = background + colorf[3]
colorvalue540.style = background + colorf[4]
colorvalue550.style = background + colorf[5]
colorvalue560.style = background + colorf[6]
colorvalue570.style = background + colorf[7]
colorvalue580.style = background + colorf[8]
colorvalue590.style = background + colorf[9]
colorvalue600.style = background + colorf[10]
colorvalue600a.style = background + colorf[11]
candidateG.textContent = chosencandidateG
colorvalue600b.style = background + colorg[0]
colorvalue610.style = background + colorg[1]
colorvalue620.style = background + colorg[2]
colorvalue630.style = background + colorg[3]
colorvalue640.style = background + colorg[4]
colorvalue650.style = background + colorg[5]
colorvalue660.style = background + colorg[6]
colorvalue670.style = background + colorg[7]
colorvalue680.style = background + colorg[8]
colorvalue690.style = background + colorg[9]
colorvalue700.style = background + colorg[10]
colorvalue700c.style.display = 'none'
colorvalue700d.style.display = 'none'
colorvalue700e.style.display = 'none'
colorvalue700f.style.display = 'none'
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
colorvalue700a.style = background + colorg[11]
candidateH.textContent = chosencandidateH
colorvalue700b.style = background + colorh[0]
colorvalue710.style = background + colorh[1]
colorvalue720.style = background + colorh[2]
colorvalue730.style = background + colorh[3]
colorvalue740.style = background + colorh[4]
colorvalue750.style = background + colorh[5]
colorvalue760.style = background + colorh[6]
colorvalue770.style = background + colorh[7]
colorvalue780.style = background + colorh[8]
colorvalue790.style = background + colorh[9]
colorvalue800.style = background + colorh[10]
colorvalue800c.style.display = 'none'
colorvalue800d.style.display = 'none'
colorvalue800e.style.display = 'none'
colorvalue800f.style.display = 'none'
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorvalue800a.style = background + colorh[11]
}
}
function clearmenu () {
for (var i = 0; i < 11; i++) {
mas[i].style.display = 'none';}
for (var j = 0; j < 111; j++) {
mbs[j].style.display = 'none';}
colorAmenu.style.display = 'none';
colorMlmenu.style.display = 'none';
colorMhmenu.style.display = 'none';
colorMPPmenu.style.display = 'none';
colorMPPhmenu.style.display = 'none';
colorMPNmenu.style.display = 'none';
colorMPNhmenu.style.display = 'none';
isolatemenu.style.display = 'none';
JMCisolatemenu.style.display = 'none';
PopPCTisolatemenu.style.display = 'none';
PopPCTisolatemenu2.style.display = 'none';
PopNUMisolatemenu.style.display = 'none';
PopNUMisolatemenu2.style.display = 'none';
Marginisolatemenu.style.display = 'none';
Marginisolatemenu2.style.display = 'none';
Margin7isolatemenu.style.display = 'none';
Margin7isolatemenu2.style.display = 'none';
Marginisolatemenu.style.display = 'none';
}
function resetcolorboxes () {
colorvalue0b.style.display = 'none'
colorvalue10.style.display = 'none'
colorvalue20.style.display = 'none'
colorvalue30.style.display = 'none'
colorvalue40.style.display = 'none'
colorvalue50.style.display = 'none'
colorvalue60.style.display = 'none'
colorvalue70.style.display = 'none'
colorvalue80.style.display = 'none'
colorvalue90.style.display = 'none'
colorvalue100.style.display = 'none'
colorvalue100a.style.display = 'none'
colorvalue110.style.display = 'none'
colorvalue100b.style.display = 'none'
colorvalue120.style.display = 'none'
colorvalue130.style.display = 'none'
colorvalue140.style.display = 'none'
colorvalue150.style.display = 'none'
colorvalue160.style.display = 'none'
colorvalue170.style.display = 'none'
colorvalue180.style.display = 'none'
colorvalue190.style.display = 'none'
colorvalue200.style.display = 'none'
colorvalue200a.style.display = 'none'
colorvalue200b.style.display = 'none'
colorvalue210.style.display = 'none'
colorvalue220.style.display = 'none'
colorvalue230.style.display = 'none'
colorvalue240.style.display = 'none'
colorvalue250.style.display = 'none'
colorvalue260.style.display = 'none'
colorvalue270.style.display = 'none'
colorvalue280.style.display = 'none'
colorvalue290.style.display = 'none'
colorvalue300.style.display = 'none'
colorvalue300a.style.display = 'none'
colorvalue300b.style.display = 'none'
colorvalue310.style.display = 'none'
colorvalue320.style.display = 'none'
colorvalue330.style.display = 'none'
colorvalue340.style.display = 'none'
colorvalue350.style.display = 'none'
colorvalue360.style.display = 'none'
colorvalue370.style.display = 'none'
colorvalue380.style.display = 'none'
colorvalue390.style.display = 'none'
colorvalue400.style.display = 'none'
colorvalue400a.style.display = 'none'
colorvalue400b.style.display = 'none'
colorvalue410.style.display = 'none'
colorvalue420.style.display = 'none'
colorvalue430.style.display = 'none'
colorvalue440.style.display = 'none'
colorvalue450.style.display = 'none'
colorvalue460.style.display = 'none'
colorvalue470.style.display = 'none'
colorvalue480.style.display = 'none'
colorvalue490.style.display = 'none'
colorvalue500.style.display = 'none'
colorvalue500a.style.display = 'none'
colorvalue500b.style.display = 'none'
colorvalue510.style.display = 'none'
colorvalue520.style.display = 'none'
colorvalue530.style.display = 'none'
colorvalue540.style.display = 'none'
colorvalue550.style.display = 'none'
colorvalue560.style.display = 'none'
colorvalue570.style.display = 'none'
colorvalue580.style.display = 'none'
colorvalue590.style.display = 'none'
colorvalue600.style.display = 'none'
colorvalue600a.style.display = 'none'
colorvalue600b.style.display = 'none'
colorvalue610.style.display = 'none'
colorvalue620.style.display = 'none'
colorvalue630.style.display = 'none'
colorvalue640.style.display = 'none'
colorvalue650.style.display = 'none'
colorvalue660.style.display = 'none'
colorvalue670.style.display = 'none'
colorvalue680.style.display = 'none'
colorvalue690.style.display = 'none'
colorvalue700.style.display = 'none'
colorvalue700c.style.display = 'none'
colorvalue700d.style.display = 'none'
colorvalue700e.style.display = 'none'
colorvalue700f.style.display = 'none'
colorvalue700g.style.display = 'none'
colorvalue700h.style.display = 'none'
colorvalue700i.style.display = 'none'
colorvalue700j.style.display = 'none'
colorvalue700a.style.display = 'none'
colorvalue700b.style.display = 'none'
colorvalue710.style.display = 'none'
colorvalue720.style.display = 'none'
colorvalue730.style.display = 'none'
colorvalue740.style.display = 'none'
colorvalue750.style.display = 'none'
colorvalue760.style.display = 'none'
colorvalue770.style.display = 'none'
colorvalue780.style.display = 'none'
colorvalue790.style.display = 'none'
colorvalue800.style.display = 'none'
colorvalue800c.style.display = 'none'
colorvalue800d.style.display = 'none'
colorvalue800e.style.display = 'none'
colorvalue800f.style.display = 'none'
colorvalue800g.style.display = 'none'
colorvalue800h.style.display = 'none'
colorvalue800i.style.display = 'none'
colorvalue800j.style.display = 'none'
colorvalue800a.style.display = 'none'
}

//Mobile Popup
function mobilepopup () {
map.on('click',chosenlayer,mobiletext)
}
function mobiletext(m)
{
precinct = m.features[0].properties[Precinct[firstmatrix][secondmatrix][thirdmatrix]];
PrecinctTotalVotes = Math.round(m.features[0].properties[TotalVotes[firstmatrix][secondmatrix][thirdmatrix]]);
if (Red[firstmatrix][secondmatrix][thirdmatrix] === '') {RedPCT = 0} else {RedPCT = Math.round (m.features[0].properties[Red[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Blue[firstmatrix][secondmatrix][thirdmatrix] === '') {BluePCT = 0} else {BluePCT = Math.round (m.features[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Yellow[firstmatrix][secondmatrix][thirdmatrix] === '') {YellowPCT = 0} else {YellowPCT = Math.round (m.features[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Green[firstmatrix][secondmatrix][thirdmatrix] === '') {GreenPCT = 0} else {GreenPCT = Math.round (m.features[0].properties[Green[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Orange[firstmatrix][secondmatrix][thirdmatrix] === '') {OrangePCT = 0} else {OrangePCT = Math.round (m.features[0].properties[Orange[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Purple[firstmatrix][secondmatrix][thirdmatrix] === '') {PurplePCT = 0} else {PurplePCT = Math.round (m.features[0].properties[Purple[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Teal[firstmatrix][secondmatrix][thirdmatrix] === '') {TealPCT = 0} else {TealPCT = Math.round (m.features[0].properties[Teal[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Violet[firstmatrix][secondmatrix][thirdmatrix] === '') {VioletPCT = 0} else {VioletPCT = Math.round (m.features[0].properties[Violet[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
arr = [[RedPCT,1],[BluePCT,2],[YellowPCT,3],[GreenPCT,4],[OrangePCT,5],[PurplePCT,6],[TealPCT,7],[VioletPCT,8]];
var sorted = []
sorted = arr.sort(function(a, b){ return b[0] - a[0];})
if (relevantColor === 'Ancestry') {if (relevantCL === 'W') {
if (sorted[0][0]>0) {if (sorted[0][1] === 1) {First = '<p><strong><em>' + RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 2) {First = '<p><strong><em>' + BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 3) {First = '<p><strong><em>' + YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>' }
else if (sorted[0][1] === 4) {First = '<p><strong><em>' + GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 5) {First = '<p><strong><em>' + OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 6) {First = '<p><strong><em>' + PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 7) {First = '<p><strong><em>' + TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 8) {First = '<p><strong><em>' + VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[1][0]>0) {if (sorted[1][1] === 1) {Second = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 2) {Second = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 3) {Second = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 4) {Second = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 5) {Second = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 6) {Second = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 7) {Second = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 8) {Second = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[2][0]>0) {if (sorted[2][1] === 1) {Third = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 2) {Third = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 3) {Third = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 4) {Third = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 5) {Third = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 6) {Third = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 7) {Third = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 8) {Third = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Third = ''}
if (sorted[3][0]>0) {if (sorted[3][1] === 1) {Fourth = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 2) {Fourth = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 3) {Fourth = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 4) {Fourth = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 5) {Fourth = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 6) {Fourth = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 7) {Fourth = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 8) {Fourth = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Fourth = ''}
if (sorted[4][0]>0) {if (sorted[4][1] === 1) {Fifth = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 2) {Fifth = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 3) {Fifth = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 4) {Fifth = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 5) {Fifth = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 6) {Fifth = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 7) {Fifth = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 8) {Fifth = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Fifth = ''}
if (sorted[5][0]>0) {if (sorted[5][1] === 1) {Sixth = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 2) {Sixth = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 3) {Sixth = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 4) {Sixth = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 5) {Sixth = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 6) {Sixth = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 7) {Sixth = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 8) {Sixth = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Sixth = ''}
if (sorted[6][0]>0) {if (sorted[6][1] === 1) {Seventh = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 2) {Seventh = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 3) {Seventh = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 4) {Seventh = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 5) {Seventh = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 6) {Seventh = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 7) {Seventh = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 8) {Seventh = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Seventh = ''}
if (sorted[7][0]>0) {if (sorted[7][1] === 1) {Eighth = RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 2) {Eighth = BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 3) {Eighth = YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 4) {Eighth = GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 5) {Eighth = OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 6) {Eighth = PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 7) {Eighth = TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 8) {Eighth = VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p><p><strong><em>'}}
else {Eighth = ''}
Candidate1 = First + Second + Third + Fourth + Fifth + Sixth + Seventh + Eighth + '</em></p>';}
else if (relevantCL === 'R')
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + m.features[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'B')
{Candidate1 = '<p><strong><em>' + BluePCT + '% </strong>' + m.features[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'O')
{Candidate1 = '<p><strong><em>' + OrangePCT + '% </strong>' + m.features[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'Y')
{Candidate1 = '<p><strong><em>' + YellowPCT + '% </strong>' + m.features[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'G')
{Candidate1 = '<p><strong><em>' + GreenPCT + '% </strong>' + m.features[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'P')
{Candidate1 = '<p><strong><em>' + PurplePCT + '% </strong>' + m.features[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'T')
{Candidate1 = '<p><strong><em>' + TealPCT + '% </strong>' + m.features[0].properties[TealCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else if (relevantCL === 'V')
{Candidate1 = '<p><strong><em>' + VioletPCT + '% </strong>' + m.features[0].properties[VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]] + '</em></p>';}
else
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';};
}
else if (relevantColor === 'Margin') {if (RedPCT >0) {Candidate1 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + ' +' + RedPCT}
else {Candidate1 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + ' ' + RedPCT}
}
else if (relevantColor === 'PopPCT') {Candidate1 = '<h3>Pop PCT: ' + RedPCT + '%</h3><h3>Pop Chg: ' + PrecinctTotalVotes + '</h3><p10>Old Pop: ' + m.features[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]] + '</p10><p11>New Pop:' + m.features[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]] + '</p11>'}

else if (relevantColor === 'PopNUM') {Candidate1 = '<h3>Pop PCT: ' + RedPCT + '%</h3><h3>Pop Chg: ' + PrecinctTotalVotes + '</h3><p10>Old Pop: ' + m.features[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]] + '</p10><p11>New Pop:' + m.features[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]] + '</p11>'}

else if (relevantColor === 'Margin7') {if (RedPCT >0) {Candidate1 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + ' +' + RedPCT}
else {Candidate1 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + ' ' + RedPCT}
}
else if (relevantColor === 'JMCWincode') {if(relevantCL === 'W')
{if (noJMCPCTdata === 'Y')
{if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]] === 0) {TealPCT = ''; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT =''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>0) {VioletPCT = ' + ' + Math.round((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; RedPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>1) {BluePCT =' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-1)*1000)/10 + '%'; RedPCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>2) {RedPCT = ' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-2)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>3) {GreenPCT = ' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-3)*1000)/10 +'%'; BluePCT = ''; YellowPCT = ''; RedPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>4) {OrangePCT =' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-4)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; RedPCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>5) {YellowPCT =' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-5)*1000)/10 + '%'; BluePCT = ''; RedPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>6) {PurplePCT =' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-6)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; RedPCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>7) {TealPCT =' + ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-7)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>8) {TealPCT = ''; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT = '' ; VioletPCT = ''}
if (RedPCT !== '') {First = '<p><em>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + RedPCT + '</strong></em></p>'}
else if (BluePCT !== '') {First = '<p><em>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + BluePCT + '</strong></em></p>'}
else if (YellowPCT !== '') {First = '<p><em>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + YellowPCT + '</strong></em></p>'}
else if (GreenPCT !== '') {First = '<p><em>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + GreenPCT + '</strong></em></p>'}
else if (OrangePCT !== '') {First = '<p><em>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + OrangePCT + '</strong></em></p>'}
else if (PurplePCT !== '') {First = '<p><em>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + PurplePCT + '</strong></em></p>'}
else if (TealPCT !=='') {First = '<p><em>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + TealPCT + '</strong></em></p>'}
else if (VioletPCT !== '') {First = '<p><em>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + VioletPCT + '</strong></em></p>'}
else {First = '<p><em>Tie or No Data</em></p>'}
Candidate1 = First}
else {if (sorted[0][0]>0) {if (sorted[0][1] === 1) {First = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 2) {First = '<p><strong><em>' + BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 3) {First = '<p><strong><em>' + YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>' }
else if (sorted[0][1] === 4) {First = '<p><strong><em>' + GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 5) {First = '<p><strong><em>' + OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 6) {First = '<p><strong><em>' + PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 7) {First = '<p><strong><em>' + TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 8) {First = '<p><strong><em>' + VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[1][0]>0) {if (sorted[1][1] === 1) {Second = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 2) {Second = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 3) {Second = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 4) {Second = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 5) {Second = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 6) {Second = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 7) {Second = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 8) {Second = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[2][0]>0) {if (sorted[2][1] === 1) {Third = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 2) {Third = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 3) {Third = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 4) {Third = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 5) {Third = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 6) {Third = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 7) {Third = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 8) {Third = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Third = ''}
if (sorted[3][0]>0) {if (sorted[3][1] === 1) {Fourth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 2) {Fourth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 3) {Fourth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 4) {Fourth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 5) {Fourth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 6) {Fourth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 7) {Fourth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 8) {Fourth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Fourth = ''}
if (sorted[4][0]>0) {if (sorted[4][1] === 1) {Fifth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 2) {Fifth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 3) {Fifth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 4) {Fifth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 5) {Fifth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 6) {Fifth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 7) {Fifth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 8) {Fifth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Fifth = ''}
if (sorted[5][0]>0) {if (sorted[5][1] === 1) {Sixth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 2) {Sixth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 3) {Sixth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 4) {Sixth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 5) {Sixth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 6) {Sixth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 7) {Sixth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 8) {Sixth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Sixth = ''}
if (sorted[6][0]>0) {if (sorted[6][1] === 1) {Seventh = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 2) {Seventh = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 3) {Seventh = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 4) {Seventh = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 5) {Seventh = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 6) {Seventh = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 7) {Seventh = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 8) {Seventh = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Seventh = ''}
if (sorted[7][0]>0) {if (sorted[7][1] === 1) {Eighth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 2) {Eighth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 3) {Eighth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 4) {Eighth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 5) {Eighth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 6) {Eighth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 7) {Eighth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 8) {Eighth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Eighth = ''}
Candidate1 = First + Second + Third + Fourth + Fifth + Sixth + Seventh + Eighth + '</em></p>';}
}
else if (relevantCL === 'R')
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'B')
{Candidate1 = '<p><strong><em>' + BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'O')
{Candidate1 = '<p><strong><em>' + OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'Y')
{Candidate1 = '<p><strong><em>' + YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'G')
{Candidate1 = '<p><strong><em>' + GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'P')
{Candidate1 = '<p><strong><em>' + PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'T')
{Candidate1 = '<p><strong><em>' + TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'V')
{Candidate1 = '<p><strong><em>' + VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';};}
else {if (relevantCL === 'W') {
if (noWincodePCTdata === 'Y')
{if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]] === 0) {TealPCT = ''; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT =''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>0) {RedPCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]))*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>1) {GreenPCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-1)*10000)/100 +'%'; BluePCT = ''; YellowPCT = ''; RedPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>2) {BluePCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-2)*10000)/100 + '%'; RedPCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>3) {OrangePCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-3)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; RedPCT = ''; PurplePCT = ''; TealPCT =''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>4) {YellowPCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-4)*10000)/100 + '%'; BluePCT = ''; RedPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT =''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>5) {PurplePCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-5)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; RedPCT = ''; TealPCT =''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>6) {VioletPCT = ' ' + Math.round((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]-6)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; RedPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>7) {TealPCT = ' ' + Math.round(((m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-7)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT = ''; VioletPCT = ''}
if (m.features[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>8) {TealPCT = ''; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT = '' ; VioletPCT = ''}
if (RedPCT !== '') {First = '<p><em>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + RedPCT + '</strong></em></p>'}
else if (BluePCT !== '') {First = '<p><em>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + BluePCT + '</strong></em></p>'}
else if (YellowPCT !== '') {First = '<p><em>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + YellowPCT + '</strong></em></p>'}
else if (GreenPCT !== '') {First = '<p><em>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + GreenPCT + '</strong></em></p>'}
else if (OrangePCT !== '') {First = '<p><em>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + OrangePCT + '</strong></em></p>'}
else if (PurplePCT !== '') {First = '<p><em>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + PurplePCT + '</strong></em></p>'}
else if (TealPCT !=='') {First = '<p><em>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + TealPCT + '</strong></em></p>'}
else if (VioletPCT !== '') {First = '<p><em>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '<strong>' + VioletPCT + '</strong></em></p>'}
else {First = '<p><em>Tie or No Data</em></p>'}
Candidate1 = First}
else {if (sorted[0][0]>0) {if (sorted[0][1] === 1) {First = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 2) {First = '<p><strong><em>' + BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 3) {First = '<p><strong><em>' + YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>' }
else if (sorted[0][1] === 4) {First = '<p><strong><em>' + GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 5) {First = '<p><strong><em>' + OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 6) {First = '<p><strong><em>' + PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 7) {First = '<p><strong><em>' + TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[0][1] === 8) {First = '<p><strong><em>' + VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[1][0]>0) {if (sorted[1][1] === 1) {Second = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 2) {Second = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 3) {Second = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 4) {Second = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 5) {Second = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 6) {Second = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 7) {Second = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[1][1] === 8) {Second = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Second = ''}
if (sorted[2][0]>0) {if (sorted[2][1] === 1) {Third = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 2) {Third = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 3) {Third = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 4) {Third = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 5) {Third = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 6) {Third = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 7) {Third = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[2][1] === 8) {Third = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Third = ''}
if (sorted[3][0]>0) {if (sorted[3][1] === 1) {Fourth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 2) {Fourth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 3) {Fourth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 4) {Fourth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 5) {Fourth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 6) {Fourth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 7) {Fourth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[3][1] === 8) {Fourth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Fourth = ''}
if (sorted[4][0]>0) {if (sorted[4][1] === 1) {Fifth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 2) {Fifth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 3) {Fifth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 4) {Fifth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 5) {Fifth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 6) {Fifth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 7) {Fifth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[4][1] === 8) {Fifth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Fifth = ''}
if (sorted[5][0]>0) {if (sorted[5][1] === 1) {Sixth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 2) {Sixth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 3) {Sixth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 4) {Sixth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 5) {Sixth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 6) {Sixth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 7) {Sixth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[5][1] === 8) {Sixth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Sixth = ''}
if (sorted[6][0]>0) {if (sorted[6][1] === 1) {Seventh = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 2) {Seventh = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 3) {Seventh = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 4) {Seventh = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 5) {Seventh = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 6) {Seventh = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 7) {Seventh = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[6][1] === 8) {Seventh = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Seventh = ''}
if (sorted[7][0]>0) {if (sorted[7][1] === 1) {Eighth = RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 2) {Eighth = BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 3) {Eighth = YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 4) {Eighth = GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 5) {Eighth = OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 6) {Eighth = PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 7) {Eighth = TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}
else if (sorted[7][1] === 8) {Eighth = VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p><p><strong><em>'}}
else {Eighth = ''}
Candidate1 = First + Second + Third + Fourth + Fifth + Sixth + Seventh + Eighth + '</em></p>';}
}
else if (relevantCL === 'R')
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'B')
{Candidate1 = '<p><strong><em>' + BluePCT + '% </strong>' + BlueCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'O')
{Candidate1 = '<p><strong><em>' + OrangePCT + '% </strong>' + OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'Y')
{Candidate1 = '<p><strong><em>' + YellowPCT + '% </strong>' + YellowCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'G')
{Candidate1 = '<p><strong><em>' + GreenPCT + '% </strong>' + GreenCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'P')
{Candidate1 = '<p><strong><em>' + PurplePCT + '% </strong>' + PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'T')
{Candidate1 = '<p><strong><em>' + TealPCT + '% </strong>' + TealCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else if (relevantCL === 'V')
{Candidate1 = '<p><strong><em>' + VioletPCT + '% </strong>' + VioletCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';}
else
{Candidate1 = '<p><strong><em>' + RedPCT + '% </strong>' + RedCandidate[firstmatrix][secondmatrix][thirdmatrix] + '</em></p>';};
}
if (relevantColor === 'Ancestry') {PopVotes = '<p>Population: '} else if (relevantColor === 'PopPCT') {PopVotes = ''} else if (relevantColor === 'PopNUM') {PopVotes = ''} else {PopVotes = '<p>Votes: '}
if (PrecinctTotalVotes>-1) {AfterCandidate1 = PopVotes + PrecinctTotalVotes + '</p>'} else {AfterCandidate1 = ''}
if (relevantColor === 'PopPCT') {AfterCandidate1 = ''}
if (relevantColor === 'PopNUM') {AfterCandidate1 = ''}
if (relevantColor === 'Ancestry') {if(mq.matches) {new mapboxgl.Popup()
.setLngLat(m.lngLat)
.setHTML(Candidate1 + AfterCandidate1)
.addTo(map)
m.preventDefault ()} else
{new mapboxgl.Popup()
.setLngLat(m.lngLat)
.setHTML('<h3>' + precinct + '</h3>' + Candidate1 + AfterCandidate1)
.addTo(map)
m.preventDefault ()}}
else {new mapboxgl.Popup()
.setLngLat(m.lngLat)
.setHTML('<h3>' + precinct + '</h3>' + Candidate1 + AfterCandidate1)
.addTo(map)
m.preventDefault ()}
}
//Desktop Label Candiates Sorted by Statewide PCT
function desktopLabel () {map.on('mousemove', function(e) {
var states = map.queryRenderedFeatures(e.point, {
layer: [chosenlayer]
});
if (RedStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTRedStatewide = 0} else {PCTRedStatewide = RedStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (BlueStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTBlueStatewide = 0} else {PCTBlueStatewide = BlueStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (YellowStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTYellowStatewide = 0} else {PCTYellowStatewide = YellowStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (GreenStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTGreenStatewide = 0} else {PCTGreenStatewide = GreenStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (OrangeStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTOrangeStatewide = 0} else {PCTOrangeStatewide = OrangeStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (PurpleStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTPurpleStatewide = 0} else {PCTPurpleStatewide = PurpleStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (TealStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTTealStatewide = 0} else {PCTTealStatewide = TealStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
if (VioletStatewidePCT[firstmatrix][secondmatrix][thirdmatrix] === '') {PCTVioletStatewide = 0} else {PCTVioletStatewide = VioletStatewidePCT[firstmatrix][secondmatrix][thirdmatrix]};
StatewideTotalVotes = StatewideVotes[firstmatrix][secondmatrix][thirdmatrix];
if (states.length > 0)
{precinct = states[0].properties[Precinct[firstmatrix][secondmatrix][thirdmatrix]];
PrecinctTotalVotes = Math.round(states[0].properties[TotalVotes[firstmatrix][secondmatrix][thirdmatrix]]);
if (Tog1[firstmatrix][secondmatrix][thirdmatrix] === '') {MouseoverTog1 = ''} else {MouseoverTog1 = states[0].properties[Tog1[firstmatrix][secondmatrix][thirdmatrix]]};
if (Tog1[firstmatrix][secondmatrix][thirdmatrix] === '') {BeforeTog1 = ''; AfterTog1 = ''}
else {BeforeTog1 = '</h3><h3>'; AfterTog1 = states[0].properties[Tog1[firstmatrix][secondmatrix][thirdmatrix]] + ' ' + Tog1Name + '</h3>'}
if (Red[firstmatrix][secondmatrix][thirdmatrix] === '') {RedPCT = 0} else {RedPCT = Math.round(states[0].properties[Red[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Blue[firstmatrix][secondmatrix][thirdmatrix] === '') {BluePCT = 0} else {BluePCT = Math.round(states[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Yellow[firstmatrix][secondmatrix][thirdmatrix] === '') {YellowPCT = 0} else {YellowPCT = Math.round(states[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Green[firstmatrix][secondmatrix][thirdmatrix] === '') {GreenPCT = 0} else {GreenPCT = Math.round(states[0].properties[Green[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Orange[firstmatrix][secondmatrix][thirdmatrix] === '') {OrangePCT = 0} else {OrangePCT = Math.round(states[0].properties[Orange[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Purple[firstmatrix][secondmatrix][thirdmatrix] === '') {PurplePCT = 0} else {PurplePCT = Math.round(states[0].properties[Purple[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Teal[firstmatrix][secondmatrix][thirdmatrix] === '') {TealPCT = 0} else {TealPCT = Math.round(states[0].properties[Teal[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};
if (Violet[firstmatrix][secondmatrix][thirdmatrix] === '') {VioletPCT = 0} else {VioletPCT = Math.round(states[0].properties[Violet[firstmatrix][secondmatrix][thirdmatrix]]*10000)/100};

// Must Edit firstcolor, chosenvariable, if don't use Wincode.
if (relevantColor === 'Ancestry') {
if (relevantCL === 'W')
// Must Edit firstcolor, chosenvariable, if don't use Wincode.
{ firstcolor = reds
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
aPCT = ''; bPCT = ''; cPCT = ' <strong>' + RedPCT + '%</strong>'; dPCT = ' <strong>' + BluePCT + '%</strong>'; ePCT = ' <strong>' + YellowPCT + '%</strong>', fPCT = ' <strong>' + GreenPCT + '%</strong>'; gPCT = ' <strong>' + OrangePCT + '%</strong>'; cStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; dStatewide = ' <strong>' + PCTBlueStatewide + '%</strong>'; eStatewide = ' <strong>' + PCTYellowStatewide + '%</strong>'; fStatewide = ' <strong>' + PCTGreenStatewide + '%</strong>'; gStatewide = ' <strong>' + PCTOrangeStatewide + '%</strong>'; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = states[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosencandidateD = states[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosencandidateE = states[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosencandidateF = states[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosencandidateG = states[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]]; colora = whites; colorb = whites; colorc = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][2]]]; colord = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][3]]]; colore = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][4]]]; colorf =LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][5]]]; colorg = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][6]]]; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][7]]]; firstcolor = reds; hPCT = ' <strong>' + PurplePCT + '%</strong>'; hStatewide = ' <strong>' + PCTPurpleStatewide + '%</strong>'; chosencandidateH = states[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 3}

else if (relevantCL === 'R') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandiddateB =''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = states[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'B') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandiddateB =''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = blues; hPCT = ' <strong>' + BluePCT + '%</strong>'; hStatewide = ' <strong>' + PCTBlueStatewide + '%</strong>'; chosencandidateH = states[0].properties[BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'Y') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandiddateB =''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = yellows; hPCT = ' <strong>' + YellowPCT + '%</strong>'; hStatewide = ' <strong>' + PCTYellowStatewide + '%</strong>'; chosencandidateH = states[0].properties[YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'G') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandiddateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = greens; hPCT = ' <strong>' + GreenPCT + '%</strong>'; hStatewide = ' <strong>' + PCTGreenStatewide + '%</strong>'; chosencandidateH = states[0].properties[GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'O') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = oranges; hPCT = ' <strong>' + OrangePCT + '%</strong>'; hStatewide = ' <strong>' + PCTOrangeStatewide + '%</strong>'; chosencandidateH = states[0].properties[OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'P') {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; firstcolor = purples; hPCT = ' <strong>' + PurplePCT + '%</strong>'; hStatewide = ' <strong>' + PCTPurpleStatewide + '%</strong>'; chosencandidateH = states[0].properties[PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else {aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandiddateB =''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = LegendColor[states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]]; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = states[0].properties[RedCandidate[firstmatrix][secondmatrix][thirdmatrix]]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
}
else if (relevantColor === 'Margin') {
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = '', fPCT = ''; gPCT = ''; hPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; colora = whites; colorb = whites; colorc = ''; colord = ''; colore = ''; colorf = ''; colorg = margincolor1; colorh = margincolor2; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]
}
else if (relevantColor === 'PopPCT') {
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = '', fPCT = Red; gPCT = ''; hPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; colora = whites; colorb = whites; colorc = ''; colord = ''; colore = ''; colorf = ''; colorg = PopPCTcolor1; colorh = PopPCTcolor2; firstcolor = reds; hPCT = ''; hStatewide = ''; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]
}
else if (relevantColor === 'PopNUM') {
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = '', fPCT = Red; gPCT = ''; hPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; colora = whites; colorb = whites; colorc = ''; colord = ''; colore = ''; colorf = ''; colorg = PopNUMcolor1; colorh = PopNUMcolor2; firstcolor = reds; hPCT = ''; hStatewide = ''; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]
}
else if (relevantColor === 'Margin7') {
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
aPCT = ''; bPCT = ''; cPCT = ''; dPCT = ''; ePCT = '', fPCT = ''; gPCT = ''; hPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; colora = whites; colorb = whites; colorc = ''; colord = ''; colore = ''; colorf = ''; colorg = margincolor71; colorh = margincolor72; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]
}
else if (relevantColor === 'JMCWincode') {if (relevantCL === 'W')
{JMCfirstcolor = violets
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
if (noJMCPCTdata === 'Y') {if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>0) {VioletPCT = '+ ' + Math.round((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; RedPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>1) {BluePCT ='+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-1)*1000)/10 + '%'; RedPCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>2) {RedPCT = '+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-2)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>3) {GreenPCT = '+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-3)*1000)/10 +'%'; BluePCT = ''; YellowPCT = ''; RedPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>4) {OrangePCT ='+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-4)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; RedPCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>5) {YellowPCT ='+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-5)*1000)/10 + '%'; BluePCT = ''; RedPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>6) {PurplePCT ='+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-6)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; RedPCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>7) {TealPCT ='+ ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-7)*1000)/10 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT = ''; VioletPCT = ''}
}
WincodeFormula ()}
else if (relevantCL === 'R') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = reds; JMCfirstcolor = reds; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'B') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = blues; JMCfirstcolor = blues; hPCT = ' <strong>' + BluePCT + '%</strong>'; hStatewide = ' <strong>' + PCTBlueStatewide + '%</strong>'; chosencandidateH = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'Y') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = yellows; JMCfirstcolor = yellows; hPCT = ' <strong>' + YellowPCT + '%</strong>'; hStatewide = ' <strong>' + PCTYellowStatewide + '%</strong>'; chosencandidateH = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'G') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = greens; JMCfirstcolor = greens; hPCT = ' <strong>' + GreenPCT + '%</strong>'; hStatewide = ' <strong>' + PCTGreenStatewide + '%</strong>'; chosencandidateH = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'O') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = oranges; JMCfirstcolor = oranges; hPCT = ' <strong>' + OrangePCT + '%</strong>'; hStatewide = ' <strong>' + PCTOrangeStatewide + '%</strong>'; chosencandidateH = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'P') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = purples; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; JMCfirstcolor = purples; hPCT = ' <strong>' + PurplePCT + '%</strong>'; hStatewide = ' <strong>' + PCTPurpleStatewide + '%</strong>'; chosencandidateH = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'T') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = teals; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; JMCfirstcolor = teals; hPCT = ' <strong>' + TealPCT + '%</strong>'; hStatewide = ' <strong>' + PCTTealStatewide + '%</strong>'; chosencandidateH = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Teal[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'V') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = violets; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; JMCfirstcolor = violets; hPCT = ' <strong>' + VioletPCT + '%</strong>'; hStatewide = ' <strong>' + PCTVioletStatewide + '%</strong>'; chosencandidateH = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Violet[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = reds; JMCfirstcolor = violets; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
}
else {if (relevantColor ==='Wincode') {
if (relevantCL === 'W')
{firstcolor = reds
chosenvariable = Wincode[firstmatrix][secondmatrix][thirdmatrix]
if (noWincodePCTdata === 'Y') {if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>0) {RedPCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]))*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>1) {GreenPCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-1)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; RedPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT =''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>2) {BluePCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-2)*10000)/100 + '%'; RedPCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>3) {OrangePCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-3)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; RedPCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>4) {YellowPCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-4)*10000)/100 + '%'; BluePCT = ''; RedPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>5) {PurplePCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-5)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; RedPCT = ''; TealPCT = ''; VioletPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>6) {VioletPCT = Math.round((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]-6)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; TealPCT = ''; RedPCT = ''}
if (states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]>7) {TealPCT = Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]])-7)*10000)/100 + '%'; BluePCT = ''; YellowPCT = ''; GreenPCT = ''; OrangePCT = ''; PurplePCT = ''; RedPCT =''; VioletPCT = ''}
}
WincodeFormula ()
}
else if (relevantCL === 'R') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = reds; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'B') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = blues; firstcolor = blues; hPCT = ' <strong>' + BluePCT + '%</strong>'; hStatewide = ' <strong>' + PCTBlueStatewide + '%</strong>'; chosencandidateH = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Blue[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'Y') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = yellows; firstcolor = yellows; hPCT = ' <strong>' + YellowPCT + '%</strong>'; hStatewide = ' <strong>' + PCTYellowStatewide + '%</strong>'; chosencandidateH = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Yellow[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'G') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = greens; firstcolor = greens; hPCT = ' <strong>' + GreenPCT + '%</strong>'; hStatewide = ' <strong>' + PCTGreenStatewide + '%</strong>'; chosencandidateH = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Green[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'O') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = oranges; firstcolor = oranges; hPCT = ' <strong>' + OrangePCT + '%</strong>'; hStatewide = ' <strong>' + PCTOrangeStatewide + '%</strong>'; chosencandidateH = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Orange[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'P') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = purples; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; firstcolor = purples; hPCT = ' <strong>' + PurplePCT + '%</strong>'; hStatewide = ' <strong>' + PCTPurpleStatewide + '%</strong>'; chosencandidateH = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Purple[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'T') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = teals; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; firstcolor = teals; hPCT = ' <strong>' + TealPCT + '%</strong>'; hStatewide = ' <strong>' + PCTTealStatewide + '%</strong>'; chosencandidateH = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Teal[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else if (relevantCL === 'V') {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = violets; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; firstcolor = violets; hPCT = ' <strong>' + VioletPCT + '%</strong>'; hStatewide = ' <strong>' + PCTVioletStatewide + '%</strong>'; chosencandidateH = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Violet[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
else {aPCT = ''; bPCT = ''; cPCT = '', dPCT = ''; ePCT = ''; fPCT = ''; gPCT = ''; aStatewide = ''; bStatewide = ''; cStatewide = ''; dStatewide = ''; eStatewide = ''; fStatewide = ''; gStatewide = ''; chosencandidateA = ''; chosencandidateB = ''; chosencandidateC = ''; chosencandidateD = ''; chosencandidateE = ''; chosencandidateF = ''; chosencandidateG = ''; colora = whites; colorb = whites; colorc = whites; colord = whites; colore = whites; colorf = whites; colorg = whites; colorh = reds; firstcolor = reds; hPCT = ' <strong>' + RedPCT + '%</strong>'; hStatewide = ' <strong>' + PCTRedStatewide + '%</strong>'; chosencandidateH = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; chosenvariable = Red[firstmatrix][secondmatrix][thirdmatrix]; firsthtml = 8}
}
else WincodeFormula ()
}
if (relevantColor === 'Ancestry') {PopVotes = '</h3><h3>Total Population: '} else if (relevantColor === 'PopPCT') {PopVotes = '</h3><h3>Population Change: '} else if (relevantColor === 'PopNUM') {PopVotes = '</h3><h3>Population Change: '} else {PopVotes = '</h3><h3>Total Votes: '}
if (relevantColor === 'PopPCT') {AfterCandidate1 = '</h3><h3>Percentage Change: ' + Math.round(((states[0].properties[Wincode[firstmatrix][secondmatrix][thirdmatrix]]))*10000)/100 + '%' + PopVotes + PrecinctTotalVotes + '</h3>' + '<p10>Old Population: ' + states[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]] + '</p10><p11>New Population: ' + states[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]] + '</p11>'}
else if (relevantColor === 'PopNUM') {AfterCandidate1 = '</h3><h3>Percentage Change: ' + Math.round(((states[0].properties[Red[firstmatrix][secondmatrix][thirdmatrix]]))*10000)/100 + '%' + PopVotes + PrecinctTotalVotes + '</h3>' + '<p10>Old Population: ' + states[0].properties[Blue[firstmatrix][secondmatrix][thirdmatrix]] + '</p10><p11>New Population: ' + states[0].properties[Yellow[firstmatrix][secondmatrix][thirdmatrix]] + '</p11>'}
else if (PrecinctTotalVotes > -1) {AfterCandidate1 = PopVotes + PrecinctTotalVotes + '</h3>'} else {AfterCandidate1 = ''}
if (matrixflag === 'Y') {Matrix = '<h3>Matrix['+firstmatrix+']['+secondmatrix+']['+thirdmatrix+']</h3><p>Color Scale:' + colorscale} else Matrix = ''

if (relevantColor ==='Ancestry') {legendtitle.innerHTML = '<h2>'+ Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
else if (relevantColor === 'Margin') {legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
else if (relevantColor === 'Margin7') {legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
else if (relevantColor === 'PopPCT') {legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
else if (relevantColor === 'PopNUM') {legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
else {legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + precinct + BeforeTog1 + AfterTog1 + Matrix + AfterCandidate1}
apct.innerHTML = aPCT
bpct.innerHTML = bPCT
cpct.innerHTML = cPCT
dpct.innerHTML = dPCT
epct.innerHTML = ePCT
fpct.innerHTML = fPCT
gpct.innerHTML = gPCT
hpct.innerHTML = hPCT
} else {
legendtitle.innerHTML = '<h2>' + Title[firstmatrix][secondmatrix][thirdmatrix] + '</h2><h3>' + 'Statewide Overall Result' + '</h3><h3>Statewide Votes: ' + StatewideTotalVotes + '</h3>'
apct.innerHTML = aStatewide
bpct.innerHTML = bStatewide
cpct.innerHTML = cStatewide
dpct.innerHTML = dStatewide
epct.innerHTML = eStatewide
fpct.innerHTML = fStatewide
gpct.innerHTML = gStatewide
hpct.innerHTML = hStatewide}
label()
})
}

function WincodeFormula ()
{arr = [[PCTRedStatewide,RedPCT,1],[PCTBlueStatewide,BluePCT,2],[PCTYellowStatewide,YellowPCT,3],[PCTGreenStatewide,GreenPCT,4],[PCTOrangeStatewide,OrangePCT,5],[PCTPurpleStatewide,PurplePCT,6],[PCTTealStatewide,TealPCT,7],[PCTVioletStatewide,VioletPCT,8]];
var sorted = []
sorted = arr.sort(function(a, b){ return b[0] - a[0];})
if (sorted[0][0]>0)
{if (sorted[0][2] === 1) {FirstPCT = sorted[0][1]; chosencandidate1 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTRedStatewide; color1 = reds}
else if (sorted[0][2] === 2) {FirstPCT = sorted[0][1]; chosencandidate1 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTBlueStatewide; color1= blues}
else if (sorted[0][2] === 3) {FirstPCT = sorted[0][1]; chosencandidate1 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTYellowStatewide; color1 = yellows}
else if (sorted[0][2] === 4) {FirstPCT = sorted[0][1]; chosencandidate1 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTGreenStatewide; color1 = greens}
else if (sorted[0][2] === 5) {FirstPCT = sorted[0][1]; chosencandidate1 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTOrangeStatewide; color1 = oranges}
else if (sorted[0][2] === 6) {FirstPCT = sorted[0][1]; chosencandidate1 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTPurpleStatewide; color1 = purples}
else if (sorted[0][2] === 7) {FirstPCT = sorted[0][1]; chosencandidate1 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTTealStatewide; color1 = teals}
else if (sorted[0][2] === 8) {FirstPCT = sorted[0][1]; chosencandidate1 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; FirstStatewide = PCTVioletStatewide; color1 = violets}}
else {FirstPCT = ''; FirstStatewide = ''; color1 = whites}
if (sorted[1][0]>0)
{if (sorted[1][2] === 1) {SecondPCT = sorted[1][1]; chosencandidate2 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTRedStatewide; color2 = reds}
else if (sorted[1][2] === 2) {SecondPCT = sorted[1][1]; chosencandidate2 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTBlueStatewide; color2 = blues}
else if (sorted[1][2] === 3) {SecondPCT = sorted[1][1]; chosencandidate2 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTYellowStatewide; color2 = yellows}
else if (sorted[1][2] === 4) {SecondPCT = sorted[1][1]; chosencandidate2 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTGreenStatewide; color2 = greens}
else if (sorted[1][2] === 5) {SecondPCT = sorted[1][1]; chosencandidate2 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTOrangeStatewide; color2 = oranges}
else if (sorted[1][2] === 6) {SecondPCT = sorted[1][1]; chosencandidate2 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTPurpleStatewide; color2 = purples}
else if (sorted[1][2] === 7) {SecondPCT = sorted[1][1]; chosencandidate2 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTTealStatewide; color2 = teals}
else if (sorted[1][2] === 8) {SecondPCT = sorted[1][1]; chosencandidate2 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; SecondStatewide = PCTVioletStatewide; color2 = violets}}
else {SecondPCT = ''; SecondStatewide = ''; color2 = whites}
if (sorted[2][0]>0)
{if (sorted[2][2] === 1) {ThirdPCT = sorted[2][1]; chosencandidate3 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTRedStatewide; color3 = reds}
else if (sorted[2][2] === 2) {ThirdPCT = sorted[2][1]; chosencandidate3 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTBlueStatewide; color3 = blues}
else if (sorted[2][2] === 3) {ThirdPCT = sorted[2][1]; chosencandidate3 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTYellowStatewide; color3 = yellows}
else if (sorted[2][2] === 4) {ThirdPCT = sorted[2][1]; chosencandidate3 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTGreenStatewide; color3 = greens}
else if (sorted[2][2] === 5) {ThirdPCT = sorted[2][1]; chosencandidate3 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTOrangeStatewide; color3 = oranges}
else if (sorted[2][2] === 6) {ThirdPCT = sorted[2][1]; chosencandidate3 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTPurpleStatewide; color3 = purples}
else if (sorted[2][2] === 7) {ThirdPCT = sorted[2][1]; chosencandidate3 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTTealStatewide; color3 = teals}
else if (sorted[2][2] === 8) {ThirdPCT = sorted[2][1]; chosencandidate3 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; ThirdStatewide = PCTVioletStatewide; color3 = violets}}
else {ThirdPCT = ''; ThirdStatewide = ''; color3 = whites}
if (sorted[3][0]>0)
{if (sorted[3][2] === 1) {FourthPCT = sorted[3][1]; chosencandidate4 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTRedStatewide; color4 = reds}
else if (sorted[3][2] === 2) {FourthPCT = sorted[3][1]; chosencandidate4 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTBlueStatewide; color4 = blues}
else if (sorted[3][2] === 3) {FourthPCT = sorted[3][1]; chosencandidate4 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTYellowStatewide; color4 = yellows}
else if (sorted[3][2] === 4) {FourthPCT = sorted[3][1]; chosencandidate4 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTGreenStatewide; color4 = greens}
else if (sorted[3][2] === 5) {FourthPCT = sorted[3][1]; chosencandidate4 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTOrangeStatewide; color4 = oranges}
else if (sorted[3][2] === 6) {FourthPCT = sorted[3][1]; chosencandidate4 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTPurpleStatewide; color4 = purples}
else if (sorted[3][2] === 7) {FourthPCT = sorted[3][1]; chosencandidate4 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTTealStatewide; color4 = teals}
else if (sorted[3][2] === 8) {FourthPCT = sorted[3][1]; chosencandidate4 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; FourthStatewide = PCTVioletStatewide; color4 = violets}}
else {FourthPCT = ''; FourthStatewide = ''; color4 = whites}
if (sorted[4][0]>0)
{if (sorted[4][2] === 1) {FifthPCT = sorted[4][1]; chosencandidate5 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTRedStatewide; color5 = reds}
else if (sorted[4][2] === 2) {FifthPCT = sorted[4][1]; chosencandidate5 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTBlueStatewide; color5 = blues}
else if (sorted[4][2] === 3) {FifthPCT = sorted[4][1]; chosencandidate5 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTYellowStatewide; color5 = yellows}
else if (sorted[4][2] === 4) {FifthPCT = sorted[4][1]; chosencandidate5 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTGreenStatewide; color5 = greens}
else if (sorted[4][2] === 5) {FifthPCT = sorted[4][1]; chosencandidate5 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTOrangeStatewide; color5 = oranges}
else if (sorted[4][2] === 6) {FifthPCT = sorted[4][1]; chosencandidate5 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTPurpleStatewide; color5 = purples}
else if (sorted[4][2] === 7) {FifthPCT = sorted[4][1]; chosencandidate5 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTTealStatewide; color5 = teals}
else if (sorted[4][2] === 8) {FifthPCT = sorted[4][1]; chosencandidate5 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; FifthStatewide = PCTVioletStatewide; color5 = violets}}
else {FifthPCT = ''; FifthStatewide = ''; color5 = whites}
if (sorted[5][0]>0)
{if (sorted[5][2] === 1) {SixthPCT = sorted[5][1]; chosencandidate6 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTRedStatewide; color6 = reds}
else if (sorted[5][2] === 2) {SixthPCT = sorted[5][1]; chosencandidate6 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTBlueStatewide; color6 = blues}
else if (sorted[5][2] === 3) {SixthPCT = sorted[5][1]; chosencandidate6 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTYellowStatewide; color6 = yellows}
else if (sorted[5][2] === 4) {SixthPCT = sorted[5][1]; chosencandidate6 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTGreenStatewide; color6 = greens}
else if (sorted[5][2] === 5) {SixthPCT = sorted[5][1]; chosencandidate6 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTOrangeStatewide; color6 = oranges}
else if (sorted[5][2] === 6) {SixthPCT = sorted[5][1]; chosencandidate6 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTPurpleStatewide; color6 = purples}
else if (sorted[5][2] === 7) {SixthPCT = sorted[5][1]; chosencandidate6 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTTealStatewide; color6 = teals}
else if (sorted[5][2] === 8) {SixthPCT = sorted[5][1]; chosencandidate6 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; SixthStatewide = PCTVioletStatewide; color6 = violets}}
else {SixthPCT = ''; SixthStatewide = ''; color6 = whites}
if (sorted[6][0]>0)
{if (sorted[6][2] === 1) {SeventhPCT = sorted[6][1]; chosencandidate7 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTRedStatewide; color7 = reds}
else if (sorted[6][2] === 2) {SeventhPCT = sorted[6][1]; chosencandidate7 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTBlueStatewide; color7 = blues}
else if (sorted[6][2] === 3) {SeventhPCT = sorted[6][1]; chosencandidate7 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTYellowStatewide; color7 = yellows}
else if (sorted[6][2] === 4) {SeventhPCT = sorted[6][1]; chosencandidate7 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTGreenStatewide; color7 = greens}
else if (sorted[6][2] === 5) {SeventhPCT = sorted[6][1]; chosencandidate7 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTOrangeStatewide; color7 = oranges}
else if (sorted[6][2] === 6) {SeventhPCT = sorted[6][1]; chosencandidate7 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTPurpleStatewide; color7 = purples}
else if (sorted[6][2] === 7) {SeventhPCT = sorted[6][1]; chosencandidate7 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTTealStatewide; color7 = teals}
else if (sorted[6][2] === 8) {SeventhPCT = sorted[6][1]; chosencandidate7 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; SeventhStatewide = PCTVioletStatewide; color7 = violets}}
else {SeventhPCT = ''; SeventhStatewide = ''; color7 = whites}
if (sorted[7][0]>0)
{if (sorted[7][2] === 1) {EighthPCT = sorted[7][1]; chosencandidate8 = RedCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTRedStatewide; color8 = reds}
else if (sorted[7][2] === 2) {EighthPCT = sorted[7][1]; chosencandidate8 = BlueCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTBlueStatewide; color8 = blues}
else if (sorted[7][2] === 3) {EighthPCT = sorted[7][1]; chosencandidate8 = YellowCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTYellowStatewide; color8 = yellows}
else if (sorted[7][2] === 4) {EighthPCT = sorted[7][1]; chosencandidate8 = GreenCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTGreenStatewide; color8 = greens}
else if (sorted[7][2] === 5) {EighthPCT = sorted[7][1]; chosencandidate8 = OrangeCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTOrangeStatewide; color8 = oranges}
else if (sorted[7][2] === 6) {EighthPCT = sorted[7][1]; chosencandidate8 = PurpleCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTPurpleStatewide; color8 = purples}
else if (sorted[7][2] === 7) {EighthPCT = sorted[7][1]; chosencandidate8 = TealCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTTealStatewide; color8 = teals}
else if (sorted[7][2] === 8) {EighthPCT = sorted[7][1]; chosencandidate8 = VioletCandidate[firstmatrix][secondmatrix][thirdmatrix]; EighthStatewide = PCTVioletStatewide; color8 = violets}}
else {EighthPCT = ''; EighthStatewide = ''; color8 = whites}

if (relevantColor ==='JMCWincode'){if (noJMCPCTdata === 'Y') {nopercents ()} else percents ()}
else if (relevantColor ==='Wincode'){if (noWincodePCTdata === 'Y') {nopercents ()} else percents ()}
else percents ()
}
function nopercents () {
if (EighthStatewide === '') {aPCT = ''; aStatewide = ''; colora = whites; chosencandidateA = ''; firsthtml = ''}
else {aPCT = ' <strong>' + FirstPCT + ''; aStatewide = ' <strong>+ ' + FirstStatewide + '</strong>'; colora = color1; chosencandidateA = chosencandidate1; firsthtml = 1};
if (SeventhStatewide === '') {bPCT = ''; bStatewide = ''; colorb = whites; chosencandidateB = ''; firsthtml = ''}
else if (firsthtml === 1) {bPCT = ' <strong>' + SecondPCT + '</strong>'; bStatewide = ' <strong>' + SecondStatewide + '</strong>'; colorb = color2; chosencandidateB = chosencandidate2}
else {bPCT = ' <strong>' + FirstPCT + '</strong>'; bStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 2; colorb = color1; chosencandidateB = chosencandidate1};
if (SixthStatewide === '') {cPCT = ''; cStatewide = ''; colorc = whites; colorc = color4; chosencandidateC = ''; firsthtml = ''}
else if (firsthtml === 1) {cPCT = ' <strong>' + ThirdPCT + '</strong>'; cStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colorc = color3; chosencandidateC = chosencandidate3}
else if (firsthtml === 2) {cPCT = ' <strong>' + SecondPCT + '</strong>'; cStatewide = ' <strong>' + SecondStatewide + '</strong>'; colorc = color2; chosencandidateC = chosencandidate2}
else {cPCT = ' <strong>' + FirstPCT + '</strong>'; cStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 3; colorc = color1; chosencandidateC = chosencandidate1}
if (FifthStatewide === '') {dPCT = ''; dStatewide = ''; colord = whites; chosencandidateD = ''; firsthtml = ''}
else if (firsthtml === 1) {dPCT = ' <strong>' + FourthPCT + '</strong>'; dStatewide = ' <strong>' + FourthStatewide + '</strong>'; colord = color4; chosencandidateD = chosencandidate4}
else if (firsthtml === 2) {dPCT = ' <strong>' + ThirdPCT + '</strong>'; dStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colord = color3; chosencandidateD = chosencandidate3}
else if (firsthtml ===3) {dPCT = ' <strong>' + SecondPCT + '</strong>'; dStatewide = ' <strong>' + SecondStatewide + '</strong>'; colord = color2; chosencandidateD = chosencandidate2}
else {dPCT = ' <strong>' + FirstPCT + '</strong>'; dStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 4; colord = color1; chosencandidateD = chosencandidate1}
if (FourthStatewide === '') {ePCT = ''; eStatewide = ''; colore = whites; chosencandidateE = ''; firsthtml = ''}
else if (firsthtml === 1) {ePCT = ' <strong>' + FifthPCT + '</strong>'; eStatewide = ' <strong>' + FifthStatewide + '</strong>'; colore = color5; chosencandidateE = chosencandidate5}
else if (firsthtml === 2) {ePCT = ' <strong>' + FourthPCT + '</strong>'; eStatewide = ' <strong>' + FourthStatewide + '</strong>'; colore = color4; chosencandidateE = chosencandidate4}
else if (firsthtml === 3) {ePCT = ' <strong>' + ThirdPCT + '</strong>'; eStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colore = color3; chosencandidateE = chosencandidate3}
else if (firsthtml ===4) {ePCT = ' <strong>' + SecondPCT + '</strong>'; eStatewide = ' <strong>' + SecondStatewide + '</strong>'; colore = color2; chosencandidateE = chosencandidate2}
else {ePCT = ' <strong>' + FirstPCT + '</strong>'; eStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 5; colore = color1; chosencandidateE = chosencandidate1}
if (ThirdStatewide === '') {fPCT = ''; fStatewide = ''; colorf = whites; chosencandidateF = ''; firsthtml = ''}
else if (firsthtml === 1) {fPCT = ' <strong>' + SixthPCT + '</strong>'; fStatewide = ' <strong>' + SixthStatewide + '</strong>'; colorf = color6; chosencandidateF = chosencandidate6}
else if (firsthtml === 2) {fPCT = ' <strong>' + FifthPCT + '</strong>'; fStatewide = ' <strong>' + FifthStatewide + '</strong>'; colorf = color5; chosencandidateF = chosencandidate5}
else if (firsthtml === 3) {fPCT = ' <strong>' + FourthPCT + '</strong>'; fStatewide = ' <strong>' + FourthStatewide + '</strong>'; colorf = color4; chosencandidateF = chosencandidate4}
else if (firsthtml === 4) {fPCT = ' <strong>' + ThirdPCT + '</strong>'; fStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colorf = color3; chosencandidateF = chosencandidate3}
else if (firsthtml ===5) {fPCT = ' <strong>' + SecondPCT + '</strong>'; fStatewide = ' <strong>' + SecondStatewide + '</strong>'; colorf = color2; chosencandidateF = chosencandidate2}
else {fPCT = ' <strong>' + FirstPCT + '</strong>'; fStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 6; colorf = color1; chosencandidateF = chosencandidate1}
if (SecondStatewide === '') {gPCT = ''; gStatewide = ''; colorg = whites; chosencandidateG = ''; firsthtml = ''}
else if (firsthtml === 1) {gPCT = ' <strong>' + SeventhPCT + '</strong>'; gStatewide = ' <strong>' + SeventhStatewide + '</strong>'; colorg = color7; chosencandidateG = chosencandidate7}
else if (firsthtml === 2) {gPCT = ' <strong>' + SixthPCT + '</strong>'; gStatewide = ' <strong>' + SixthStatewide + '</strong>'; colorg = color6; chosencandidateG = chosencandidate6}
else if (firsthtml === 3) {gPCT = ' <strong>' + FifthPCT + '</strong>'; gStatewide = ' <strong>' + FifthStatewide + '</strong>'; colorg = color5; chosencandidateG = chosencandidate5}
else if (firsthtml === 4) {gPCT = ' <strong>' + FourthPCT + '</strong>'; gStatewide = ' <strong>' + FourthStatewide + '</strong>'; colorg = color4; chosencandidateG = chosencandidate4}
else if (firsthtml ===5) {gPCT = ' <strong>' + ThirdPCT + '</strong>'; gStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colorg = color3; chosencandidateG = chosencandidate3}
else if (firsthtml ===6) {gPCT = ' <strong>' + SecondPCT + '</strong>'; gStatewide = ' <strong>' + SecondStatewide + '</strong>'; colorg = color2; chosencandidateG = chosencandidate2}
else {gPCT = ' <strong>' + FirstPCT + '</strong>'; gStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 7; colorg = color1; chosencandidateG = chosencandidate1}
if (FirstStatewide === '') {hPCT = ''; gStatewide = ''; colorg = whites; chosencandidateG = ''; firsthtml = ''}
else if (firsthtml === 1) {hPCT = ' <strong>' + EighthPCT + '</strong>'; hStatewide = ' <strong>' + EighthStatewide + '/strong>'; colorh = color8; chosencandidateH = chosencandidate8}
else if (firsthtml === 2) {hPCT = ' <strong>' + SeventhPCT + '</strong>'; hStatewide = ' <strong>' + SeventhStatewide + '</strong>'; colorh = color7; chosencandidateH = chosencandidate7}
else if (firsthtml === 3) {hPCT = ' <strong>' + SixthPCT + '</strong>'; hStatewide = ' <strong>' + SixthStatewide + '</strong>'; colorh = color6; chosencandidateH = chosencandidate6}
else if (firsthtml === 4) {hPCT = ' <strong>' + FifthPCT + '</strong>'; hStatewide = ' <strong>' + FifthStatewide + '</strong>'; colorh = color5; chosencandidateH = chosencandidate5}
else if (firsthtml ===5) {hPCT = ' <strong>' + FourthPCT + '</strong>'; hStatewide = ' <strong>' + FourthStatewide + '</strong>'; colorh = color4; chosencandidateH = chosencandidate4}
else if (firsthtml ===6) {hPCT = ' <strong>' + ThirdPCT + '</strong>'; hStatewide = ' <strong>' + ThirdStatewide + '</strong>'; colorh = color3; chosencandidateH = chosencandidate3}
else if (firsthtml ===7) {hPCT = ' <strong>' + SecondPCT + '</strong>'; hStatewide = ' <strong>' + SecondStatewide + '</strong>'; colorh = color2; chosencandidateH = chosencandidate2}
else {hPCT = ' <strong>' + FirstPCT + '</strong>'; hStatewide = ' <strong>' + FirstStatewide + '</strong>'; firsthtml = 8; colorh = color1; chosencandidateH = chosencandidate1}
}
function percents () {
if (EighthStatewide === '') {aPCT = ''; aStatewide = ''; colora = whites; chosencandidateA = ''; firsthtml = ''}
else {aPCT = ' <strong>' + FirstPCT + '%</strong>'; aStatewide = ' <strong>' + FirstStatewide + '%</strong>'; colora = color1; chosencandidateA = chosencandidate1; firsthtml = 1};
if (SeventhStatewide === '') {bPCT = ''; bStatewide = ''; colorb = whites; chosencandidateB = ''; firsthtml = ''}
else if (firsthtml === 1) {bPCT = ' <strong>' + SecondPCT + '%</strong>'; bStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colorb = color2; chosencandidateB = chosencandidate2}
else {bPCT = ' <strong>' + FirstPCT + '%</strong>'; bStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 2; colorb = color1; chosencandidateB = chosencandidate1};
if (SixthStatewide === '') {cPCT = ''; cStatewide = ''; colorc = whites; colorc = color4; chosencandidateC = ''; firsthtml = ''}
else if (firsthtml === 1) {cPCT = ' <strong>' + ThirdPCT + '%</strong>'; cStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colorc = color3; chosencandidateC = chosencandidate3}
else if (firsthtml === 2) {cPCT = ' <strong>' + SecondPCT + '%</strong>'; cStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colorc = color2; chosencandidateC = chosencandidate2}
else {cPCT = ' <strong>' + FirstPCT + '%</strong>'; cStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 3; colorc = color1; chosencandidateC = chosencandidate1}
if (FifthStatewide === '') {dPCT = ''; dStatewide = ''; colord = whites; chosencandidateD = ''; firsthtml = ''}
else if (firsthtml === 1) {dPCT = ' <strong>' + FourthPCT + '%</strong>'; dStatewide = ' <strong>' + FourthStatewide + '%</strong>'; colord = color4; chosencandidateD = chosencandidate4}
else if (firsthtml === 2) {dPCT = ' <strong>' + ThirdPCT + '%</strong>'; dStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colord = color3; chosencandidateD = chosencandidate3}
else if (firsthtml ===3) {dPCT = ' <strong>' + SecondPCT + '%</strong>'; dStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colord = color2; chosencandidateD = chosencandidate2}
else {dPCT = ' <strong>' + FirstPCT + '%</strong>'; dStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 4; colord = color1; chosencandidateD = chosencandidate1}
if (FourthStatewide === '') {ePCT = ''; eStatewide = ''; colore = whites; chosencandidateE = ''; firsthtml = ''}
else if (firsthtml === 1) {ePCT = ' <strong>' + FifthPCT + '%</strong>'; eStatewide = ' <strong>' + FifthStatewide + '%</strong>'; colore = color5; chosencandidateE = chosencandidate5}
else if (firsthtml === 2) {ePCT = ' <strong>' + FourthPCT + '%</strong>'; eStatewide = ' <strong>' + FourthStatewide + '%</strong>'; colore = color4; chosencandidateE = chosencandidate4}
else if (firsthtml === 3) {ePCT = ' <strong>' + ThirdPCT + '%</strong>'; eStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colore = color3; chosencandidateE = chosencandidate3}
else if (firsthtml ===4) {ePCT = ' <strong>' + SecondPCT + '%</strong>'; eStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colore = color2; chosencandidateE = chosencandidate2}
else {ePCT = ' <strong>' + FirstPCT + '%</strong>'; eStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 5; colore = color1; chosencandidateE = chosencandidate1}
if (ThirdStatewide === '') {fPCT = ''; fStatewide = ''; colorf = whites; chosencandidateF = ''; firsthtml = ''}
else if (firsthtml === 1) {fPCT = ' <strong>' + SixthPCT + '%</strong>'; fStatewide = ' <strong>' + SixthStatewide + '%</strong>'; colorf = color6; chosencandidateF = chosencandidate6}
else if (firsthtml === 2) {fPCT = ' <strong>' + FifthPCT + '%</strong>'; fStatewide = ' <strong>' + FifthStatewide + '%</strong>'; colorf = color5; chosencandidateF = chosencandidate5}
else if (firsthtml === 3) {fPCT = ' <strong>' + FourthPCT + '%</strong>'; fStatewide = ' <strong>' + FourthStatewide + '%</strong>'; colorf = color4; chosencandidateF = chosencandidate4}
else if (firsthtml === 4) {fPCT = ' <strong>' + ThirdPCT + '%</strong>'; fStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colorf = color3; chosencandidateF = chosencandidate3}
else if (firsthtml ===5) {fPCT = ' <strong>' + SecondPCT + '%</strong>'; fStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colorf = color2; chosencandidateF = chosencandidate2}
else {fPCT = ' <strong>' + FirstPCT + '%</strong>'; fStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 6; colorf = color1; chosencandidateF = chosencandidate1}
if (SecondStatewide === '') {gPCT = ''; gStatewide = ''; colorg = whites; chosencandidateG = ''; firsthtml = ''}
else if (firsthtml === 1) {gPCT = ' <strong>' + SeventhPCT + '%</strong>'; gStatewide = ' <strong>' + SeventhStatewide + '%</strong>'; colorg = color7; chosencandidateG = chosencandidate7}
else if (firsthtml === 2) {gPCT = ' <strong>' + SixthPCT + '%</strong>'; gStatewide = ' <strong>' + SixthStatewide + '%</strong>'; colorg = color6; chosencandidateG = chosencandidate6}
else if (firsthtml === 3) {gPCT = ' <strong>' + FifthPCT + '%</strong>'; gStatewide = ' <strong>' + FifthStatewide + '%</strong>'; colorg = color5; chosencandidateG = chosencandidate5}
else if (firsthtml === 4) {gPCT = ' <strong>' + FourthPCT + '%</strong>'; gStatewide = ' <strong>' + FourthStatewide + '%</strong>'; colorg = color4; chosencandidateG = chosencandidate4}
else if (firsthtml ===5) {gPCT = ' <strong>' + ThirdPCT + '%</strong>'; gStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colorg = color3; chosencandidateG = chosencandidate3}
else if (firsthtml ===6) {gPCT = ' <strong>' + SecondPCT + '%</strong>'; gStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colorg = color2; chosencandidateG = chosencandidate2}
else {gPCT = ' <strong>' + FirstPCT + '%</strong>'; gStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 7; colorg = color1; chosencandidateG = chosencandidate1}
if (FirstStatewide === '') {hPCT = ''; gStatewide = ''; colorg = whites; chosencandidateG = ''; firsthtml = ''}
else if (firsthtml === 1) {hPCT = ' <strong>' + EighthPCT + '%</strong>'; hStatewide = ' <strong>' + EighthStatewide + '%</strong>'; colorh = color8; chosencandidateH = chosencandidate8}
else if (firsthtml === 2) {hPCT = ' <strong>' + SeventhPCT + '%</strong>'; hStatewide = ' <strong>' + SeventhStatewide + '%</strong>'; colorh = color7; chosencandidateH = chosencandidate7}
else if (firsthtml === 3) {hPCT = ' <strong>' + SixthPCT + '%</strong>'; hStatewide = ' <strong>' + SixthStatewide + '%</strong>'; colorh = color6; chosencandidateH = chosencandidate6}
else if (firsthtml === 4) {hPCT = ' <strong>' + FifthPCT + '%</strong>'; hStatewide = ' <strong>' + FifthStatewide + '%</strong>'; colorh = color5; chosencandidateH = chosencandidate5}
else if (firsthtml ===5) {hPCT = ' <strong>' + FourthPCT + '%</strong>'; hStatewide = ' <strong>' + FourthStatewide + '%</strong>'; colorh = color4; chosencandidateH = chosencandidate4}
else if (firsthtml ===6) {hPCT = ' <strong>' + ThirdPCT + '%</strong>'; hStatewide = ' <strong>' + ThirdStatewide + '%</strong>'; colorh = color3; chosencandidateH = chosencandidate3}
else if (firsthtml ===7) {hPCT = ' <strong>' + SecondPCT + '%</strong>'; hStatewide = ' <strong>' + SecondStatewide + '%</strong>'; colorh = color2; chosencandidateH = chosencandidate2}
else {hPCT = ' <strong>' + FirstPCT + '%</strong>'; hStatewide = ' <strong>' + FirstStatewide + '%</strong>'; firsthtml = 8; colorh = color1; chosencandidateH = chosencandidate1}
}
// Second Level Menus
function menuA () {for (var i = 0; i < toggleableLayerIdsA[bmenu].length; i++) {
id = toggleableLayerIdsA[bmenu][i];
if(id === '') {} else {Names = toggleableLayerNamesA[bmenu][i]};
if(id === '') {} else {var link = document.createElement('a')};
if(id === '') {} else {link.href = '#'};
if(id === '') {} else {link.className = 'none'};
if(id === '') {} else {link.className = 'activema'+bmenu};
if(Names !== toggleableLayerNamesA[bmenu][1]) {link.className = ''}
if(id === toggleableLayerNamesA[bmenu][0]) {link.className = 'headerma'+bmenu}
if(id === '') {} else {link.shortcut = id};
if(id === '') {} else {link.textContent = Names};
link.onclick = function (f) {
clickedLayerMenuA[bmenu] = this.shortcut;
clickedName[bmenu] = this.textContent
var current = document.getElementsByClassName('activema'+bmenu);
if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][0]) {} else if (current[0].className === 'activema'+bmenu) {current[0].className = current[0].className.replace('activema'+bmenu,"")}
if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][0]) {} else this.className = 'activema'+bmenu;
f.preventDefault();
f.stopPropagation();
if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][0]){}
if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][1])
{neweramenu = 1
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][2])
{neweramenu = 2
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][3])
{neweramenu = 3
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][4])
{neweramenu = 4
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][5])
{neweramenu = 5
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][6])
{neweramenu = 6
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][7])
{neweramenu = 7
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][8])
{neweramenu = 8
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][9])
{neweramenu = 9
newmain = 2
menuAvariables ()
}
else if (clickedLayerMenuA[bmenu] === toggleableLayerIdsA[bmenu][10])
{neweramenu = 10
newmain = 2
menuAvariables ()
}
}
var layers = document.getElementById('ma'+bmenu);
if (xstatus[bmenu]> 1) {} else {layers.appendChild(link)}

}
}
function menuAvariables () {
lv = layernumbermain[bmenu];
relevantCL = clickedLayer[main][bmenu][neweramenu]
relevantState = state[main][bmenu][neweramenu]
relevantColor = relevanttype[main][bmenu][neweramenu]
chosenlayer = layer[lv];
firstmatrix = main
secondmatrix = bmenu
thirdmatrix = neweramenu
if (oldlv === lv) {} else {changelayer ()}
xAstatus[(bmenu*10)+neweramenu] ++;
mbs[(bmenu*10)+neweramenu].style.display = 'block';
if(lowermenuA[bmenu][neweramenu] === 0) {if (relevantColor === 'Ancestry') {resetlegend(); colormap (); nomenu ()}
else if (relevantColor === 'Margin') {xMarginResetstatus = 1 ;resetlegend(); colormap3 (); nomenu ()}
else if (relevantColor === 'Margin7') {xMargin7Resetstatus = 1; resetlegend(); colormap4 (); nomenu ()}
else if (relevantColor === 'JMCWincode') {xJMCResetstatus = 1; resetlegend(); colormap5 (); nomenu ()}
else if (relevantColor === 'PopPCT') {xPopPCTResetstatus = 1; resetlegend(); colormap6 (); nomenu ()}
else if (relevantColor === 'PopNUM') {xPopNUMResetstatus = 1; resetlegend(); colormap7 (); nomenu ()}
else {xWinResetstatus = 1; resetlegend(); colormap2 (); nomenu ()}}
else {menuB ()}
}
//Third Level Menus
function menuB () {
oldbmenu = bmenu
newbmenu = (bmenu*10)+neweramenu

for (var i = 0; i < toggleableLayerIdsB[newbmenu].length; i++) {
var id = toggleableLayerIdsB[newbmenu][i];
if(id === ''){} else {Names = toggleableLayerNamesB[newbmenu][i]};
if(id === ''){} else {var link = document.createElement('a')};
if(id === ''){} else {link.href = '#'};
if(id === ''){} else {link.className = 'none'};
if(id === ''){} else {link.className = 'activemb'+newbmenu};
if(Names !== toggleableLayerNamesB[newbmenu][1]) {link.className = ''}
if(id === toggleableLayerNamesB[newbmenu][0]) {link.className = 'headermb'+newbmenu}
if(id === '') {} else {link.shortcut = id};
if(id === '') {} else {link.textContent = Names};
link.onclick = function (f) {
clickedLayerMenuB[newbmenu] = this.shortcut;
clickedName[newbmenu] = this.textContent
var current = document.getElementsByClassName('activemb'+newbmenu);
if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][0]) {} else if(current[0].className === 'activemb'+newbmenu) {current[0].className = current[0].className.replace('activemb'+newbmenu,"")}
if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][0]) {} else {this.className = 'activemb'+newbmenu};
f.preventDefault();
f.stopPropagation();
{
if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][0]){}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][1])
{newamenu = 1
menuBvariables ()
}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][2])
{newamenu = 2
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][3])
{newamenu = 3
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][4])
{newamenu = 4
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][5])
{newamenu = 5
lv = layernumbermain[oldbmenu];
menuBvariables()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][6])
{newamenu = 6
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][7])
{newamenu = 7
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu]=== toggleableLayerIdsB[newbmenu][8])
{newamenu = 8
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][9])
{newamenu = 9
menuBvariables ()}
else if (clickedLayerMenuB[newbmenu] === toggleableLayerIdsB[newbmenu][10])
{newamenu = 10
menuBvariables ()}
}}
var layers = document.getElementById('mb'+(newbmenu));
if (xAstatus[newbmenu] > 1) {} else
{layers.appendChild(link)}}
}
function menuBvariables (){
lv = layernumbermain[oldbmenu];
chosenlayer = layer[lv];
relevantCL = clickedLayer[newmain][newbmenu][newamenu]
relevantState = state[newmain][newbmenu][newamenu]
relevantColor = relevanttype[newmain][newbmenu][newamenu]
firstmatrix = newmain
secondmatrix = newbmenu
thirdmatrix = newamenu
if (oldlv === lv) {} else {changelayer ()}
mbs[newbmenu].style.display = 'block';
if (relevantColor === 'Ancestry') {resetlegend(); colormap (); nomenu ()}
else if (relevantColor === 'Margin') {xMarginResetstatus = 1; resetlegend(); colormap3 (); nomenu ()}
else if (relevantColor === 'Margin7') {xMargin7Resetstatus = 1; resetlegend(); colormap4 (); nomenu ()}
else if (relevantColor === 'JMCWincode') {xJMCResetstatus = 1; resetlegend(); colormap5 (); nomenu ()}
else if (relevantColor === 'PopPCT') {xPopPCTResetstatus = 1; resetlegend(); colormap6 (); nomenu ()}
else if (relevantColor === 'PopNUM') {xPopNUMResetstatus = 1; resetlegend(); colormap7 (); nomenu ()}
else {xWinResetstatus = 1; resetlegend(); colormap2 (); nomenu ()}
}

function mainmenuvariables (){
lv = layernumbermain[bmenu];
relevantCL = clickedLayer[main][bmenu][amenu]
relevantState = state[main][bmenu][amenu]
relevantColor = relevanttype[main][bmenu][amenu]
firstmatrix = main
secondmatrix = bmenu
thirdmatrix = amenu
xstatus[bmenu] ++;
if (oldlv === lv) {} else {changelayer ()}
mas[bmenu].style.display = 'block';
chosenlayer = layer[lv];
if(lowermainmenu[bmenu] === 0) {if (relevantColor === 'Ancestry') {resetlegend (); colormap (); nomenu ()}
else if (relevantColor === 'Margin') {xMarginResetstatus = 1; resetlegend(); colormap3 (); nomenu ()}
else if (relevantColor === 'Margin7') {xMargin7Resetstatus = 1; resetlegend(); colormap4 (); nomenu ()}
else if (relevantColor === 'JMCWincode') {xJMCResetstatus = 1; resetlegend(); colormap5 (); nomenu ()}
else if (relevantColor === 'PopPCT') {xPopPCTResetstatus = 1; resetlegend(); colormap6 (); nomenu ()}
else if (relevantColor === 'PopNUM') {xPopNUMResetstatus = 1; resetlegend(); colormap7 (); nomenu ()}
else {xWinResetstatus = 1; resetlegend (); colormap2 (); nomenu ()}}
else {menuA ()}
}
function nomenu () {
if (cellphone === 'Y') {
mobilepopup ()
clearmenu ()}
else if(cellphone === 'N'){
desktopLabel ();
colorchange ();}
clearmenu ()}

function changelayer () {
map.setLayoutProperty(layer[oldlv],'visibility','none')
map.setLayoutProperty(layer[lv],'visibility','visible')
oldlv = lv
chosenlayer = layer[lv]
if (legendstatus[0].style.display === 'none') {mobilepopup ()};
}
//Start of Default Map. Must edit variables for labels. LV = Layer Value; amenu = Map Value. Default = 0
let lv = 0
let amenu = 0
let bmenu = 0
let main = 0
let firstmatrix = main
let secondmatrix = bmenu
let thirdmatrix = amenu
chosenlayer = layer[lv]
let oldlv = lv
if (relevantColor ==='Ancestry') {colormap ()}
else if (relevantColor === 'Margin') {colormap3 ()}
else if (relevantColor === 'Margin7') {colormap4 ()}
else if (relevantColor === 'JMCWincode') {colormap5 ()}
else if (relevantColor === 'PopPCT') {colormap6 ()}
else if (relevantColor === 'PopNUM') {colormap7 ()}
else {colormap2 ()}
//Cellphone Popup
if (cellphone === 'Y') {
mobilepopup ()}
//Desktop mouseover
else if(cellphone === 'N'){desktopLabel ();
colorchange ();}
//Resets legend
function resetlegend () {
if (relevantCL === 'W') {if (relevantColor === 'JMCWincode') {colorscale = (colorstep[firstmatrix][secondmatrix][thirdmatrix]);
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1;
csslider.step = 0.1;
csslider.value = colorscale;
JMClabel ()
}
else if (relevantColor === 'PopPCT') {colorscale = (colorstep[firstmatrix][secondmatrix][thirdmatrix]);
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1;
csslider.step = 0.1;
csslider.value = colorscale;
PPlabel ()
}

else if (relevantColor === 'PopNUM') {colorscale = (colorstep[firstmatrix][secondmatrix][thirdmatrix]);
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' residents';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 10;
csslider.step = 10;
csslider.value = colorscale;
PNlabel ()
}
else if (relevantColor === 'Margin7') {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1;
csslider.step = 0.1;
csslider.value = colorscale;
m7label ()
}
else if (relevantColor === 'Margin') {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1;
csslider.step = 0.1;
csslider.value = colorscale
otherlabel ()
}
else if (relevantColor === 'Ancestry') {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = 'N/A';
csslider.max = 1;
csslider.min = 1;
csslider.step = 1;
csslider.value = colorscale
otherlabel ()
}
else {colorscale = (colorstep[firstmatrix][secondmatrix][thirdmatrix]);
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1
csslider.step = 0.1
csslider.value = colorscale

otherlabel ()
}
}
else if (relevantCL === 'R') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'B') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'Y') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'G') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'O') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'P') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'T') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}
else if (relevantCL === 'V') if (relevantColor === "JMCWincode") {JMCWincodereset ()} else if (relevantColor === 'PopPCT') {PopPCTreset ()} else if (relevantColor === 'PopNUM') {PopNUMreset ()} else {normalreset ()}

else {if (relevantColor === 'Ancestry') {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = 'N/A';
csslider.max = 1;
csslider.min = 1;
csslider.step = 1;
csslider.value = colorscale
otherlabel ()}
else
{colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1
csslider.step = 0.1
csslider.value = colorscale;
otherlabel ()}
}
}
function normalreset () {
if (relevantColor === 'Wincode') {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1
csslider.step = 0.1
csslider.value = colorscale}
else {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.value = colorscale}
otherlabel ()
}

function PopPCTreset () {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale +' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1
csslider.step = 0.1
csslider.value = colorscale;
PPlabel()
}

function PopNUMreset () {colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorstep + ' residents';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 10
csslider.step = 10
csslider.value = colorstep;
PNlabel ()

}

function JMCWincodereset () {
colorscale = colorstep[firstmatrix][secondmatrix][thirdmatrix];
startwincode = startvalue[firstmatrix][secondmatrix][thirdmatrix];
cssliderValue.textContent = colorscale + ' points';
csslider.max = maxslider[firstmatrix][secondmatrix][thirdmatrix];
csslider.min = 0.1
csslider.step = 0.1
csslider.value = colorscale;
JMClabel()
}

function choosecolor () {
if (WinColors === 'JMC')
{reds = ['#909090','#FFD5D9','#FFAAAE','#FB6666','#EB4747','#CC3333','#AC2929','#8C1C1C','#6C1717','#531515','#321111','#2C0F0F'];
blues = ['#909090','#D5D9FF','#AAAEFF','#6666FB','#4747EB','#3333CC','#2929AC','#1C1C8C','#17176C','#151553','#11113C','#0F0F2C'];
greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
reds7 = ['#909090','#FFBBBB','#F58181','#EB4747','#CC3333','#AA2222','#881111','#660000'];
blues7 = ['#909090','#BBBBFF','#8181F5','#4747EB','#3333CC','#2222AA','#111188','#000066']
reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}
else if (WinColors === 'Atlas')
{reds = ['#909090','#00ffff','#00ddff','#00bbff','#0099ff','#0000ff','#0000dd','#0000bb','#000099','#000088','#000077','#000066'];
blues = ['#909090','#ff99ff','#ff66ff','#ff33cc','#ff0099','#ff0000','#dd0000','#bb0000','#990000','#880000','#770000','#660000'];
greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
reds7 = ['#909090','#33CCFF','#0099FF','#0000FF','#0000DD','#0000BB','#000099','#000088'];
blues7 =['#909090','#FF33CC','#FF0099', '#FF0000', '#DD0000', '#BB0000', "#990000", '#880000']
reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}
else if (WinColors === 'ReverseAtlas')
{reds = ['#909090','#ff99ff','#ff66ff','#ff33cc','#ff0099','#ff0000','#dd0000','#bb0000','#990000','#880000','#770000','#660000'];
blues = ['#909090','#00ffff','#00ddff','#00bbff','#0099ff','#0000ff','#0000dd','#0000bb','#000099','#000088','#000077','#000066'];
greens = ['#909090','#33ffcc','#00ffcc','#00ffaa','#00ff99','#00ff00','#00dd00','#00bb00','#009900','#008800','#007700','#006600'];
yellows = ['#909090','#ffffdd','#ffffbb','#ffffaa','#ffff99','#ffff00','#dddd00','#bbbb00','#999900','#888800','#777700','#666600'];
oranges = ['#909090','#ffdd00','#ffcc00','#ffbb00','#ffaa00','#ff8800','#ff6600','#cc4400','#aa2a00','#992200','#771100','#661100'];
purples = ['#909090','#eeddff','#ddccff','#ddbbff','#cc99ff','#aa33ff','#8800dd','#6600bb','#440099','#330088','#220077','#110066'];
teals = ['#909090','#ddffff','#bbffff','#aaffff','#99ffff','#00ffff','#00dddd','#00bbbb','#009999','#008888','#007777','#006666'];
violets = ['#909090','#ffddff','#ffbbff','#ffaaff','#ff99ff','#ff00ff','#dd00dd','#bb00bb','#990099','#880088','#770077','#660066'];
reds7 =['#909090','#FF33CC','#FF0099', '#FF0000', '#DD0000', '#BB0000', "#990000", '#880000'];
blues7 = ['#909090','#33CCFF','#0099FF','#0000FF','#0000DD','#0000BB','#000099','#000088']
reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}
else
{reds = ['#909090','#ffbfbf','#ffacac','#ff9898','#ff8585','#ff7171','#ff5d5d','#ff4a4a','#ff3636','#ff2323','#ff0f0f','#ff0000'];
blues = ['#909090','#bbbbfe','#a8a8f5','#9595ed','#8282e5','#6f6fdc','#5c5cd4','#4848cb','#3535c3','#2222bb','#0f0fb2','#0909aa'];
greens = ['#909090','#abe6ab','#9ae099','#88d988','#77d376','#65cc64','#54c653','#42c041','#31b92f','#1fb31e','#0ead0c','#00a500'];
yellows = ['#909090','#fcfcb9','#f0f0a6','#e4e492','#d8d87e','#cccc6b','#c0c057','#b4b443','#a8a830','#9c9c1c','#909008','#7a7a00'];
oranges = ['#909090','#ffdbb7','#ffd1a4','#ffc790','#ffbc7d','#ffb269','#ffa855','#ff9e42','#ff932e','#ff891b','#ff7f07','#ff6e02'];
purples = ['#909090','#e2a4e2','#da92da','#d280d2','#ca6fca','#c25dc2','#b94bb9','#b13ab1','#a928a9','#a116a1','#990599','#860081'];
teals = ['#909090','#b3fbfb','#9ff4f4','#8becec','#76e5e5','#62dddd','#4ed6d6','#3acfcf','#25c7c7','#11c0c0','#4dbbcf','#3ab7c7'];
violets = ['#909090','#ffb2ff','#ff9eff','#ff8aff','#ff77ff','#ff63ff','#ff50ff','#ff3cff','#ff29ff','#ff15ff','#ff01ff','#ff00ef'];
reds7 = ['#909090','#febdbd','#f4a3a3', '#e98a8a', '#df7171', '#d45757', '#c93e3e', '#bf2525'];
blues7 = ['#909090', '#b0b4f9', '#979aef', '#7e81e4', '#6467da', '#4b4dd0', '#3233c5', '#1919bb']
reds15 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
yellows15 = ['#909090','#FCFCB9','#F0F0AB','#E4E49E','#D9D991','#CDCD84','#C2C276','#B6B669','#ABAB5C','#9F9F4F','#939342','#888834','#7C7C27','#71711A','#65650D','#5A5A00'];
greens15 = ['#909090','#ABE6AB','#9EDB9E','#92D192','#86C686','#7ABC7A','#6DB26D','#61A761','#559D55','#499349','#3D883D','#307E30','#247424','#186918','#0C5F0C','#005500'];
oranges15 = ['#909090','#FFDBB7','#FFCFA9','#FFC39C','#FFB78F','#FFAB82','#FF9F75','#FF9368','#FF875B','#FF7B4E','#FF6F41','#FF6334','#FF5727','#FF4B1A','#FF3F0D','#FF3300'];
purples15 = ['#909090','#E2A4E2','#D798D7','#CD8CCD','#C380C3','#B975B9','#AF69AF','#A55DA5','#9B529B','#914691','#873A87','#7D2E7D','#732373','#691769','#5F0B5F','#550055'];
teals15 = ['#909090','#B3FBFB','#A8F3F4','#9DEBED','#92E4E7','#88DCE0','#7DD5DA','#72CDD3','#68C6CD','#5DBEC6','#52B6BF','#47AFB9','#3DA7B2','#32A0AC','#2798A5','#1D919F'];
violets15 = ['#909090','#FFB2FF','#FFA5FA','#FF98F5','#FF8BF0','#FF7FEB','#FF72E6','#FF65E1','#FF59DD','#FF4CD8','#FF3FD3','#FF32CE','#FF26C9','#FF19C4','#FF0CBF','#FF00BB'];
blues15 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0'];
reds19 = ['#909090','#febdbd','#f9b0b0','#f4a3a3','#ef9797','#e98a8a','#e47d7d','#df7171','#d96464','#d45757','#cf4b4b','#c93e3e','#c43131','#bf2525','#b91818','#b40b0b','#880000','#550000','#330000','#110000'];
blues19 = ['#909090','#b0b4f9','#a4a7f4','#979aef','#8a8dea','#7e81e4','#7174df','#6467da','#585ad5','#4b4dd0','#3f40ca','#3233c5','#2526c0','#1919bb','#0c0cb5','#0000b0', '#000099','#000077','#000055','#000033']
yellows19 = ['#909090','#FCFCB9','#F0F0AE','#E5E5A4','#DADA9A','#CFCF8F','#C4C485','#B9B97B','#ADAD71','#A2A266','#97975C','#8C8C53','#818147','#76763D','#6A6A33','#5F5F29','#54541E','#494914','#3E3E0A','#333300'];
greens19 = ['#909090','#ABE6AB','#A1DCA1','#98D298','#8EC88E','#85BE85','#7BB47B','#72AA72','#68A068','#5F965F','#558C55','#4C824C','#427842','#396E39','#2F642F','#265A26','#1C501C','#134613','#093C09','#003300'];
oranges19 = ['#909090','#FFDBB7','#FFCFAC','#FFC4A2','#FFB998','#FFAE8E','#FFA284','#FF977A','#FF8C6F','#FF8165','#FF765B','#FF6A51','#FF5F47','#FF543D','#FF4932','#FF3D28','#FF321E','#FF2714','#FF1C0A','#FF1100'];
purples19 = ['#909090','#E2A4E2','#D89AD8','#CE91CE','#C488C4','#BB7FBB','#B176B1','#A76DA7','#9D649D','#945B94','#8A528A','#804880','#773F77','#6D366D','#632D63','#592459','#501B50','#461246','#3C093C','#330033'];
teals19 = ['#909090','#B3FBFB','#A9F4F4','#9FEEEE','#95E7E7','#8BE1E1','#81DBDB','#77D4D4','#6DCECE','#63C7C7','#59C1C1','#4FBBBB','#45B4B4','#3BAEAE','#31A7A7','#27A1A1','#1D9B9B','#139494','#098E8E','#008888'];
violets19 = ['#909090','#FFB2FF','#FFA8FD','#FF9EF3','#FF94EE','#FF8AE8','#FF80E2','#FF76DD','#FF6CD7','#FF62D1','#FF59CC','#FF4FC6','#FF45C0','#FF3BBB','#FF31B5','#FF27AF','#FF1DAA','#FF13A4','#FF099E','#FF0099']}

if (relevantColor === 'Ancestry') {colormap (); nomenu ()}
else if (relevantColor === 'Margin7') {resetlegend (); colormap4 (); nomenu (); xMargin7Colorstatus = 1; xMargin7Colorreset = 1; xMargin7Resetstatus = 1}

else if (relevantColor === 'PopPCT') {if(xPopPCTResetstatus === 2) {colormap6 (); nomenu ()} else {
if (PopPCTcolor1 === reds15) {PopPCTcolor1txt = 'Red'}
else if (PopPCTcolor1 === blues15) {PopPCTcolor1txt = 'Blue'}
else if (PopPCTcolor1 === greens15) {PopPCTcolor1txt = 'Green'}
else if (PopPCTcolor1 === yellows15) {PopPCTcolor1txt = 'Yellow'}
else if (PopPCTcolor1 === oranges15) {PopPCTcolor1txt = 'Orange'}
else if (PopPCTcolor1 === purples15) {PopPCTcolor1txt = 'Purple'}
else if (PopPCTcolor1 === teals15) {PopPCTcolor1txt = 'Teal'}
else if (PopPCTcolor1 === violets15) {PopPCTcolor1txt = 'Violet'}
else {PopPCTcolor1txt = 'Blue'}

if (PopPCTcolor2 === reds15) {PopPCTcolor2txt = 'Red'}
else if (PopPCTcolor2 === blues15) {PopPCTcolor2txt = 'Blue'}
else if (PopPCTcolor2 === greens15) {PopPCTcolor2txt = 'Green'}
else if (PopPCTcolor2 === yellows15) {PopPCTcolor2txt = 'Yellow'}
else if (PopPCTcolor2 === oranges15) {PopPCTcolor2txt = 'Orange'}
else if (PopPCTcolor2 === purples15) {PopPCTcolor2txt = 'Purple'}
else if (PopPCTcolor2 === teals15) {PopPCTcolor2txt = 'Teal'}
else if (PopPCTcolor2 === violets15) {PopPCTcolor2txt = 'Violet'}
else {PopPCTcolor2txt = 'Red'}
xColorMPPstatus ++
var toggleableColorIdsMPP = ['Lcolor',blues15,reds15,greens15,yellows15,oranges15,purples15,teals15,violets15];
var toggleableColorNamesMPP = ['Low Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (l = 0; l < toggleableColorIdsMPP.length; l++) {
var idcolorMPP = toggleableColorIdsMPP[l];
var NamescolorMPP = toggleableColorNamesMPP[l];
var linkcolorMPP = document.createElement('a');
linkcolorMPP.href = '#';
linkcolorMPP.className = 'activecolorMlmenu';
if(NamescolorMPP !== PopPCTcolor1txt) {linkcolorMPP.className = ''}
if(idcolorMPP === toggleableColorIdsMPP[0]) {linkcolorMPP.className = 'headercolorMPPmenu'}
if(NamescolorMPP === PopPCTcolor1txt) {linkcolorMPP.className = 'activecolorMPPmenu'}
linkcolorMPP.shortcut = idcolorMPP;
linkcolorMPP.textContent = NamescolorMPP;
colorMPPmenu.style.display = 'block';
linkcolorMPP.onclick = function (g) {
PopPCTcolor1 = this.shortcut;
PopPCTcolor1Names = this.textContent;
PopPCTcolor1txt = this.textContent;
var currentcolorMPP = document.getElementsByClassName('activecolorMPPmenu');
if (PopPCTcolor1 === toggleableColorIdsMPP[0]) {} else if (currentcolorMPP[0].className === 'activecolorMPPmenu') {currentcolorMPP[0].className = currentcolorMPP[0].className.replace('activecolorMPPmenu','')};
if (PopPCTcolor1 === toggleableColorIdsMPP[0]) {} else {this.className = 'activecolorMPPmenu'};
g.preventDefault();
g.stopPropagation();
if (PopPCTcolor1 === toggleableColorIdsMPP[0]) {} else {xColorMPPhstatus ++
var toggleableColorIdsMPPh = ['Hcolor',blues15,reds15,greens15,yellows15,oranges15,purples15,teals15,violets15];
var toggleableColorNamesMPPh = ['High Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (m = 0; m < toggleableColorIdsMPPh.length; m++) {
var idcolorMPPh = toggleableColorIdsMPPh[m];
var NamescolorMPPh = toggleableColorNamesMPPh[m];
var linkcolorMPPh = document.createElement('a');
linkcolorMPPh.href = '#';
linkcolorMPPh.className = 'activecolorMPPhmenu';
if(NamescolorMPPh !== PopPCTcolor2txt) {linkcolorMPPh.className = ''}
if(idcolorMPPh === toggleableColorIdsMPPh[0]) {linkcolorMPPh.className = 'headercolorMPPhmenu'}
if(NamescolorMPPh === PopPCTcolor2txt) {linkcolorMPPh.className = 'activecolorMPPhmenu'}
linkcolorMPPh.shortcut = idcolorMPPh;
linkcolorMPPh.textContent = NamescolorMPPh;
colorMPPhmenu.style.display = 'block';
linkcolorMPPh.onclick = function (h) {
PopPCTcolor2 = this.shortcut;
PopPCTcolor2Names = this.textContent;
PopPCTcolor2txt = this.textContent;
var currentcolorMPPh = document.getElementsByClassName('activecolorMPPhmenu');
if (PopPCTcolor2 === toggleableColorIdsMPPh[0]) {} else if (currentcolorMPPh[0].className === 'activecolorMPPhmenu') {currentcolorMPPh[0].className = currentcolorMPPh[0].className.replace('activecolorMPPhmenu','')};
if (PopPCTcolor2 === toggleableColorIdsMPPh[0]) {} else {this.className = 'activecolorMPPhmenu'};
h.preventDefault();
h.stopPropagation();

if(PopPCTcolor2 === toggleableColorIdsMPP[0]) {} else {resetlegend (); colormap6 (); nomenu (); xPopPCTColorstatus = 1; xPopPCTColorreset = 1; xPopPCTResetstatus = 1}
}
var layerscolorMPPh = document.getElementById('colorMPPhmenu');
if (xColorMPPhstatus > 1) {} else
{layerscolorMPPh.appendChild(linkcolorMPPh)}}
}
}
var layerscolorMPP = document.getElementById('colorMPPmenu');
if (xColorMPPstatus > 1) {} else
{layerscolorMPP.appendChild(linkcolorMPP)}}
}
}
else if (relevantColor === 'PopNUM') {if(xPopNUMResetstatus === 2) {colormap7 (); nomenu ()} else {PopNUMcolorcheck ()
xColorMPNstatus ++
var toggleableColorIdsMPN = ['Lcolor',blues19,reds19,greens19,yellows19,oranges19,purples19,teals19,violets19];
var toggleableColorNamesMPN = ['Low Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (l = 0; l < toggleableColorIdsMPN.length; l++) {
var idcolorMPN = toggleableColorIdsMPN[l];
var NamescolorMPN = toggleableColorNamesMPN[l];
var linkcolorMPN = document.createElement('a');
linkcolorMPN.href = '#';
linkcolorMPN.className = 'activecolorMPNmenu';
if(NamescolorMPN !== PopNUMcolor1txt) {linkcolorMPN.className = ''}
if(idcolorMPN === toggleableColorIdsMPN[0]) {linkcolorMPN.className = 'headercolorMPNmenu'}
if(NamescolorMPN === PopNUMcolor1txt) {linkcolorMPN.className = 'activecolorMPNmenu'}
linkcolorMPN.shortcut = idcolorMPN;
linkcolorMPN.textContent = NamescolorMPN;
colorMPNmenu.style.display = 'block';
linkcolorMPN.onclick = function (y) {
PopNUMcolor1 = this.shortcut;
let NUMcolor1 = this.shortcut;
PopNUMcolor1Names = this.textContent;
PopNUMcolor1txt = this.textContent;
var currentcolorMPN = document.getElementsByClassName('activecolorMPNmenu');
if (PopNUMcolor1 === toggleableColorIdsMPN[0]) {} else if (currentcolorMPN[0].className === 'activecolorMPNmenu') {currentcolorMPN[0].className = currentcolorMPN[0].className.replace('activecolorMPNmenu','')};
if (PopNUMcolor1 === toggleableColorIdsMPN[0]) {} else {this.className = 'activecolorMPNmenu'};
y.preventDefault();
y.stopPropagation();
if (PopNUMcolor1 === toggleableColorIdsMPN[0]) {} else {xColorMPNhstatus ++
var toggleableColorIdsMPNh = ['Hcolor',blues19,reds19,greens19,yellows19,oranges19,purples19,teals19,violets19];
var toggleableColorNamesMPNh = ['High Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (m = 0; m < toggleableColorIdsMPNh.length; m++) {
var idcolorMPNh = toggleableColorIdsMPNh[m];
var NamescolorMPNh = toggleableColorNamesMPNh[m];
var linkcolorMPNh = document.createElement('a');
linkcolorMPNh.href = '#';
linkcolorMPNh.className = 'activecolorMPNhmenu';
if(NamescolorMPNh !== PopNUMcolor2txt) {linkcolorMPNh.className = ''}
if(idcolorMPNh === toggleableColorIdsMPNh[0]) {linkcolorMPNh.className = 'headercolorMPNhmenu'}
if(NamescolorMPNh === PopNUMcolor2txt) {linkcolorMPNh.className = 'activecolorMPNhmenu'}
linkcolorMPNh.shortcut = idcolorMPNh;
linkcolorMPNh.textContent = NamescolorMPNh;
colorMPNhmenu.style.display = 'block';
linkcolorMPNh.onclick = function (z) {
PopNUMcolor2 = this.shortcut;
let NUMcolor2 = this.shortcut;
PopNUMcolor2Names = this.textContent;
PopNUMcolor2txt = this.textContent;
var currentcolorMPNh = document.getElementsByClassName('activecolorMPNhmenu');
if (PopNUMcolor2 === toggleableColorIdsMPNh[0]) {} else if (currentcolorMPNh[0].className === 'activecolorMPNhmenu') {currentcolorMPNh[0].className = currentcolorMPNh[0].className.replace('activecolorMPNhmenu','')};
if (PopNUMcolor2 === toggleableColorIdsMPNh[0]) {} else {this.className = 'activecolorMPNhmenu'};
z.preventDefault();
z.stopPropagation();

if(PopNUMcolor2 === toggleableColorIdsMPN[0]) {} else {resetlegend (); colormap7 (); nomenu (); xPopNUMColorstatus = 1; xPopNUMColorreset = 1; xPopNUMResetstatus = 1}
}
var layerscolorMPNh = document.getElementById('colorMPNhmenu');
if (xColorMPNhstatus > 1) {} else
{layerscolorMPNh.appendChild(linkcolorMPNh)}}
}
}
var layerscolorMPN = document.getElementById('colorMPNmenu');
if (xColorMPNstatus > 1) {} else
{layerscolorMPN.appendChild(linkcolorMPN)}}
}
}
else if (relevantColor === 'JMCWincode') {resetlegend (); colormap5 (); nomenu (); xJMCColorstatus = 1; xJMCColorreset = 1; xJMCResetstatus = 1}
else if (relevantColor === 'Wincode') {resetlegend (); colormap2 (); nomenu (); xWinColorstatus = 1; xWinColorreset = 1; xWinResetstatus = 1}
else if (relevantColor === 'Margin') {if(xMarginResetstatus === 2) {colormap3 (); nomenu ()} else {
if (margincolor1 === reds) {margincolor1txt = 'Red'}
else if (margincolor1 === blues) {margincolor1txt = 'Blue'}
else if (margincolor1 === greens) {margincolor1txt = 'Green'}
else if (margincolor1 === yellows) {margincolor1txt = 'Yellow'}
else if (margincolor1 === oranges) {margincolor1txt = 'Orange'}
else if (margincolor1 === purples) {margincolor1txt = 'Purple'}
else if (margincolor1 === teals) {margincolor1txt = 'Teal'}
else if (margincolor1 === violets) {margincolor1txt = 'Violet'}
else {margincolor1txt = 'Blue'}

if (margincolor2 === reds) {margincolor2txt = 'Red'}
else if (margincolor2 === blues) {margincolor2txt = 'Blue'}
else if (margincolor2 === greens) {margincolor2txt = 'Green'}
else if (margincolor2 === yellows) {margincolor2txt = 'Yellow'}
else if (margincolor2 === oranges) {margincolor2txt = 'Orange'}
else if (margincolor2 === purples) {margincolor2txt = 'Purple'}
else if (margincolor2 === teals) {margincolor2txt = 'Teal'}
else if (margincolor2 === violets) {margincolor2txt = 'Violet'}
else {margincolor2txt = 'Red'}
xColorMlstatus ++
var toggleableColorIdsMl = ['Lcolor',blues,reds,greens,yellows,oranges,purples,teals,violets];
var toggleableColorNamesMl = ['Low Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (l = 0; l < toggleableColorIdsMl.length; l++) {
var idcolorMl = toggleableColorIdsMl[l];
var NamescolorMl = toggleableColorNamesMl[l];
var linkcolorMl = document.createElement('a');
linkcolorMl.href = '#';
linkcolorMl.className = 'activecolorMlmenu';
if(NamescolorMl !== margincolor1txt) {linkcolorMl.className = ''}
if(idcolorMl === toggleableColorIdsMl[0]) {linkcolorMl.className = 'headercolorMlmenu'}
if(NamescolorMl === margincolor1txt) {linkcolorMl.className = 'activecolorMlmenu'}
linkcolorMl.shortcut = idcolorMl;
linkcolorMl.textContent = NamescolorMl;
colorMlmenu.style.display = 'block';
linkcolorMl.onclick = function (g) {
margincolor1 = this.shortcut;
margincolor1Names = this.textContent;
margincolor1txt = this.textContent;
var currentcolorMl = document.getElementsByClassName('activecolorMlmenu');
if (margincolor1 === toggleableColorIdsMl[0]) {} else if (currentcolorMl[0].className === 'activecolorMlmenu') {currentcolorMl[0].className = currentcolorMl[0].className.replace('activecolorMlmenu','')};
if (margincolor1 === toggleableColorIdsMl[0]) {} else {this.className = 'activecolorMlmenu'};
g.preventDefault();
g.stopPropagation();
if(margincolor1 === toggleableColorIdsMl[0]) {} else {xColorMhstatus ++
var toggleableColorIdsMh = ['Hcolor',blues,reds,greens,yellows,oranges,purples,teals,violets];
var toggleableColorNamesMh = ['High Color','Blue','Red','Green','Yellow','Orange','Purple','Teal','Violet'];
for (m = 0; m < toggleableColorIdsMh.length; m++) {
var idcolorMh = toggleableColorIdsMh[m];
var NamescolorMh = toggleableColorNamesMh[m];
var linkcolorMh = document.createElement('a');
linkcolorMh.href = '#';
linkcolorMh.className = 'activecolorMhmenu';
if(NamescolorMh !== margincolor2txt) {linkcolorMh.className = ''}
if(idcolorMh === toggleableColorIdsMh[0]) {linkcolorMh.className = 'headercolorMhmenu'}
if(NamescolorMh === margincolor2txt) {linkcolorMh.className = 'activecolorMhmenu'}
linkcolorMh.shortcut = idcolorMh;
linkcolorMh.textContent = NamescolorMh;
colorMhmenu.style.display = 'block';
linkcolorMh.onclick = function (h) {
margincolor2 = this.shortcut;
margincolor2Names = this.textContent;
margincolor2txt = this.textContent;
var currentcolorMh = document.getElementsByClassName('activecolorMhmenu');
if (margincolor2 === toggleableColorIdsMh[0]) {} else if (currentcolorMh[0].className === 'activecolorMhmenu') {currentcolorMh[0].className = currentcolorMh[0].className.replace('activecolorMhmenu','')};
if (margincolor2 === toggleableColorIdsMh[0]) {} else {this.className = 'activecolorMhmenu'};
h.preventDefault();
h.stopPropagation();

if(margincolor2 === toggleableColorIdsMl[0]) {} else {resetlegend (); colormap3 (); nomenu (); xMarginColorstatus = 1; xMarginColorreset = 1; xMarginResetstatus = 1}
}
var layerscolorMh = document.getElementById('colorMhmenu');
if (xColorMhstatus > 1) {} else
{layerscolorMh.appendChild(linkcolorMh)}}
}
}
var layerscolorMl = document.getElementById('colorMlmenu');
if (xColorMlstatus > 1) {} else
{layerscolorMl.appendChild(linkcolorMl)}}
}
}
else {resetlegend (); colormap2 (); nomenu (); xWinColorstatus = 1; xWinColorreset = 1; xWinResetstatus = 1}
}

function PopNUMcolorcheck () {if (PopNUMcolor1 === reds19) {PopNUMcolor1txt = 'Red'}
else if (PopNUMcolor1 === blues19) {PopNUMcolor1txt = 'Blue'}
else if (PopNUMcolor1 === greens19) {PopNUMcolor1txt = 'Green'}
else if (PopNUMcolor1 === yellows19) {PopNUMcolor1txt = 'Yellow'}
else if (PopNUMcolor1 === oranges19) {PopNUMcolor1txt = 'Orange'}
else if (PopNUMcolor1 === purples19) {PopNUMcolor1txt = 'Purple'}
else if (PopNUMcolor1 === teals19) {PopNUMcolor1txt = 'Teal'}
else if (PopNUMcolor1 === violets19) {PopNUMcolor1txt = 'Violet'}

if (PopNUMcolor2 === reds19) {PopNUMcolor2txt = 'Red'}
else if (PopNUMcolor2 === blues19) {PopNUMcolor2txt = 'Blue'}
else if (PopNUMcolor2 === greens19) {PopNUMcolor2txt = 'Green'}
else if (PopNUMcolor2 === yellows19) {PopNUMcolor2txt = 'Yellow'}
else if (PopNUMcolor2 === oranges19) {PopNUMcolor2txt = 'Orange'}
else if (PopNUMcolor2 === purples19) {PopNUMcolor2txt = 'Purple'}
else if (PopNUMcolor2 === teals19) {PopNUMcolor2txt = 'Teal'}
else if (PopNUMcolor2 === violets19) {PopNUMcolor2txt = 'Violet'}}

// Start of Menus & Submaps
for (var i = 0; i < toggleableLayerIdsMain.length; i++) {
var id = toggleableLayerIdsMain[i];
var Names = toggleableLayerNamesMain[i];
if(id === ''){} else {var link = document.createElement('a')};
if(id === ''){} else {link.href = '#'};
if(id === ''){} else {link.className = 'active'};
if(Names !== toggleableLayerNamesMain[1]) {link.className = ''};
if(id === toggleableLayerIdsMain[0]) {link.className = 'header'};
if(cellphone === 'N') {if(id === 'Legend') {link.className = 'legend'}; let popup = ''};
if(id === layerTog1) {link.className ='county'};
if(id === layerTog2) {if(Tog2Visibility === 'visible'){link.className = 'county'} else {link.className =''}};
if(id === layerTog3) {link.className =''}
if(id === 'Color') {link.className = 'activecolor'}
if(id === 'Isolate') {link.className = 'isolate'; link.background = '##FFFF00'}
if(id === '') {} else {link.shortcut = id};
if(id === '') {} else {link.textContent = Names};
link.onclick = function (e) {
clickedLayerMainMenu = this.shortcut;
clickedName = this.textContent
var current = document.getElementsByClassName('active');
if (clickedLayerMainMenu === toggleableLayerIdsMain [0]) {} else if (clickedLayerMainMenu === layerTog3) {} else if (clickedLayerMainMenu === layerTog1) {} else if (clickedLayerMainMenu === layerTog2) {} else if (clickedLayerMainMenu === 'Legend') {} else if (clickedLayerMainMenu === 'Color') {} else if (clickedLayerMainMenu === 'Isolate') {} else if (current[0].className === 'active') current[0].className = current[0].className.replace('active')
if (clickedLayerMainMenu === toggleableLayerIdsMain [0]) {} else if (clickedLayerMainMenu === layerTog3) {} else if (clickedLayerMainMenu === layerTog2) {} else if (clickedLayerMainMenu === layerTog1) {} else if (clickedLayerMainMenu === 'Legend') {} else if (clickedLayerMainMenu === 'Color') {} else if (clickedLayerMainMenu === 'Isolate') {} else {this.className = 'active'};
e.preventDefault ();
e.stopPropagation();
if (clickedLayerMainMenu === toggleableLayerIdsMain[0]){}
if (layerTog1 === '') {} else {if (clickedLayerMainMenu === layerTog1)
{var visibility = map.getLayoutProperty(layerTog1, 'visibility');
if (visibility === 'visible') {
map.setLayoutProperty(layerTog1, 'visibility', 'none');
this.className = '';
} else {
this.className = 'county';
map.setLayoutProperty(layerTog1, 'visibility', 'visible')}
}}
if (layerTog2 === '') {} else {if (clickedLayerMainMenu === layerTog2)
{var visibility = map.getLayoutProperty(layerTog2, 'visibility');

if (visibility === 'visible') {
map.setLayoutProperty(layerTog2, 'visibility', 'none');
this.className = '';
} else {
this.className = 'tog2';
map.setLayoutProperty(layerTog2, 'visibility', 'visible')}
}}
if (layerTog3 === '') {} else {if (clickedLayerMainMenu === layerTog3)
{var Tog3linecolor = map.getPaintProperty(layer[1], 'fill-outline-color');

if (Tog3linecolor === '#ffffff') {
map.setPaintProperty(layer[1], 'fill-outline-color', Multi[1]);
this.className = '';
} else {
this.className = 'county';
map.setPaintProperty(layer[1], 'fill-outline-color', '#ffffff')}
}}
if (clickedLayerMainMenu === 'Legend')
{
if (legendstatus[0].style.display === 'none') {
this.className = 'legend';
desktopLabel ();
colorchange ();
map.off('click',chosenlayer,mobiletext)
legendstatus[0].style.display = 'block';
if (mh.matches) {legendstatus[0].style.left = '70px';
legendstatus[0].style.top = '10px';}
if (mq.matches) {legendstatus[0].style.top = '50px';
legendstatus[0].style.left = '10px'}
} else {
this.className = '';
mobilepopup ();
legendstatus[0].style.display = 'none';
legendstatus[0].style.left = '10px';
legendstatus[0].style.top = '10px';}
}
if (clickedLayerMainMenu === 'Color') {
xColorstatus ++
var toggleableColorIds = ['Color','cinyc','JMC','Atlas','ReverseAtlas'];
var toggleableColorNames = ['Color','cinyc','JMC','Atlas','Rev Atlas'];
for (k = 0; k < toggleableColorIds.length; k++) {
var idcolor = toggleableColorIds[k];
var Namescolor = toggleableColorNames[k];
var linkcolor = document.createElement('a');
linkcolor.href = '#';
linkcolor.className = 'activecolorAmenu';
if(idcolor !== WinColors) {linkcolor.className = ''}
if(idcolor === toggleableColorIds[0]) {linkcolor.className = 'headercolorAmenu'}
if(idcolor === WinColors) {linkcolor.className = 'activecolorAmenu'}
linkcolor.shortcut = idcolor;
linkcolor.textContent = Namescolor;
colorAmenu.style.display = 'block';
linkcolor.onclick = function (f) {
WinColors = this.shortcut;
WinColorsNames = this.textContent;
var currentcolor = document.getElementsByClassName('activecolorAmenu');
if (WinColors === toggleableColorIds[0]) {} else if (currentcolor[0].className === 'activecolorAmenu') {currentcolor[0].className = currentcolor[0].className.replace('activecolorAmenu','')};
if (WinColors === toggleableColorIds[0]) {} else {this.className = 'activecolorAmenu'};
f.preventDefault();
f.stopPropagation();
if(WinColors === toggleableColorIds[0]) {} else {choosecolor ()}
}
var layerscolor = document.getElementById('colorAmenu');
if (xColorstatus > 1) {} else
{layerscolor.appendChild(linkcolor)}
}
}
if (clickedLayerMainMenu === 'Isolate') {if(relevantColor === 'Wincode') {{if (xWinColorstatus === 1){
for (i=0; i<12; i++) {
Wincolor2[i] = greens[i];
Wincolor3[i] = blues[i];
Wincolor4[i] = yellows[i];
Wincolor5[i] = oranges[i];
Wincolor6[i] = purples[i];
Wincolor7[i] = teals[i];
Wincolor8[i] = violets[i];
if(Wincolor1txt === 'Red') Wincolor1[i] = reds[i];
if(Wincolor1txt === 'Blue') Wincolor1[i] = blues[i];
if(Wincolor1txt === 'Green') Wincolor1[i] = greens[i];
if(Wincolor1txt === 'Yellow') Wincolor1[i] = yellows[i];
if(Wincolor1txt === 'Orange') Wincolor1[i] = oranges[i];
if(Wincolor1txt === 'Purple') Wincolor1[i] = purples[i];
if(Wincolor1txt === 'Teal') Wincolor1[i] = teals[i];
if(Wincolor1txt === 'Violet') Wincolor1[i] = violets[i];
}}}
xWinColorstatus = 0
xIsolatestatus ++
var toggleableIsolateIds = ['Color',1,2,3,4,5,6,7,8,9,10,11,12,'Done','Reset'];
var toggleableIsolateNames = ['Color',
'0 to '+ Math.round(((0.01*colorscale)+startwincode/100)*100),
Math.round(((0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.02*colorscale)+startwincode/100)*100),
Math.round(((0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.03*colorscale)+startwincode/100)*100),
Math.round(((0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.04*colorscale)+startwincode/100)*100),
Math.round(((0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.05*colorscale)+startwincode/100)*100),
Math.round(((0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.06*colorscale)+startwincode/100)*100),
Math.round(((0.06*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.07*colorscale)+startwincode/100)*100),
Math.round(((0.07*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.08*colorscale)+startwincode/100)*100),
Math.round(((0.08*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.09*colorscale)+startwincode/100)*100),
Math.round(((0.09*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.10*colorscale)+startwincode/100)*100),
Math.round(((0.10*colorscale)+startwincode/100)*100),
'Tie','Done','Reset'];
for (k = 0; k < toggleableIsolateIds.length; k++) {
idisolate = toggleableIsolateIds[k];
Namesisolate = toggleableIsolateNames[k];
linkisolate = document.createElement('a');
linkisolate.href = '#';
if (xWinColorreset === 1) {Winstatus1[k] = 1}
if (Winstatus1[k] === 0) {linkisolate.className = 'old'; linkisolate.style.background = '#ffffff'; linkisolate.style.color = '#000000'}
else {linkisolate.className = 'activeisolatemenu'; Winstatus1[k]=1; linkisolate.style.background = Wincolor1[idisolate]; if(idisolate<7) {linkisolate.style.color = '#000000'}}
if(idisolate === 'Color') {linkisolate.className = 'headerisolatemenu'}
if(idisolate === 'Done') {linkisolate.className = 'headerisolatemenu'}
if(idisolate === 'Reset') {linkisolate.className = 'headerisolatemenu'}
if(idisolate === 12) {linkisolate.className = 'activeisolatemenu'; linkisolate.style.background = '#c0c0c0'}
//if(idisolate === WinIsolates) {linkisolate.className = 'activeisolatemenu'}
linkisolate.shortcut = idisolate;
linkisolate.textContent = Namesisolate;
isolatemenu.style.display = 'block';
linkisolate.onclick = function (g) {
xWinColorreset = 0
WinIsolates = this.shortcut;
WinIsolateNames = this.textContent;
if (WinIsolates === 'Color') {}
else if (WinIsolates === 'Done') {xWinResetstatus = 0; nomenu ()}
else if (WinIsolates === 'Reset') {for (p = 0; p<12; p++) {firstcolor[p] = Wincolor1[p]
secondcolor[p] = greens[p]
thirdcolor[p] = blues[p]
fourthcolor[p] = yellows[p]
fifthcolor[p] = oranges[p]
sixthcolor[p] = purples[p]
seventhcolor[p] = teals[p]
eighthcolor[p] = violets[p]}
for (o = 0; o <toggleableIsolateIds.length; o++) {
Winstatus1[o] = 1;
idisolate = toggleableIsolateIds[o];
Namesisolate = toggleableIsolateNames[o];
linkisolate = document.createElement('a');
linkisolate.href = '#';
linkisolate.className = 'activeisolatemenu'
if(idisolate === 'Color') {linkisolate.className = 'headerisolatemenu'}
if(idisolate === 'Done') {linkisolate.className = 'headerisolatemenu'}
if(idisolate === 'Reset') {linkisolate.className = 'headerisolatemenu'}}
xWinResetstatus = 2;
xWinColorstatus = 1;
choosecolor ()
xWinResetstatus = 1}
if (WinIsolates === 12) {
if (Winstatus1[WinIsolates] === 1) {this.className = 'old'; this.style.background = '#ffffff'; this.style.color = '#000000';
tie = reds[0]; Winstatus1[WinIsolates]=0
}
else {this.className = 'activeisolatemenu';
tie = '#c0c0c0';
this.style.background = '#c0c0c0'; this.style.color = '#000000'; Winstatus1[WinIsolates]=1}
}
else {if (Winstatus1[WinIsolates] === 1) {this.className = 'old'; this.style.background = '#ffffff'; this.style.color = '#000000';
firstcolor[WinIsolates] = reds[0];
secondcolor[WinIsolates] = greens[0];
thirdcolor[WinIsolates] = blues[0];
fourthcolor[WinIsolates] = yellows[0];
fifthcolor[WinIsolates] = oranges[0];
sixthcolor[WinIsolates] = purples[0];
seventhcolor[WinIsolates] = teals[0];
eighthcolor[WinIsolates] = violets[0];
Winstatus1[WinIsolates]=0;
}
else {if (Winstatus1[WinIsolates] === 0) {this.className = 'activeisolatemenu';
firstcolor[WinIsolates] = Wincolor1[WinIsolates];
secondcolor[WinIsolates] = Wincolor2[WinIsolates];
thirdcolor[WinIsolates] = Wincolor3[WinIsolates];
fourthcolor[WinIsolates] = Wincolor4[WinIsolates];
fifthcolor[WinIsolates] = Wincolor5[WinIsolates];
sixthcolor[WinIsolates] = Wincolor6[WinIsolates];
seventhcolor[WinIsolates] = Wincolor7[WinIsolates];
eighthcolor[WinIsolates] = Wincolor8[WinIsolates];
Winstatus1[WinIsolates]=1;
this.style.background = Wincolor1[WinIsolates];
if(WinIsolates>6) {this.style.color = '#ffffff'}
}
}
}
g.preventDefault();
g.stopPropagation();

if(WinIsolates === 'Color') {} else {colormap2()}
}
var layersisolate = document.getElementById('isolatemenu');
if (xIsolatestatus > 1) {if (xWinResetstatus === 0) {} else {layersisolate.removeChild(layersisolate.firstChild); layersisolate.appendChild(linkisolate);}}
else {layersisolate.appendChild(linkisolate)}
}
}
else if(relevantColor === 'JMCWincode') {if (xJMCColorstatus === 1){
for (i=0; i<12; i++) {
JMCcolor2[i] = blues[i]
JMCcolor3[i] = reds[i]
JMCcolor4[i] = greens[i]
JMCcolor5[i] = oranges[i]
JMCcolor6[i] = yellows[i]
JMCcolor7[i] = purples[i]
JMCcolor8[i] = teals[i]
if(JMCcolor1txt === 'Red') JMCcolor1[i] = reds[i];
if(JMCcolor1txt === 'Blue') JMCcolor1[i] = blues[i];
if(JMCcolor1txt === 'Green') JMCcolor1[i] = greens[i];
if(JMCcolor1txt === 'Yellow') JMCcolor1[i] = yellows[i];
if(JMCcolor1txt === 'Orange') JMCcolor1[i] = oranges[i];
if(JMCcolor1txt === 'Purple') JMCcolor1[i] = purples[i];
if(JMCcolor1txt === 'Teal') JMCcolor1[i] = teals[i];
if(JMCcolor1txt === 'Violet') JMCcolor1[i] = violets[i];
}}
xJMCIsolatestatus ++
xJMCColorstatus = 0
var toggleableJMCisolateIds = ['Color',1,2,3,4,5,6,7,8,9,10,11,12,'Done','Reset'];
var toggleableJMCisolateNames = ['Color',
'0 to '+ Math.round(((0.005*colorscale)+startwincode/100)*100),
Math.round(((0.005*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.01*colorscale)+startwincode/100)*100),
Math.round(((0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.02*colorscale)+startwincode/100)*100),
Math.round(((0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.03*colorscale)+startwincode/100)*100),
Math.round(((0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.04*colorscale)+startwincode/100)*100),
Math.round(((0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.05*colorscale)+startwincode/100)*100),
Math.round(((0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.06*colorscale)+startwincode/100)*100),
Math.round(((0.06*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.07*colorscale)+startwincode/100)*100),
Math.round(((0.07*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.08*colorscale)+startwincode/100)*100),
Math.round(((0.08*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.09*colorscale)+startwincode/100)*100),
Math.round(((0.09*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.10*colorscale)+startwincode/100)*100),
'Tie','Done','Reset'];
for (k = 0; k < toggleableJMCisolateIds.length; k++) {
idJMCisolate = toggleableJMCisolateIds[k];
NamesJMCisolate = toggleableJMCisolateNames[k];
linkJMCisolate = document.createElement('a');
linkJMCisolate.href = '#';
if (xJMCColorreset === 1) {JMCstatus1[k] = 1}
if (JMCstatus1[k] === 0) {linkJMCisolate.className = 'JMCold'; linkJMCisolate.style.background = '#ffffff'; linkJMCisolate.style.color = '#000000'}
else {linkJMCisolate.className = 'activeJMCisolatemenu'; JMCstatus1[k]=1; linkJMCisolate.style.background = JMCcolor1[idJMCisolate]; if(idJMCisolate<7) {linkJMCisolate.style.color = '#000000'}}
if(idJMCisolate === 'Color') {linkJMCisolate.className = 'headerJMCisolatemenu'}
if(idJMCisolate === 'Done') {linkJMCisolate.className = 'headerJMCisolatemenu'}
if(idJMCisolate === 'Reset') {linkJMCisolate.className = 'headerJMCisolatemenu'}
if(idJMCisolate === 12) {linkJMCisolate.className = 'activeJMCisolatemenu'; linkJMCisolate.style.background = '#c0c0c0'}
//if(idJMCisolate === WinJMCisolates) {linkJMCisolate.className = 'activeJMCisolatemenu'}
linkJMCisolate.shortcut = idJMCisolate;
linkJMCisolate.textContent = NamesJMCisolate;
JMCisolatemenu.style.display = 'block'
linkJMCisolate.onclick = function (h) {
xJMCColorreset = 0
WinJMCisolates = this.shortcut;
WinJMCisolateNames = this.textContent;
if (WinJMCisolates === 'Color') {}
else if (WinJMCisolates === 'Done'){xJMCResetstatus = 0; nomenu ()}
else if (WinJMCisolates === 'Reset') {for (p = 0; p<12; p++) {JMCfirstcolor[p] = JMCcolor1[p]
JMCsecondcolor[p] = blues[p]
JMCthirdcolor[p] = reds[p]
JMCfourthcolor[p] = greens[p]
JMCfifthcolor[p] = oranges[p]
JMCsixthcolor[p] = yellows[p]
JMCseventhcolor[p] = purples[p]
JMCeighthcolor[p] = teals[p]}
for (o = 0; o <toggleableJMCisolateIds.length; o++) {
JMCstatus1[o] = 1;
idJMCisolate = toggleableJMCisolateIds[o];
NamesJMCisolate = toggleableJMCisolateNames[o];
linkJMCisolate = document.createElement('a');
linkJMCisolate.href = '#';
linkJMCisolate.className = 'activeJMCisolatemenu'
if(idJMCisolate === 'Color') {linkJMCisolate.className = 'headerJMCisolatemenu'}
if(idJMCisolate === 'Done') {linkJMCisolate.className = 'headerJMCisolatemenu'}
if(idJMCisolate === 'Reset') {linkJMCisolate.className = 'headerJMCisolatemenu'}}
xJMCResetstatus = 2;
xJMCColorstatus = 1;
choosecolor ()
xJMCResetstatus = 1}

if (WinJMCisolates === 12) {
if (JMCstatus1[WinJMCisolates] === 1) {this.className = 'JMCold'; this.style.background = '#ffffff'; this.style.color = '#000000';
tie = reds[0]; JMCstatus1[WinJMCisolates]=0
}
else {this.className = 'activeisolatemenu';
tie = '#c0c0c0';
this.style.background = '#c0c0c0'; this.style.color = '#000000'; JMCstatus1[WinJMCisolates]=1}
}

else if (JMCstatus1[WinJMCisolates] === 1) {this.className = 'JMCold'; this.style.background = '#ffffff'; this.style.color = '#000000';
JMCfirstcolor[WinJMCisolates] = violets[0];
JMCsecondcolor[WinJMCisolates] = blues[0];
JMCthirdcolor[WinJMCisolates] = reds[0];
JMCfourthcolor[WinJMCisolates] = greens[0];
JMCfifthcolor[WinJMCisolates] = oranges[0];
JMCsixthcolor[WinJMCisolates] = yellows[0];
JMCseventhcolor[WinJMCisolates] = purples[0];
JMCeighthcolor[WinJMCisolates] = teals[0];
JMCstatus1[WinJMCisolates]=0
}
else {this.className = 'activeJMCisolatemenu';
JMCfirstcolor[WinJMCisolates] = JMCcolor1[WinJMCisolates];
JMCsecondcolor[WinJMCisolates] = JMCcolor2[WinJMCisolates];
JMCthirdcolor[WinJMCisolates] = JMCcolor3[WinJMCisolates];
JMCfourthcolor[WinJMCisolates] = JMCcolor4[WinJMCisolates];
JMCfifthcolor[WinJMCisolates] = JMCcolor5[WinJMCisolates];
JMCsixthcolor[WinJMCisolates] = JMCcolor6[WinJMCisolates];
JMCseventhcolor[WinJMCisolates] = JMCcolor7[WinJMCisolates];
JMCeighthcolor[WinJMCisolates] = JMCcolor8[WinJMCisolates];
JMCstatus1[WinJMCisolates]=1; this.style.background = JMCcolor1[WinJMCisolates]; if(WinJMCisolates>6) {this.style.color = '#ffffff'}}

h.preventDefault();
h.stopPropagation();

if(WinJMCisolates === 'Color') {} else {colormap5()}
}
var layersJMCisolate = document.getElementById('JMCisolatemenu');
if (xJMCIsolatestatus > 1) {if (xJMCResetstatus === 0) {} else {layersJMCisolate.removeChild(layersJMCisolate.firstChild); layersJMCisolate.appendChild(linkJMCisolate);}}
else {layersJMCisolate.appendChild(linkJMCisolate)}
}
}
else if(relevantColor === 'PopPCT') {{if (xPopPCTColorstatus === 1){
for (i=0; i<16; i++) {
if(PopPCTcolor1txt === 'Red') PCTcolor1[i] = reds15[i];
if(PopPCTcolor1txt === 'Blue') PCTcolor1[i] = blues15[i];
if(PopPCTcolor1txt === 'Green') PCTcolor1[i] = greens15[i];
if(PopPCTcolor1txt === 'Yellow') PCTcolor1[i] = yellows15[i];
if(PopPCTcolor1txt === 'Orange') PCTcolor1[i] = oranges15[i];
if(PopPCTcolor1txt === 'Purple') PCTcolor1[i] = purples15[i];
if(PopPCTcolor1txt === 'Teal') PCTcolor1[i] = teals15[i];
if(PopPCTcolor1txt === 'Violet') PCTcolor1[i] = violets15[i];
if(PopPCTcolor2txt === 'Red') PCTcolor2[i] = reds15[i];
if(PopPCTcolor2txt === 'Blue') PCTcolor2[i] = blues15[i];
if(PopPCTcolor2txt === 'Green') PCTcolor2[i] = greens15[i];
if(PopPCTcolor2txt === 'Yellow') PCTcolor2[i] = yellows15[i];
if(PopPCTcolor2txt === 'Orange') PCTcolor2[i] = oranges15[i];
if(PopPCTcolor2txt === 'Purple') PCTcolor2[i] = purples15[i];
if(PopPCTcolor2txt === 'Teal') PCTcolor2[i] = teals15[i];
if(PopPCTcolor2txt === 'Violet') PCTcolor2[i] = violets15[i];}}}
xPopPCTIsolatestatus ++
xPopPCTColorstatus = 0
PopPCTisolatemenu.style.display = 'block'
var toggleablePopPCTisolateIds = ['Color',15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,'Done','Reset'];
var toggleablePopPCTisolateNames = ['Color',
'<' + Math.round(((-0.13*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.13*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.12*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.12*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.11*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.11*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.10*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.10*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.09*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.09*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.08*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.08*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.07*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.07*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.06*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.06*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.05*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.05*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.04*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.04*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.03*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.03*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.02*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.02*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.01*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.01*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((-0.00000000000001*colorscale)+startwincode/100)*1000)/10,
Math.round(((-0.00000000000001*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0*colorscale)+startwincode/100)*1000)/10,
'Done','Reset']
for (k = 0; k < toggleablePopPCTisolateIds.length; k++) {
idPopPCTisolate = toggleablePopPCTisolateIds[k];
NamesPopPCTisolate = toggleablePopPCTisolateNames[k];
linkPopPCTisolate = document.createElement('a');
linkPopPCTisolate.href = '#';
if (xPopPCTColorreset === 1) {PCTstatus1[k] = 1}
if (PCTstatus1[k] === 0) {linkPopPCTisolate.className = 'PopPCTold'; linkPopPCTisolate.style.background = '#ffffff'; linkPopPCTisolate.style.color = '#000000'}
else {linkPopPCTisolate.className = 'activePopPCTisolatemenu'; PCTstatus1[k]=1; linkPopPCTisolate.style.background = PCTcolor1[idPopPCTisolate]; if(idPopPCTisolate<7) {linkPopPCTisolate.style.color = '#000000'}}
if(idPopPCTisolate === 'Color') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}

if(idPopPCTisolate === 'Done') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}

if(idPopPCTisolate === 'Reset') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}

//if(idPopPCTisolate === WinPopPCTisolates) {linkPopPCTisolate.className = 'activePopPCTisolatemenu'}
linkPopPCTisolate.shortcut = idPopPCTisolate;
linkPopPCTisolate.textContent = NamesPopPCTisolate;
linkPopPCTisolate.onclick = function (g) {
xPopPCTColorreset = 0
WinPopPCTisolates = this.shortcut;
WinPopPCTisolateNames = this.textContent;
if (WinPopPCTisolates === 'Color') {}
else if (WinPopPCTisolates === 'Done') {xPopPCTResetstatus = 0; nomenu ()}
else if (WinPopPCTisolates === 'Reset') {for (p = 0; p<16; p++) {PopPCTcolor1[p] = PCTcolor1[p]}
for (o = 0; o <toggleablePopPCTisolateIds.length; o++) {
PCTstatus1[o] = 1;
idPopPCTisolate = toggleablePopPCTisolateIds2[o];
NamesPopPCTisolate = toggleablePopPCTisolateNames2[o];
linkPopPCTisolate = document.createElement('a');
linkPopPCTisolate.href = '#';
linkPopPCTisolate.className = 'activePopPCTisolatemenu'
if(idPopPCTisolate === 'Color') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}
if(idPopPCTisolate === 'Done') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}
if(idPopPCTisolate === 'Reset') {linkPopPCTisolate.className = 'headerPopPCTisolatemenu'}}
xPopPCTResetstatus = 2;
xPopPCTColorstatus = 1;
choosecolor ()
xPopPCTResetstatus = 1}
else if (PCTstatus1[16-WinPopPCTisolates] === 1) {this.className = 'PopPCTold'; this.style.background = '#ffffff'; this.style.color = '#000000'
PopPCTcolor1[WinPopPCTisolates]=reds15[0]
PCTstatus1[16-WinPopPCTisolates]=0
}
else {this.className = 'activePopPCTisolatemenu'; PopPCTcolor1[WinPopPCTisolates] = PCTcolor1[WinPopPCTisolates]; PCTstatus1[16-WinPopPCTisolates]=1; this.style.background = PCTcolor1[WinPopPCTisolates]; if(WinPopPCTisolates>6) {this.style.color = '#ffffff'}}
g.preventDefault()
g.stopPropagation();

if(WinPopPCTisolates === 'Color') {} else {colormap6()}
}
var layersPopPCTisolate = document.getElementById('PopPCTisolatemenu');
if (xPopPCTIsolatestatus > 1) {if (xPopPCTResetstatus === 0) {} else {layersPopPCTisolate.removeChild(layersPopPCTisolate.firstChild); layersPopPCTisolate.appendChild(linkPopPCTisolate);}}
else {layersPopPCTisolate.appendChild(linkPopPCTisolate)}
}
xPopPCTIsolatestatus2 ++
PopPCTisolatemenu2.style.display = 'block'
var toggleablePopPCTisolateIds2 =['Color',1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,'Done','Reset']
var toggleablePopPCTisolateNames2 = ['Color',
Math.round(((0.*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.01*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.01*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.02*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.02*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.03*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.03*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.04*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.04*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.05*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.05*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.06*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.06*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.07*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.07*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.08*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.08*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.09*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.09*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.10*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.10*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.11*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.11*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.12*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.12*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.13*colorscale)+startwincode/100)*1000)/10,
Math.round(((0.13*colorscale)+startwincode/100)*1000)/10 + ' to ' + Math.round(((0.14*colorscale)+startwincode/100)*1000)/10,
'>' + Math.round(((0.14*colorscale)+startwincode/100)*1000)/10,
'Done','Reset'];
var layersPopPCTisolate2 = document.getElementById('PopPCTisolatemenu2');
for (l = 0; l < toggleablePopPCTisolateIds2.length; l++) {
idPopPCTisolate2 = toggleablePopPCTisolateIds2[l];
NamesPopPCTisolate2 = toggleablePopPCTisolateNames2[l];
linkPopPCTisolate2 = document.createElement('a');
linkPopPCTisolate2.href = '#';
if (xPopPCTColorreset === 1) {PCTstatus2[l] = 1}
if (PCTstatus2[l] === 0) {linkPopPCTisolate2.className = 'PopPCTold2'; linkPopPCTisolate2.style.background = '#ffffff'; linkPopPCTisolate2.style.color = '#000000'}
else {linkPopPCTisolate2.className = 'activePopPCTisolatemenu2'; PCTstatus2[l]=1; linkPopPCTisolate2.style.background = PCTcolor2[idPopPCTisolate2]; if(idPopPCTisolate2<7) {linkPopPCTisolate2.style.color = '#000000'}}
if(idPopPCTisolate2 === 'Color') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}
if(idPopPCTisolate2 === 'Done') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}
if(idPopPCTisolate2 === 'Reset') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}
//if(idPopPCTisolate === WinPopPCTisolates) {linkPopPCTisolate.className = 'activePopPCTisolatemenu'}
linkPopPCTisolate2.shortcut = idPopPCTisolate2;
linkPopPCTisolate2.textContent = NamesPopPCTisolate2;
linkPopPCTisolate2.onclick = function (h) {
xPopPCTColorreset = 0
WinPopPCTisolates2 = this.shortcut;
WinPopPCTisolateNames2 = this.textContent;
if (WinPopPCTisolates2 === 'Color') {}
else if (WinPopPCTisolates2 === 'Done') {xPopPCTResetstatus = 0; nomenu ()}
else if (WinPopPCTisolates2 === 'Reset') {for (n = 0; n<16; n++) {PopPCTcolor2[n] = PCTcolor2[n]}
for (m = 0; m <toggleablePopPCTisolateIds2.length; m++) {
PCTstatus2[m] = 1;
idPopPCTisolate2 = toggleablePopPCTisolateIds2[m];
NamesPopPCTisolate2 = toggleablePopPCTisolateNames2[m];
linkPopPCTisolate2 = document.createElement('a');
linkPopPCTisolate2.href = '#';
linkPopPCTisolate2.className = 'activePopPCTisolatemenu2'
if(idPopPCTisolate2 === 'Color') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}
if(idPopPCTisolate2 === 'Done') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}
if(idPopPCTisolate2 === 'Reset') {linkPopPCTisolate2.className = 'headerPopPCTisolatemenu2'}}
PopPCTisolateclicks2 = 0;
xPopPCTResetstatus = 2;
choosecolor ()
xPopPCTResetstatus = 1}
else if (this.className === 'activePopPCTisolatemenu2') {this.className = 'PopPCTold2'; this.style.background = '#ffffff'; this.style.color = '#000000'
PopPCTcolor2[WinPopPCTisolates2] =reds15[0];
PCTstatus2[WinPopPCTisolates2]=0
}
else {this.className = 'activePopPCTisolatemenu2'; PopPCTcolor2[WinPopPCTisolates2] = PCTcolor2[WinPopPCTisolates2]; PCTstatus2[WinPopPCTisolates2]=1;
this.style.background = PCTcolor2[WinPopPCTisolates2]; if(WinPopPCTisolates2>6) {this.style.color = '#ffffff'}}
h.preventDefault();
h.stopPropagation();

if(WinPopPCTisolates2 === 'Color') {} else if (WinPopPCTisolates2 === 'Done') {} else if (WinPopPCTisolates2 === 'Reset') {} else {colormap6()}
}
//var layersPopPCTisolate2 = document.getElementById('PopPCTisolatemenu2');
if (xPopPCTIsolatestatus2 > 1) {if (xPopPCTResetstatus === 0) {} else {layersPopPCTisolate2.removeChild(layersPopPCTisolate2.firstChild); layersPopPCTisolate2.appendChild(linkPopPCTisolate2)}}
else {layersPopPCTisolate2.appendChild(linkPopPCTisolate2)}
}
}
else if(relevantColor === 'PopNUM') {{if (xPopNUMColorstatus === 1){
for (i=0; i<20; i++) {
if(PopNUMcolor1txt === 'Red') NUMcolor1[i] = reds19[i];
if(PopNUMcolor1txt === 'Blue') NUMcolor1[i] = blues19[i];
if(PopNUMcolor1txt === 'Green') NUMcolor1[i] = greens19[i];
if(PopNUMcolor1txt === 'Yellow') NUMcolor1[i] = yellows19[i];
if(PopNUMcolor1txt === 'Orange') NUMcolor1[i] = oranges19[i];
if(PopNUMcolor1txt === 'Purple') NUMcolor1[i] = purples19[i];
if(PopNUMcolor1txt === 'Teal') NUMcolor1[i] = teals19[i];
if(PopNUMcolor1txt === 'Violet') NUMcolor1[i] = violets19[i];
if(PopNUMcolor2txt === 'Red') NUMcolor2[i] = reds19[i];
if(PopNUMcolor2txt === 'Blue') NUMcolor2[i] = blues19[i];
if(PopNUMcolor2txt === 'Green') NUMcolor2[i] = greens19[i];
if(PopNUMcolor2txt === 'Yellow') NUMcolor2[i] = yellows19[i];
if(PopNUMcolor2txt === 'Orange') NUMcolor2[i] = oranges19[i];
if(PopNUMcolor2txt === 'Purple') NUMcolor2[i] = purples19[i];
if(PopNUMcolor2txt === 'Teal') NUMcolor2[i] = teals19[i];
if(PopNUMcolor2txt === 'Violet') NUMcolor2[i] = violets19[i];}}}
xPopNUMIsolatestatus ++
xPopNUMColorstatus = 0
PopNUMisolatemenu.style.display = 'block'
var toggleablePopNUMisolateIds = ['Color',19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,'Done','Reset'];
var toggleablePopNUMisolateNames = ['Color',
'<' + Math.round((-200*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-200*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-100*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-100*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-50*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-50*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-20*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-20*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-14*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-14*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-13*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-13*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-12*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-12*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-11*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-11*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-10*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-10*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-9*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-9*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-8*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-8*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-7*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-7*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-6*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-6*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-5*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-5*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-4*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-4*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-3*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-3*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-2*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-2*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((-1*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((-1*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((0*colorscale/100000+startwincode)*1000)/10 + 'K',
'Done','Reset'];
for (k = 0; k < toggleablePopNUMisolateIds.length; k++) {
idPopNUMisolate = toggleablePopNUMisolateIds[k];
NamesPopNUMisolate = toggleablePopNUMisolateNames[k];
linkPopNUMisolate = document.createElement('a');
linkPopNUMisolate.href = '#';
if (xPopNUMColorreset === 1) {NUMstatus1[k] = 1}
if (NUMstatus1[k] === 0) {linkPopNUMisolate.className = 'PopNUMold'; linkPopNUMisolate.style.background = '#ffffff'; linkPopNUMisolate.style.color = '#000000'}
else {linkPopNUMisolate.className = 'activePopNUMisolatemenu'; NUMstatus1[k]=1; linkPopNUMisolate.style.background = NUMcolor1[idPopNUMisolate]; if(idPopNUMisolate<9) {linkPopNUMisolate.style.color = '#000000'}}
if(idPopNUMisolate === 'Color') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}

if(idPopNUMisolate === 'Done') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}

if(idPopNUMisolate === 'Reset') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}

//if(idPopNUMisolate === WinPopNUMisolates) {linkPopNUMisolate.className = 'activePopNUMisolatemenu'}
linkPopNUMisolate.shortcut = idPopNUMisolate;
linkPopNUMisolate.textContent = NamesPopNUMisolate;
linkPopNUMisolate.onclick = function (g) {
xPopNUMColorreset = 0
WinPopNUMisolates = this.shortcut;
WinPopNUMisolateNames = this.textContent;
if (WinPopNUMisolates === 'Color') {}
else if (WinPopNUMisolates === 'Done') {xPopNUMResetstatus = 0; nomenu ()}
else if (WinPopNUMisolates === 'Reset') {for (p = 0; p<20; p++) {PopNUMcolor1[p] = NUMcolor1[p]}
for (o = 0; o <toggleablePopNUMisolateIds.length; o++) {
NUMstatus1[o] = 1;
idPopNUMisolate = toggleablePopNUMisolateIds2[o];
NamesPopNUMisolate = toggleablePopNUMisolateNames2[o];
linkPopNUMisolate = document.createElement('a');
linkPopNUMisolate.href = '#';
linkPopNUMisolate.className = 'activePopNUMisolatemenu'
if(idPopNUMisolate === 'Color') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}
if(idPopNUMisolate === 'Done') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}
if(idPopNUMisolate === 'Reset') {linkPopNUMisolate.className = 'headerPopNUMisolatemenu'}}
xPopNUMResetstatus = 2;
xPopNUMColorstatus = 1;
choosecolor ()
xPopNUMResetstatus = 1}
else if (NUMstatus1[20-WinPopNUMisolates] === 1) {this.className = 'PopNUMold'; this.style.background = '#ffffff'; this.style.color = '#000000'
PopNUMcolor1[WinPopNUMisolates]=reds19[0]
NUMstatus1[20-WinPopNUMisolates]=0
}
else {this.className = 'activePopNUMisolatemenu'; PopNUMcolor1[WinPopNUMisolates] = NUMcolor1[WinPopNUMisolates]; NUMstatus1[20-WinPopNUMisolates]=1; this.style.background = NUMcolor1[WinPopNUMisolates]; if(WinPopNUMisolates>8) {this.style.color = '#ffffff'}}
g.preventDefault()
g.stopPropagation();

if(WinPopNUMisolates === 'Color') {} else {colormap7()}
}
var layersPopNUMisolate = document.getElementById('PopNUMisolatemenu');
if (xPopNUMIsolatestatus > 1) {if (xPopNUMResetstatus === 0) {} else {layersPopNUMisolate.removeChild(layersPopNUMisolate.firstChild); layersPopNUMisolate.appendChild(linkPopNUMisolate);}}
else {layersPopNUMisolate.appendChild(linkPopNUMisolate)}
}
xPopNUMIsolatestatus2 ++
PopNUMisolatemenu2.style.display = 'block'
var toggleablePopNUMisolateIds2 = ['Color',1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,'Done','Reset'];
var toggleablePopNUMisolateNames2 = ['Color',
Math.round(startwincode*1000)/10 + 'K to ' + Math.round((1*colorscale)/100000+startwincode*1000)/10 + 'K',
Math.round((1*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((2*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((2*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((3*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((3*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((4*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((4*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((5*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((5*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((6*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((6*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((7*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((7*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((8*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((8*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((9*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((9*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((10*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((10*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((11*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((11*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((12*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((12*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((13*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((13*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((14*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((14*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((20*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((20*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((50*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((50*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((100*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((100*colorscale/100000+startwincode)*1000)/10 + 'K to ' + Math.round((200*colorscale/100000+startwincode)*1000)/10 + 'K',
Math.round((200*colorscale/100000+startwincode)*1000)/10 +'K+',
'Done','Reset'];
var layersPopNUMisolate2 = document.getElementById('PopNUMisolatemenu2');
for (l = 0; l < toggleablePopNUMisolateIds2.length; l++) {
idPopNUMisolate2 = toggleablePopNUMisolateIds2[l];
NamesPopNUMisolate2 = toggleablePopNUMisolateNames2[l];
linkPopNUMisolate2 = document.createElement('a');
linkPopNUMisolate2.href = '#';
if (xPopNUMColorreset === 1) {NUMstatus2[l] = 1}
if (NUMstatus2[l] === 0) {linkPopNUMisolate2.className = 'PopNUMold2'; linkPopNUMisolate2.style.background = '#ffffff'; linkPopNUMisolate2.style.color = '#000000'}
else {linkPopNUMisolate2.className = 'activePopNUMisolatemenu2'; NUMstatus2[l]=1; linkPopNUMisolate2.style.background = NUMcolor2[idPopNUMisolate2]; if(idPopNUMisolate2<9) {linkPopNUMisolate2.style.color = '#000000'}}
if(idPopNUMisolate2 === 'Color') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}
if(idPopNUMisolate2 === 'Done') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}
if(idPopNUMisolate2 === 'Reset') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}
//if(idPopNUMisolate === WinPopNUMisolates) {linkPopNUMisolate.className = 'activePopNUMisolatemenu'}
linkPopNUMisolate2.shortcut = idPopNUMisolate2;
linkPopNUMisolate2.textContent = NamesPopNUMisolate2;
linkPopNUMisolate2.onclick = function (h) {
xPopNUMColorreset = 0
WinPopNUMisolates2 = this.shortcut;
WinPopNUMisolateNames2 = this.textContent;
if (WinPopNUMisolates2 === 'Color') {}
else if (WinPopNUMisolates2 === 'Done') {xPopNUMResetstatus = 0; nomenu ()}
else if (WinPopNUMisolates2 === 'Reset') {for (n = 0; n<20; n++) {PopNUMcolor2[n] = NUMcolor2[n]}
for (m = 0; m <toggleablePopNUMisolateIds2.length; m++) {
NUMstatus2[m] = 1;
idPopNUMisolate2 = toggleablePopNUMisolateIds2[m];
NamesPopNUMisolate2 = toggleablePopNUMisolateNames2[m];
linkPopNUMisolate2 = document.createElement('a');
linkPopNUMisolate2.href = '#';
linkPopNUMisolate2.className = 'activePopNUMisolatemenu2'
if(idPopNUMisolate2 === 'Color') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}
if(idPopNUMisolate2 === 'Done') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}
if(idPopNUMisolate2 === 'Reset') {linkPopNUMisolate2.className = 'headerPopNUMisolatemenu2'}}
xPopNUMResetstatus = 2;
choosecolor ()
xPopNUMResetstatus = 1}
else if (this.className === 'activePopNUMisolatemenu2') {this.className = 'PopNUMold2'; this.style.background = '#ffffff'; this.style.color = '#000000'
PopNUMcolor2[WinPopNUMisolates2] =reds19[0];
NUMstatus2[WinPopNUMisolates2]=0
}
else {this.className = 'activePopNUMisolatemenu2'; PopNUMcolor2[WinPopNUMisolates2] = NUMcolor2[WinPopNUMisolates2]; NUMstatus2[WinPopNUMisolates2]=1;
this.style.background = NUMcolor2[WinPopNUMisolates2]; if(WinPopNUMisolates2>5) {this.style.color = '#ffffff'}}
h.preventDefault();
h.stopPropagation();

if(WinPopNUMisolates2 === 'Color') {} else if (WinPopNUMisolates2 === 'Done') {} else if (WinPopNUMisolates2 === 'Reset') {} else {colormap7()}
}
//var layersPopNUMisolate2 = document.getElementById('PopNUMisolatemenu2');
if (xPopNUMIsolatestatus2 > 1) {if (xPopNUMResetstatus === 0) {} else {layersPopNUMisolate2.removeChild(layersPopNUMisolate2.firstChild); layersPopNUMisolate2.appendChild(linkPopNUMisolate2)}}
else {layersPopNUMisolate2.appendChild(linkPopNUMisolate2)}
}
}
else if(relevantColor === 'Margin') {if (xMarginColorstatus === 1){
for (i=0; i<12; i++) {
if(margincolor1txt === 'Red') Margincolor1[i] = reds[i];
if(margincolor1txt === 'Blue') Margincolor1[i] = blues[i];
if(margincolor1txt === 'Green') Margincolor1[i] = greens[i];
if(margincolor1txt === 'Yellow') Margincolor1[i] = yellows[i];
if(margincolor1txt === 'Orange') Margincolor1[i] = oranges[i];
if(margincolor1txt === 'Purple') Margincolor1[i] = purples[i];
if(margincolor1txt === 'Teal') Margincolor1[i] = teals[i];
if(margincolor1txt === 'Violet') Margincolor1[i] = violets[i];
if(margincolor2txt === 'Red') Margincolor2[i] = reds[i];
if(margincolor2txt === 'Blue') Margincolor2[i] = blues[i];
if(margincolor2txt === 'Green') Margincolor2[i] = greens[i];
if(margincolor2txt === 'Yellow') Margincolor2[i] = yellows[i];
if(margincolor2txt === 'Orange') Margincolor2[i] = oranges[i];
if(margincolor2txt === 'Purple') Margincolor2[i] = purples[i];
if(margincolor2txt === 'Teal') Margincolor2[i] = teals[i];
if(margincolor2txt === 'Violet') Margincolor2[i] = violets[i];}}
xMarginColorstatus = 0
Marginisolatemenu.style.display = 'block'
xMarginIsolatestatus ++
var toggleableMarginisolateIds = ['Color',11,10,9,8,7,6,5,4,3,2,1,'Done','Reset']
var toggleableMarginisolateNames = ['Color',
'< '+ Math.round(((-0.09*colorscale)+startwincode/100)*100),
Math.round(((-0.09*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.08*colorscale)+startwincode/100)*100),
Math.round(((-0.08*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.07*colorscale)+startwincode/100)*100),
Math.round(((-0.07*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.06*colorscale)+startwincode/100)*100),
Math.round(((-0.06*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.05*colorscale)+startwincode/100)*100),
Math.round(((-0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.04*colorscale)+startwincode/100)*100),
Math.round(((-0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.03*colorscale)+startwincode/100)*100),
Math.round(((-0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.02*colorscale)+startwincode/100)*100),
Math.round(((-0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.01*colorscale)+startwincode/100)*100),
Math.round(((-0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.00000000000001*colorscale)+startwincode/100)*100),
Math.round(((-0.00000000000001*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0*colorscale)+startwincode/100)*100),'Done','Reset']
for (k = 0; k < toggleableMarginisolateIds.length; k++) {
idMarginisolate = toggleableMarginisolateIds[k];
NamesMarginisolate = toggleableMarginisolateNames[k];
linkMarginisolate = document.createElement('a');
linkMarginisolate.href = '#';
if (xMarginColorreset === 1) {Marginstatus1[k] = 1}
if (Marginstatus1[k] === 0) {linkMarginisolate.className = 'Marginold'; linkMarginisolate.style.background = '#ffffff'; linkMarginisolate.style.color = '#000000'}
else {linkMarginisolate.className = 'activeMarginisolatemenu'; Marginstatus1[k]=1; linkMarginisolate.style.background = Margincolor1[idMarginisolate]; if(idMarginisolate<6) {linkMarginisolate.style.color = '#000000'}}
if(idMarginisolate === 'Color') {linkMarginisolate.className = 'headerMarginisolatemenu'}

if(idMarginisolate === 'Done') {linkMarginisolate.className = 'headerMarginisolatemenu'}

if(idMarginisolate === 'Reset') {linkMarginisolate.className = 'headerMarginisolatemenu'}

//if(idMarginisolate === WinMarginisolates) {linkMarginisolate.className = 'activeMarginisolatemenu'}
linkMarginisolate.shortcut = idMarginisolate;
linkMarginisolate.textContent = NamesMarginisolate;
linkMarginisolate.onclick = function (g) {
xMarginColorreset = 0
WinMarginisolates = this.shortcut;
WinMarginisolateNames = this.textContent;
if (WinMarginisolates === 'Color') {}
else if (WinMarginisolates === 'Done') {xMarginResetstatus = 0; nomenu ()}
else if (WinMarginisolates === 'Reset') {for (p = 0; p<12; p++) {margincolor1[p] = Margincolor1[p]}
for (o = 0; o <toggleableMarginisolateIds.length; o++) {
Marginstatus1[o] = 1;
idMarginisolate = toggleableMarginisolateIds2[o];
NamesMarginisolate = toggleableMarginisolateNames2[o];
linkMarginisolate = document.createElement('a');
linkMarginisolate.href = '#';
linkMarginisolate.className = 'activeMarginisolatemenu'
if(idMarginisolate === 'Color') {linkMarginisolate.className = 'headerMarginisolatemenu'}
if(idMarginisolate === 'Done') {linkMarginisolate.className = 'headerMarginisolatemenu'}
if(idMarginisolate === 'Reset') {linkMarginisolate.className = 'headerMarginisolatemenu'}}
xMarginResetstatus = 2;
xMarginColorstatus = 1;
choosecolor ()
xMarginResetstatus = 1}
else if (Marginstatus1[12-WinMarginisolates] === 1) {this.className = 'Marginold'; this.style.background = '#ffffff'; this.style.color = '#000000'
margincolor1[WinMarginisolates]=reds7[0]
Marginstatus1[12-WinMarginisolates]=0
}
else {this.className = 'activeMarginisolatemenu'; margincolor1[WinMarginisolates] = Margincolor1[WinMarginisolates]; Marginstatus1[12-WinMarginisolates]=1; this.style.background = Margincolor1[WinMarginisolates]; if(WinMarginisolates>5) {this.style.color = '#ffffff'}}
g.preventDefault()
g.stopPropagation();

if(WinMarginisolates === 'Color') {} else {colormap3()}
}
var layersMarginisolate = document.getElementById('Marginisolatemenu');
if (xMarginIsolatestatus > 1) {if (xMarginResetstatus === 0) {} else {layersMarginisolate.removeChild(layersMarginisolate.firstChild); layersMarginisolate.appendChild(linkMarginisolate)}}
else {layersMarginisolate.appendChild(linkMarginisolate)}
}
Marginisolatemenu2.style.display = 'block'
xMarginIsolatestatus2 ++
var toggleableMarginisolateIds2 = ['Color',1,2,3,4,5,6,7,8,9,10,11,'Done','Reset'];
var toggleableMarginisolateNames2 = ['Color',
Math.round(((0*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.01*colorscale)+startwincode/100)*100),
Math.round(((0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.02*colorscale)+startwincode/100)*100),
Math.round(((0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.03*colorscale)+startwincode/100)*100),
Math.round(((0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.04*colorscale)+startwincode/100)*100),
Math.round(((0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.05*colorscale)+startwincode/100)*100),
Math.round(((0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.06*colorscale)+startwincode/100)*100),
Math.round(((0.06*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.07*colorscale)+startwincode/100)*100),
Math.round(((0.07*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.08*colorscale)+startwincode/100)*100),
Math.round(((0.08*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.09*colorscale)+startwincode/100)*100),
Math.round(((0.09*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.10*colorscale)+startwincode/100)*100),
'>' + Math.round(((0.10*colorscale)+startwincode/100)*100),
'Done','Reset'];
var layersMarginisolate2 = document.getElementById('Marginisolatemenu2');
for (l = 0; l < toggleableMarginisolateIds2.length; l++) {
idMarginisolate2 = toggleableMarginisolateIds2[l];
NamesMarginisolate2 = toggleableMarginisolateNames2[l];
linkMarginisolate2 = document.createElement('a');
linkMarginisolate2.href = '#';
if (xMarginColorreset === 1) {Marginstatus2[l] = 1}
if (Marginstatus2[l] === 0) {linkMarginisolate2.className = 'Marginold2'; linkMarginisolate2.style.background = '#ffffff'; linkMarginisolate2.style.color = '#000000'}
else {linkMarginisolate2.className = 'activeMarginisolatemenu2'; Marginstatus2[l]=1; linkMarginisolate2.style.background = Margincolor2[idMarginisolate2]; if(idMarginisolate2<6) {linkMarginisolate2.style.color = '#000000'}}
if(idMarginisolate2 === 'Color') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}
if(idMarginisolate2 === 'Done') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}
if(idMarginisolate2 === 'Reset') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}
//if(idMarginisolate === WinMarginisolates) {linkMarginisolate.className = 'activeMarginisolatemenu'}
linkMarginisolate2.shortcut = idMarginisolate2;
linkMarginisolate2.textContent = NamesMarginisolate2;
linkMarginisolate2.onclick = function (h) {
xMarginColorreset = 0
WinMarginisolates2 = this.shortcut;
WinMarginisolateNames2 = this.textContent;
if (WinMarginisolates2 === 'Color') {}
else if (WinMarginisolates2 === 'Done') {xMarginResetstatus = 0; nomenu ()}
else if (WinMarginisolates2 === 'Reset') {for (n = 0; n<12; n++) {margincolor2[n] = Margincolor2[n]}
for (m = 0; m <toggleableMarginisolateIds2.length; m++) {
Marginstatus2[m] = 1;
idMarginisolate2 = toggleableMarginisolateIds2[m];
NamesMarginisolate2 = toggleableMarginisolateNames2[m];
linkMarginisolate2 = document.createElement('a');
linkMarginisolate2.href = '#';
linkMarginisolate2.className = 'activeMarginisolatemenu2'
if(idMarginisolate2 === 'Color') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}
if(idMarginisolate2 === 'Done') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}
if(idMarginisolate2 === 'Reset') {linkMarginisolate2.className = 'headerMarginisolatemenu2'}}
xMarginResetstatus = 2;
choosecolor ()
xMarginResetstatus = 1}
else if (this.className === 'activeMarginisolatemenu2') {this.className = 'Marginold2'; this.style.background = '#ffffff'; this.style.color = '#000000'
margincolor2[WinMarginisolates2] =reds[0];
Marginstatus2[WinMarginisolates2]=0
}
else {this.className = 'activeMarginisolatemenu2'; margincolor2[WinMarginisolates2] = Margincolor2[WinMarginisolates2]; Marginstatus2[WinMarginisolates2]=1;
this.style.background = Margincolor2[WinMarginisolates2]; if(WinMarginisolates2>5) {this.style.color = '#ffffff'}}
h.preventDefault();
h.stopPropagation();

if(WinMarginisolates2 === 'Color') {} else if (WinMarginisolates2 === 'Done') {} else if (WinMarginisolates2 === 'Reset') {} else {colormap3()}
}
//var layersMarginisolate2 = document.getElementById('Marginisolatemenu2');
if (xMarginIsolatestatus2 > 1) {if (xMarginResetstatus === 0) {} else {layersMarginisolate2.removeChild(layersMarginisolate2.firstChild); layersMarginisolate2.appendChild(linkMarginisolate2)}}
else {layersMarginisolate2.appendChild(linkMarginisolate2)}
}
}

else if(relevantColor === 'Margin7') {{if (xMargin7Colorstatus === 1){
for (i=0; i<8; i++) {
if(margincolor71txt === 'Red') Margin7color1[i] = reds7[i];
if(margincolor71txt === 'Blue') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Green') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Yellow') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Orange') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Purple') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Teal') Margin7color1[i] = blues7[i];
if(margincolor71txt === 'Violet') Margin7color1[i] = blues7[i];
if(margincolor72txt === 'Red') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Blue') Margin7color2[i] = blues7[i];
if(margincolor72txt === 'Green') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Yellow') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Orange') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Purple') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Teal') Margin7color2[i] = reds7[i];
if(margincolor72txt === 'Violet') Margin7color2[i] = reds7[i];}}}
xMargin7Colorstatus = 0
Margin7isolatemenu.style.display = 'block'
xMargin7Isolatestatus ++
var toggleableMargin7isolateIds = ['Color',7,6,5,4,3,2,1,'Done','Reset']
var toggleableMargin7isolateNames = ['Color',
'< '+ Math.round(((-0.05*colorscale)+startwincode/100)*100),
Math.round(((-0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.04*colorscale)+startwincode/100)*100),
Math.round(((-0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.03*colorscale)+startwincode/100)*100),
Math.round(((-0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.02*colorscale)+startwincode/100)*100),
Math.round(((-0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.01*colorscale)+startwincode/100)*100),
Math.round(((-0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((-0.00000000000001*colorscale)+startwincode/100)*100),
Math.round(((-0.00000000000001*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0*colorscale)+startwincode/100)*100),
'Done','Reset']
for (k = 0; k < toggleableMargin7isolateIds.length; k++) {
idMargin7isolate = toggleableMargin7isolateIds[k];
NamesMargin7isolate = toggleableMargin7isolateNames[k];
linkMargin7isolate = document.createElement('a');
linkMargin7isolate.href = '#';
if (xMargin7Colorreset === 1) {Margin7status1[k] = 1}
if (Margin7status1[k] === 0) {linkMargin7isolate.className = 'Margin7old'; linkMargin7isolate.style.background = '#ffffff'; linkMargin7isolate.style.color = '#000000'}
else {linkMargin7isolate.className = 'activeMargin7isolatemenu'; Margin7status1[k]=1; linkMargin7isolate.style.background = Margin7color1[idMargin7isolate]; if(idMargin7isolate<3) {linkMargin7isolate.style.color = '#000000'}}
if(idMargin7isolate === 'Color') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}

if(idMargin7isolate === 'Done') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}

if(idMargin7isolate === 'Reset') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}

//if(idMargin7isolate === WinMargin7isolates) {linkMargin7isolate.className = 'activeMargin7isolatemenu'}
linkMargin7isolate.shortcut = idMargin7isolate;
linkMargin7isolate.textContent = NamesMargin7isolate;
linkMargin7isolate.onclick = function (g) {
xMargin7Colorreset = 0
WinMargin7isolates = this.shortcut;
WinMargin7isolateNames = this.textContent;
if (WinMargin7isolates === 'Color') {}
else if (WinMargin7isolates === 'Done') {xMargin7Resetstatus = 0; nomenu ()}
else if (WinMargin7isolates === 'Reset') {for (p = 0; p<8; p++) {margincolor71[p] = Margin7color1[p]}
for (o = 0; o <toggleableMargin7isolateIds.length; o++) {
Margin7status1[o] = 1;
idMargin7isolate = toggleableMargin7isolateIds2[o];
NamesMargin7isolate = toggleableMargin7isolateNames2[o];
linkMargin7isolate = document.createElement('a');
linkMargin7isolate.href = '#';
linkMargin7isolate.className = 'activeMargin7isolatemenu'
if(idMargin7isolate === 'Color') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}
if(idMargin7isolate === 'Done') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}
if(idMargin7isolate === 'Reset') {linkMargin7isolate.className = 'headerMargin7isolatemenu'}}
xMargin7Resetstatus = 2;
xMargin7Colorstatus = 1;
choosecolor ()
xMargin7Resetstatus = 1}
else if (Margin7status1[8-WinMargin7isolates] === 1) {this.className = 'Margin7old'; this.style.background = '#ffffff'; this.style.color = '#000000'
margincolor71[WinMargin7isolates]=reds7[0]
Margin7status1[8-WinMargin7isolates]=0
}
else {this.className = 'activeMargin7isolatemenu'; margincolor71[WinMargin7isolates] = Margin7color1[WinMargin7isolates]; Margin7status1[8-WinMargin7isolates]=1; this.style.background = Margin7color1[WinMargin7isolates]; if(WinMargin7isolates>2) {this.style.color = '#ffffff'}}
g.preventDefault()
g.stopPropagation();

if(WinMargin7isolates === 'Color') {} else {colormap4()}
}
var layersMargin7isolate = document.getElementById('Margin7isolatemenu');
if (xMargin7Isolatestatus > 1) {if (xMargin7Resetstatus === 0) {} else {layersMargin7isolate.removeChild(layersMargin7isolate.firstChild); layersMargin7isolate.appendChild(linkMargin7isolate);}}
else {layersMargin7isolate.appendChild(linkMargin7isolate)}
}
xMargin7Isolatestatus2 ++
Margin7isolatemenu2.style.display = 'block'
toggleableMargin7isolateIds2 = ['Color',1,2,3,4,5,6,7,'Done','Reset'];
toggleableMargin7isolateNames2 = ['Color',
Math.round(((0*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.01*colorscale)+startwincode/100)*100),
Math.round(((0.01*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.02*colorscale)+startwincode/100)*100),
Math.round(((0.02*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.03*colorscale)+startwincode/100)*100),
Math.round(((0.03*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.04*colorscale)+startwincode/100)*100),
Math.round(((0.04*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.05*colorscale)+startwincode/100)*100),
Math.round(((0.05*colorscale)+startwincode/100)*100) + ' to ' + Math.round(((0.06*colorscale)+startwincode/100)*100),
'>' + Math.round(((0.06*colorscale)+startwincode/100)*100),
'Done','Reset'];
var layersMargin7isolate2 = document.getElementById('Margin7isolatemenu2');
for (l = 0; l < toggleableMargin7isolateIds2.length; l++) {
idMargin7isolate2 = toggleableMargin7isolateIds2[l];
NamesMargin7isolate2 = toggleableMargin7isolateNames2[l];
linkMargin7isolate2 = document.createElement('a');
linkMargin7isolate2.href = '#';
if (xMargin7Colorreset === 1) {Margin7status2[l] = 1}
if (Margin7status2[l] === 0) {linkMargin7isolate2.className = 'Margin7old2'; linkMargin7isolate2.style.background = '#ffffff'; linkMargin7isolate2.style.color = '#000000'}
else {linkMargin7isolate2.className = 'activeMargin7isolatemenu2'; Margin7status2[l]=1; linkMargin7isolate2.style.background = Margin7color2[idMargin7isolate2]; if(idMargin7isolate2<3) {linkMargin7isolate2.style.color = '#000000'}}
if(idMargin7isolate2 === 'Color') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}
if(idMargin7isolate2 === 'Done') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}
if(idMargin7isolate2 === 'Reset') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}
//if(idMargin7isolate === WinMargin7isolates) {linkMargin7isolate.className = 'activeMargin7isolatemenu'}
linkMargin7isolate2.shortcut = idMargin7isolate2;
linkMargin7isolate2.textContent = NamesMargin7isolate2;
linkMargin7isolate2.onclick = function (h) {
xMargin7Colorreset = 0
WinMargin7isolates2 = this.shortcut;
WinMargin7isolateNames2 = this.textContent;
if (WinMargin7isolates2 === 'Color') {}
else if (WinMargin7isolates2 === 'Done') {xMargin7Resetstatus = 0; nomenu ()}
else if (WinMargin7isolates2 === 'Reset') {for (n = 0; n<12; n++) {margincolor72[n] = Margin7color2[n]}
for (m = 0; m <toggleableMargin7isolateIds2.length; m++) {
Margin7status2[m] = 1;
idMargin7isolate2 = toggleableMargin7isolateIds2[m];
NamesMargin7isolate2 = toggleableMargin7isolateNames2[m];
linkMargin7isolate2 = document.createElement('a');
linkMargin7isolate2.href = '#';
linkMargin7isolate2.className = 'activeMargin7isolatemenu2'
if(idMargin7isolate2 === 'Color') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}
if(idMargin7isolate2 === 'Done') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}
if(idMargin7isolate2 === 'Reset') {linkMargin7isolate2.className = 'headerMargin7isolatemenu2'}}
xMargin7Resetstatus = 2;
choosecolor ()
xMargin7Resetstatus = 1}
else if (this.className === 'activeMargin7isolatemenu2') {this.className = 'Margin7old2'; this.style.background = '#ffffff'; this.style.color = '#000000'
margincolor72[WinMargin7isolates2] =reds7[0];
Margin7status2[WinMargin7isolates2]=0
}
else {this.className = 'activeMargin7isolatemenu2'; margincolor72[WinMargin7isolates2] = Margin7color2[WinMargin7isolates2]; Margin7status2[WinMargin7isolates2]=1;
this.style.background = Margin7color2[WinMargin7isolates2]; if(WinMargin7isolates2>2) {this.style.color = '#ffffff'}}
h.preventDefault();
h.stopPropagation();

if(WinMargin7isolates2 === 'Color') {} else if (WinMargin7isolates2 === 'Done') {} else if (WinMargin7isolates2 === 'Reset') {} else {colormap4()}
}
//var layersMargin7isolate2 = document.getElementById('Margin7isolatemenu2');
if (xMargin7Isolatestatus2 > 1) {if (xMargin7Resetstatus === 0) {} else {layersMargin7isolate2.removeChild(layersMargin7isolate2.firstChild); layersMargin7isolate2.appendChild(linkMargin7isolate2)}}
else {layersMargin7isolate2.appendChild(linkMargin7isolate2)}
}
}
}
{
if (clickedName === toggleableLayerNamesMain[0]) {}
else if (clickedName === toggleableLayerNamesMain[1])
{
main = 1;
amenu = 0;
bmenu = 1;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[2])
{
main = 1;
amenu = 0;
bmenu = 2;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[3])
{
main = 1;
amenu = 0;
bmenu = 3;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[4])
{
main = 1;
amenu = 0;
bmenu = 4;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[5])
{
main = 1;
amenu = 0;
bmenu = 5;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[6])
{
main = 1;
amenu = 0;
bmenu = 6;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[7])
{
main = 1;
amenu = 0;
bmenu = 7;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[8])
{
main = 1;
amenu = 0;
bmenu = 8;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[9])
{
main = 1;
amenu = 0;
bmenu = 9;
mainmenuvariables ()
}
else if (clickedName === toggleableLayerNamesMain[10])
{
main = 1;
amenu = 0;
bmenu = 10;
mainmenuvariables ()
}
}
}
var layers = document.getElementById('menu');
layers.appendChild(link);}
})

// listen for Change
slider.addEventListener('input', function(z) {
// Adjust the layers opacity. layer here is arbitrary - this could
// be another layer name found in your style or a custom layer
// added on the fly using `addSource`.
for (var i = 1; i < layer.length; i++){
map.setPaintProperty(layer[i],'fill-opacity', parseInt(z.target.value, 10) / 100);
}
// Value indicator
sliderValue.textContent = z.target.value + '%';
legendA.style.opacity = z.target.value/100;
legendB.style.opacity = z.target.value/100;
legendC.style.opacity = z.target.value/100;
legendD.style.opacity = z.target.value/100;
legendE.style.opacity = z.target.value/100;
legendF.style.opacity = z.target.value/100;
legendG.style.opacity = z.target.value/100;
legendH.style.opacity = z.target.value/100;
})

//county sub layer - must edit or delete
if(layerTog2 === ''){} else {
map.on('load',
function () {map.addLayer({
id: layerTog2,
type: 'line',
source: {
type: 'vector',
// Mapbox tileset Map ID - must edit for different tilesets
url: Tog2URL
},
'source-layer': layerTog2,
paint: {
'line-color': Tog2Color,
'line-width': Tog2Width},
layout: {'visibility': Tog2Visibility}

,},)})}

//Tog1 layer
if(layerTog1 === ''){} else {map.on('load',
function () {map.addLayer({
id: layerTog1,
type: 'line',
source: {
type: 'vector',
// Mapbox tileset Map ID - must edit for different tilesets
url: Tog1URL
},
'source-layer': layerTog1,
paint: {
'line-color': Tog1Color,
'line-width': Tog1Width
},},)})}
map.on('mouseenter', layer[lv], function () {
map.getCanvas().style.cursor = 'pointer';
});

/* //Change it back to a pointer when it leaves.
map.on('mouseleave', layer[lv], function () {
map.getCanvas().style.cursor = '';
});
map.addControl(new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
// limit results to named country
country: country,
filter:
/* function (item) {
// returns true if item contains relevant State
return item.context.map(function (i) {
// id is in the form {index}.{id} per https://github.com/mapbox/carmen/blob/master/carmen-geojson.md
// this example attempts to find the `region` named relevantState
return (i.id.split('.').shift() === 'region' && i.text === relevantState);
}).reduce(function (acc, cur) {
return acc || cur;
});
}*/
var geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
// limit results to named country
country: country
});

/*var layerlinedisplay = document.getElementById(layer[1])
if(relevantColor === 'PopPCT') {if (map.getZoom() > 6) {
layerlinedisplay.style.line-width = 0.1;
layerlinedisplay.style.linecolor = '#f0f0f0';
} else {
layerlinedisplay.style.linewidth = 0;}
}
if(relevantColor === 'PopNUM') {if (map.getZoom() > 6) {
layerlinedisplay.style.linewidth = 0.1;
layerlinedisplay.style.linecolor = '#f0f0f0';
} else {
layerlinedisplay.style.linewidth = 0;
}}*/

map.addControl(geocoder);

map.on('load', updateGeocoderProximity); // set proximity on map load
map.on('moveend', updateGeocoderProximity); // and then update proximity each time the map moves

function updateGeocoderProximity() {
// proximity is designed for local scale, if the user is looking at the whole world,
// it doesn't make sense to factor in the arbitrary centre of the map
if (map.getZoom() > 9) {
var center = map.getCenter().wrap(); // ensures the longitude falls within -180 to 180 as the Geocoding API doesn't accept values outside this range
geocoder.setProximity({ longitude: center.lng, latitude: center.lat });
} else {
geocoder.setProximity(null);
}
}
map.addControl(new mapboxgl.FullscreenControl());
map.addControl(new mapboxgl.NavigationControl());
Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive