text: let state_names = ['Alabama','Arizona','Arkansas','California','Colorado',
  'Connecticut','Delaware','District of Columbia', 'Florida','Georgia','Idaho','Illinois',
  'Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota',
  'Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York',
  'North Carolina','Ohio','Oklahoma','Oregon', 'Pennsylvania', 'Rhode Island','South Carolina',
  'Tennessee','Texas','Utah','Vermont','West Virginia', 'Virginia','Washington','Wisconsin',
  'Wyoming', 'North Dakota', 'South Dakota'];
  
  let state_names_1898 = ['Alaska', 'Alabama','Arizona','Arkansas','California','Colorado',
  'Connecticut','Delaware','District of Columbia', 'Florida','Georgia', 'Hawaii', 'Idaho','Illinois',
  'Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota',
  'Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York',
  'North Carolina','Ohio','Oklahoma','Oregon', 'Pennsylvania', 'Rhode Island','South Carolina',
  'Tennessee','Texas','Utah','Vermont','West Virginia', 'Virginia','Washington','Wisconsin',
  'Wyoming', 'North Dakota', 'South Dakota'];
  
  let territories_1898 = ['Oklahoma', 'New Mexico', 'Arizona', 'Alaska', 'Hawaii'];
  
  let confed_states_1864 = ['Texas', 'Arkansas', 'Louisiana', 'Tennessee', 'Mississippi', 'Alabama', 
    'Georgia', 'Florida', 'South Carolina', 'North Carolina', 'Virginia'];
  
  //Data source from https://en.wikipedia.org/wiki/1864_United_States_presidential_election
  let election_data_1864 = {'California':{'nu_count':'62,053','nu_electoral':'5','dem_count':'43,837','dem_electoral':'-1'},
    'Connecticut':{'nu_count':'44,673','nu_electoral':'6','dem_count':'42,285','dem_electoral':'-1'},
    'Delaware':{'nu_count':'8,155','nu_electoral':'–','dem_count':'8,767','dem_electoral':'3'},
    'Illinois':{'nu_count':'189,512','nu_electoral':'16','dem_count':'158,724','dem_electoral':'-1'},
    'Indiana':{'nu_count':'149,887','nu_electoral':'13','dem_count':'130,230','dem_electoral':'-1'},
    'Iowa':{'nu_count':'83,858','nu_electoral':'8','dem_count':'49,089','dem_electoral':'-1'},
    'Kansas':{'nu_count':'17,089','nu_electoral':'3','dem_count':'3,836','dem_electoral':'-1'},
    'Kentucky':{'nu_count':'27,787','nu_electoral':'–','dem_count':'64,301','dem_electoral':'11'},
    'Louisiana':{'nu_count':'no popular vote','nu_electoral':'7','dem_count':'no popular vote','dem_electoral':'-1'},
    'Maine':{'nu_count':'67,805','nu_electoral':'7','dem_count':'46,992','dem_electoral':'-1'},
    'Maryland':{'nu_count':'40,153','nu_electoral':'7','dem_count':'32,739','dem_electoral':'-1'},
    'Massachusetts':{'nu_count':'126,742','nu_electoral':'12','dem_count':'48,745','dem_electoral':'-1'},
    'Michigan':{'nu_count':'91,133','nu_electoral':'8','dem_count':'74,146','dem_electoral':'-1'},
    'Minnesota':{'nu_count':'25,031','nu_electoral':'4','dem_count':'17,376','dem_electoral':'-1'},
    'Missouri':{'nu_count':'72,750','nu_electoral':'11','dem_count':'31,596','dem_electoral':'-1'},
    'Nevada':{'nu_count':'9,826','nu_electoral':'2','dem_count':'6,594','dem_electoral':'-1'},
    'New Hampshire':{'nu_count':'36,596','nu_electoral':'5','dem_count':'33,034','dem_electoral':'-1'},
    'New Jersey':{'nu_count':'60,724','nu_electoral':'–','dem_count':'68,020','dem_electoral':'7'},
    'New York':{'nu_count':'368,735','nu_electoral':'33','dem_count':'361,986','dem_electoral':'-1'},
    'Ohio':{'nu_count':'265,674','nu_electoral':'21','dem_count':'205,609','dem_electoral':'-1'},
    'Oregon':{'nu_count':'9,888','nu_electoral':'3','dem_count':'8,457','dem_electoral':'-1'},
    'Pennsylvania':{'nu_count':'296,292','nu_electoral':'26','dem_count':'277,443','dem_electoral':'-1'},
    'Rhode Island':{'nu_count':'14,349','nu_electoral':'4','dem_count':'8,718','dem_electoral':'-1'},
    'Tennessee':{'nu_count':'no popular vote','nu_electoral':'10','dem_count':'no popular vote','dem_electoral':'-1'},
    'Vermont':{'nu_count':'42,419','nu_electoral':'5','dem_count':'13,321','dem_electoral':'-1'},
    'West Virginia':{'nu_count':'23,799','nu_electoral':'5','dem_count':'11,078','dem_electoral':'-1'},
    'Wisconsin':{'nu_count':'83,458','nu_electoral':'8','dem_count':'65,884','dem_electoral':'-1'}};
  
  let territories_1864 = {"Dakota Territory": {"info":"Dakota Territory"},
    "Nebraska Territory": {"info":"Nebraska Territory"},
    "Montana Territory": {"info":"Montana Territory"},
    "Idaho Territory": {"info":"Idaho Territory"},
    "Washington Territory": {"info":"Washington Territory"},
    "Unorganized Territory": {"info":"Unorganized Territory"},
    "Colorado Territory": {"info":"Colorado Territory"},
    "Utah Territory": {"info":"Utah Territory"},
    "Arizona Territory": {"info":"Arizona Territory"},
    "New Mexico Territory": {"info":"New Mexico Territory"}
  }
  
  let states_to_terrs_1864 = {'Wyoming': 'Dakota Territory', 'North Dakota': 'Dakota Territory', 
    'South Dakota': 'Dakota Territory', 'Oklahoma': 'Unorganized Territory', 'Nebraska': 'Nebraska Territory',
    'Montana': 'Montana Territory', 'Idaho': 'Idaho Territory', 'Washington': 'Washington Territory', 
    'Colorado': 'Colorado Territory', 'Utah': 'Utah Territory', 'Arizona': 'Arizona Territory', 
    'New Mexico': 'New Mexico Territory'
  };
  
  let territories_1860 = {"Kansas Territory": {"info":"Kansas Territory"},
    "Nebraska Territory": {"info":"Nebraska Territory. There was an adjacent Unorganized territory which was located in modern day eastern North and South Dakota."},
    "Washington Territory": {"info":"Washington Territory"},
    "Unorganized Territory": {"info":"Unorganized Territory"},
    "Utah Territory": {"info":"Utah Territory"},
    "New Mexico Territory": {"info":"New Mexico Territory"},
    "Colorado_1860": {"info":"Modern day Colorado was comprised of Kansas, Utah, and Kansas territories, and was not its seperate territory in 1860 like it was in 1864."}
  }
  
  let states_to_terrs_1860 = {'Wyoming': 'Nebraska Territory', 'North Dakota': 'Nebraska Territory', 
    'South Dakota': 'Nebraska Territory', 'Oklahoma': 'Unorganized Territory', 'Nebraska': 'Nebraska Territory',
    'Montana': 'Nebraska Territory', 'Idaho': 'Washington Territory', 'Washington': 'Washington Territory', 
    'Colorado': 'Colorado_1860', 'Utah': 'Utah Territory', 'Arizona': 'New Mexico Territory', 
    'New Mexico': 'New Mexico Territory', 'Kansas': 'Kansas Territory', 'Nevada': 'Utah Territory'
  };
  
  //Data source from https://en.wikipedia.org/wiki/1860_United_States_presidential_election
  let election_data_1860 = 
  {
      "Alabama": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "13,618",
         "nd_e": "-",
         "sd_c": "48,669",
         "sd_e": "9",
         "cu_c": "27,835",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Arkansas": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "5,357",
         "nd_e": "-",
         "sd_c": "28,732",
         "sd_e": "4",
         "cu_c": "20,063",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Florida": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "223",
         "nd_e": "-",
         "sd_c": "8,277",
         "sd_e": "3",
         "cu_c": "4,801",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Georgia": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "11,581",
         "nd_e": "-",
         "sd_c": "52,176",
         "sd_e": "10",
         "cu_c": "42,960",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Louisiana": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "7,625",
         "nd_e": "-",
         "sd_c": "22,681",
         "sd_e": "6",
         "cu_c": "20,204",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Mississippi": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "3,282",
         "nd_e": "-",
         "sd_c": "40,768",
         "sd_e": "7",
         "cu_c": "25,045",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "North Carolina": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "2,737",
         "nd_e": "-",
         "sd_c": "48,846",
         "sd_e": "10",
         "cu_c": "45,129",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Tennessee": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "11,281",
         "nd_e": "-",
         "sd_c": "65,097",
         "sd_e": "-",
         "cu_c": "69,728",
         "cu_e": "12",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Texas": {
         "r_c": "no ballots",
         "r_e": "no ballots",
         "nd_c": "18",
         "nd_e": "-",
         "sd_c": "47,454",
         "sd_e": "4",
         "cu_c": "15,383",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "California": {
         "r_c": "38,733",
         "r_e": "4",
         "nd_c": "37,999",
         "nd_e": "-",
         "sd_c": "33,969",
         "sd_e": "-",
         "cu_c": "9,111",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Connecticut": {
         "r_c": "43,486",
         "r_e": "6",
         "nd_c": "17,364",
         "nd_e": "-",
         "sd_c": "16,558",
         "sd_e": "-",
         "cu_c": "3,337",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Delaware": {
         "r_c": "3,822",
         "r_e": "-",
         "nd_c": "1,066",
         "nd_e": "-",
         "sd_c": "7,339",
         "sd_e": "3",
         "cu_c": "3,888",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Illinois": {
         "r_c": "172,171",
         "r_e": "11",
         "nd_c": "160,215",
         "nd_e": "-",
         "sd_c": "2,331",
         "sd_e": "-",
         "cu_c": "4,914",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Indiana": {
         "r_c": "139,033",
         "r_e": "13",
         "nd_c": "115,509",
         "nd_e": "-",
         "sd_c": "12,295",
         "sd_e": "-",
         "cu_c": "5,306",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Iowa": {
         "r_c": "70,302",
         "r_e": "4",
         "nd_c": "55,639",
         "nd_e": "-",
         "sd_c": "1,035",
         "sd_e": "-",
         "cu_c": "1,763",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Kentucky": {
         "r_c": "1,364",
         "r_e": "-",
         "nd_c": "25,651",
         "nd_e": "-",
         "sd_c": "53,143",
         "sd_e": "-",
         "cu_c": "66,058",
         "cu_e": "12",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Maine": {
         "r_c": "62,811",
         "r_e": "8",
         "nd_c": "29,693",
         "nd_e": "-",
         "sd_c": "6,368",
         "sd_e": "-",
         "cu_c": "2,046",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Maryland": {
         "r_c": "2,294",
         "r_e": "-",
         "nd_c": "15,966",
         "nd_e": "-",
         "sd_c": "42,482",
         "sd_e": "8",
         "cu_c": "41,760",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Massachusetts": {
         "r_c": "106,684",
         "r_e": "13",
         "nd_c": "34,370",
         "nd_e": "-",
         "sd_c": "6,163",
         "sd_e": "-",
         "cu_c": "22,331",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Michigan": {
         "r_c": "88,450",
         "r_e": "6",
         "nd_c": "64,889",
         "nd_e": "-",
         "sd_c": "805",
         "sd_e": "-",
         "cu_c": "405",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Minnesota": {
         "r_c": "22,069",
         "r_e": "4",
         "nd_c": "11,920",
         "nd_e": "-",
         "sd_c": "748",
         "sd_e": "-",
         "cu_c": "50",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Missouri": {
         "r_c": "17,028",
         "r_e": "-",
         "nd_c": "58,801",
         "nd_e": "9",
         "sd_c": "31,362",
         "sd_e": "-",
         "cu_c": "58,372",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "New Hampshire": {
         "r_c": "37,519",
         "r_e": "5",
         "nd_c": "25,887",
         "nd_e": "-",
         "sd_c": "2,125",
         "sd_e": "-",
         "cu_c": "412",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Ohio": {
         "r_c": "221,809",
         "r_e": "23",
         "nd_c": "187,421",
         "nd_e": "-",
         "sd_c": "11,303",
         "sd_e": "-",
         "cu_c": "12,193",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Oregon": {
         "r_c": "5,344",
         "r_e": "3",
         "nd_c": "4,131",
         "nd_e": "-",
         "sd_c": "5,074",
         "sd_e": "-",
         "cu_c": "212",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Vermont": {
         "r_c": "33,808",
         "r_e": "5",
         "nd_c": "8,649",
         "nd_e": "-",
         "sd_c": "1,866",
         "sd_e": "-",
         "cu_c": "217",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Virginia": {
         "r_c": "1,887",
         "r_e": "-",
         "nd_c": "16,198",
         "nd_e": "-",
         "sd_c": "74,325",
         "sd_e": "-",
         "cu_c": "74,481",
         "cu_e": "15",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "Wisconsin": {
         "r_c": "86,113",
         "r_e": "5",
         "nd_c": "65,021",
         "nd_e": "-",
         "sd_c": "887",
         "sd_e": "-",
         "cu_c": "161",
         "cu_e": "-",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "New Jersey": {
         "r_c": "58,346",
         "r_e": "4",
         "nd_c": "no ballots",
         "nd_e": "3",
         "sd_c": "no ballots",
         "sd_e": "-",
         "cu_c": "no ballots",
         "cu_e": "-",
         "f_c": "62,869",
         "f_e": "-"
      },
      "New York": {
         "r_c": "362,646",
         "r_e": "35",
         "nd_c": "no ballots",
         "nd_e": "-",
         "sd_c": "no ballots",
         "sd_e": "-",
         "cu_c": "no ballots",
         "cu_e": "-",
         "f_c": "312,510",
         "f_e": "-"
      },
      "Pennsylvania": {
         "r_c": "268,030",
         "r_e": "27",
         "nd_c": "16,765",
         "nd_e": "-",
         "sd_c": "no ballots",
         "sd_e": "no ballots",
         "cu_c": "12,776",
         "cu_e": "-",
         "f_c": "178,871",
         "f_e": "-"
      },
      "Rhode Island": {
         "r_c": "12,244",
         "r_e": "4",
         "nd_c": "7,707",
         "nd_e": "-",
         "sd_c": "no ballots",
         "sd_e": "no ballots",
         "cu_c": "no ballots",
         "cu_e": "no ballots",
         "f_c": "no ballots",
         "f_e": "no ballots"
      },
      "South Carolina": {
         "r_c": "no popular vote",
         "r_e": "no popular vote",
         "nd_c": "no popular vote",
         "nd_e": "no popular vote",
         "sd_c": "no popular vote",
         "sd_e": "8",
         "cu_c": "no popular vote",
         "cu_e": "no popular vote",
         "f_c": "no popular vote",
         "f_e": "no popular vote"
      }
   };