const countriesEconom = [
  { name: "Albania", zone: 10},
  { name: "Austria", zone: 10},
  { name: "Bośnia i Hercegowina", zone: 10},
  { name: "Bułgaria", zone: 10},
  { name: "Chorwacja", zone: 10},
  { name: "Cypr", zone: 10},
  { name: "Dania z Grenlandia i Wyspami Owczymi", zone: 10},
  { name: "Estonia", zone: 10},
  { name: "Francja z Korsyka oraz z Andora i Monako", zone: 10},
  { name: "Gibraltar", zone: 10},
  { name: "Grecja", zone: 10},
  { name: "Hiszpania z Majorka i Wyspami Kanaryjskimi", zone: 10},
  { name: "Kosowo", zone: 10},
  { name: "Holandia", zone: 10},
  { name: "Irlandia ( Eire )", zone: 10},
  { name: "Islandia", zone: 10},
  { name: "Izrael", zone: 10},
  { name: "Litwa", zone: 10},
  { name: "Luksemburg", zone: 10},
  { name: "Łotwa", zone: 10},
  { name: "Macedonia", zone: 10},
  { name: "Malta", zone: 10},
  { name: "Mołdowa", zone: 10},
  { name: "Rumunia", zone: 10},
  { name: "Serbia", zone: 10},
  { name: "Słowenia", zone: 10},
  { name: "Szwecja", zone: 10},
  { name: "Turcja", zone: 10},
  { name: "Ukraina", zone: 10},
  { name: "Watykan", zone: 10},

  { name: "Belgia", zone: 11},
  { name: "Białoruś", zone: 11},
  { name: "Finlandia", zone: 11},
  { name: "Norwegia", zone: 11},
  { name: "Portugalia z Azorami i Madera", zone: 11},
  { name: "Rosja", zone: 11},
  { name: "Szwajcaria  z Liechtensteinem", zone: 11},
  { name: "Węgry", zone: 11},
  { name: "Wielka  Brytania oraz Irlandia Płn. (bez terytoriów zamorskich)", zone: 11},
  { name: "Włochy  z  Republika San  Marino", zone: 11},

  { name: "Czechy", zone: 12},
  { name: "Słowacja", zone: 12},

  { name: "Niemcy", zone: 13},

  { name: "Czarnogóra", zone: 20},
  { name: "Ameryka Północna", zone: 20},

  { name: "Ameryka Południowa", zone: 30},
  { name: "Środkowa i Azja", zone: 30},

  { name: "Australia", zone: 40},
  { name: "Oceania", zone: 40}
]

const countriesPriority = [
	{ name: "Austria", zone: 'A1' },
	{ name: "Białoruś", zone: 'A1' },
	{ name: "Bośnia i Hercegowina", zone: 'A1' },
	{ name: "Bułgaria", zone: 'A1' },
	{ name: "Chorwacja", zone: 'A1' },
	{ name: "Dania z Grenlandia i Wyspami Owczymi", zone: 'A1' },
	{ name: "Estonia", zone: 'A1' },
	{ name: "Holandia", zone: 'A1' },
	{ name: "Litwa", zone: 'A1' },
	{ name: "Luksemburg", zone: 'A1' },
	{ name: "Łotwa", zone: 'A1' },
	{ name: "Słowenia", zone: 'A1' },
	{ name: "Szwajcaria  z Liechtensteinem", zone: 'A1' },
	{ name: "Ukraina", zone: 'A1' },
	{ name: "Watykan", zone: 'A1' },
	{ name: "Węgry", zone: 'A1' },

	{ name: "Albania", zone: 'A2' },
	{ name: "Belgia", zone: 'A2' },
	{ name: "Czarnogóra", zone: 'A2' },
	{ name: "Malta", zone: 'A2' },
	{ name: "Norwegię", zone: 'A2' },
	{ name: "Cypr", zone: 'A2' },
	{ name: "Finlandia", zone: 'A2' },
	{ name: "Francja z Korsyka oraz z Andora i Monako", zone: 'A2' },
	{ name: "Gibraltar", zone: 'A2' },
	{ name: "Grecja", zone: 'A2' },
	{ name: "Hiszpania z Majorka i Wyspami Kanaryjskimi", zone: 'A2' },
	{ name: "Kosowo", zone: 'A2' },
	{ name: "Irlandia ( Eire )", zone: 'A2' },
	{ name: "Islandia", zone: 'A2' },
	{ name: "Izrael", zone: 'A2' },
	{ name: "Macedonia", zone: 'A2' },
	{ name: "Mołdowa", zone: 'A2' },
	{ name: "Rumunia", zone: 'A2' },
	{ name: "Serbia", zone: 'A2' },
	{ name: "Szwecja", zone: 'A2' },
	{ name: "Turcja", zone: 'A2' },
	{ name: "Włochy z  Republika San  Marino", zone: 'A2' },

	{ name: "Portugalia z Azorami i Madera", zone: 'A3' },
	{ name: "Rosja", zone: 'A3' },
	{ name: "Wielka Brytania", zone: 'A3' },
	{ name: "Irlandia Płn. (bez terytoriów zamorskich)", zone: 'A3' },

	{ name: "Czechy", zone: 'A4' },
	{ name: "Slowacja", zone: 'A4' },

	{ name: "Niemcy", zone: 'A5' },

	{ name: "Ameryka Północna", zone: 'B' },
	{ name: "Afryka", zone: 'B' },

	{ name: "Ameryka Południowa", zone: 'C' },
	{ name: "Ameryka Środkowa", zone: 'C' },
	{ name: "Azja", zone: 'C' },

	{ name: "Australia", zone: 'D' },
	{ name: "Oceania", zone: 'D' },
]

const zoneEconom = [
	{zone: 10, weight: 1, price: 56.00},
	{zone: 10, weight: 2, price: 62.00},
	{zone: 10, weight: 3, price: 67.00},
	{zone: 10, weight: 4, price: 75.00},
	{zone: 10, weight: 5, price: 84.00},
	{zone: 10, weight: 6, price: 86.00},
	{zone: 10, weight: 7, price: 88.00},
	{zone: 10, weight: 8, price: 90.00},
	{zone: 10, weight: 9, price: 92.00},
	{zone: 10, weight: 10, price: 95.00},
	{zone: 10, weight: 11, price: 100.00},
	{zone: 10, weight: 12, price: 105.00},
	{zone: 10, weight: 13, price: 110.00},
	{zone: 10, weight: 14, price: 116.00},
	{zone: 10, weight: 15, price: 124.00},
	{zone: 10, weight: 16, price: 127.00},
	{zone: 10, weight: 17, price: 131.00},
	{zone: 10, weight: 18, price: 136.00},
	{zone: 10, weight: 19, price: 141.00},
	{zone: 10, weight: 20, price: 146.00},

	{zone: 11, weight: 1, price: 56.00},
	{zone: 11, weight: 2, price: 62.00},
	{zone: 11, weight: 3, price: 67.00},
	{zone: 11, weight: 4, price: 75.00},
	{zone: 11, weight: 5, price: 84.00},
	{zone: 11, weight: 6, price: 96.00},
	{zone: 11, weight: 7, price: 98.00},
	{zone: 11, weight: 8, price: 105.00},
	{zone: 11, weight: 9, price: 112.00},
	{zone: 11, weight: 10, price: 120.00},
	{zone: 11, weight: 11, price: 127.00},
	{zone: 11, weight: 12, price: 135.00},
	{zone: 11, weight: 13, price: 143.00},
	{zone: 11, weight: 14, price: 151.00},
	{zone: 11, weight: 15, price: 159.00},
	{zone: 11, weight: 16, price: 167.00},
	{zone: 11, weight: 17, price: 175.00},
	{zone: 11, weight: 18, price: 183.00},
	{zone: 11, weight: 19, price: 191.00},
	{zone: 11, weight: 20, price: 199.00},

	{zone: 12, weight: 1, price: 32.00},
	{zone: 12, weight: 2, price: 35.00},
	{zone: 12, weight: 3, price: 37.00},
	{zone: 12, weight: 4, price: 40.00},
	{zone: 12, weight: 5, price: 41.00},
	{zone: 12, weight: 6, price: 43.00},
	{zone: 12, weight: 7, price: 45.00},
	{zone: 12, weight: 8, price: 48.00},
	{zone: 12, weight: 9, price: 50.00},
	{zone: 12, weight: 10, price: 52.00},
	{zone: 12, weight: 11, price: 55.00},
	{zone: 12, weight: 12, price: 56.00},
	{zone: 12, weight: 13, price: 58.00},
	{zone: 12, weight: 14, price: 60.00},
	{zone: 12, weight: 15, price: 63.00},
	{zone: 12, weight: 16, price: 65.00},
	{zone: 12, weight: 17, price: 67.00},
	{zone: 12, weight: 18, price: 69.00},
	{zone: 12, weight: 19, price: 72.00},
	{zone: 12, weight: 20, price: 74.00},

	{zone: 13, weight: 1, price: 52.00},
	{zone: 13, weight: 2, price: 58.00},
	{zone: 13, weight: 3, price: 63.00},
	{zone: 13, weight: 4, price: 71.00},
	{zone: 13, weight: 5, price: 80.00},
	{zone: 13, weight: 6, price: 82.00},
	{zone: 13, weight: 7, price: 84.00},
	{zone: 13, weight: 8, price: 86.00},
	{zone: 13, weight: 9, price: 88.00},
	{zone: 13, weight: 10, price: 91.00},
	{zone: 13, weight: 11, price: 96.00},
	{zone: 13, weight: 12, price: 101.00},
	{zone: 13, weight: 13, price: 106.00},
	{zone: 13, weight: 14, price: 112.00},
	{zone: 13, weight: 15, price: 120.00},
	{zone: 13, weight: 16, price: 123.00},
	{zone: 13, weight: 17, price: 127.00},
	{zone: 13, weight: 18, price: 132.00},
	{zone: 13, weight: 19, price: 137.00},
	{zone: 13, weight: 20, price: 142.00},

	{zone: 20, weight: 1, price: 57.00},
	{zone: 20, weight: 2, price: 63.00},
	{zone: 20, weight: 3, price: 68.00},
	{zone: 20, weight: 4, price: 76.00},
	{zone: 20, weight: 5, price: 85.00},
	{zone: 20, weight: 6, price: 89.00},
	{zone: 20, weight: 7, price: 92.00},
	{zone: 20, weight: 8, price: 100.00},
	{zone: 20, weight: 9, price: 108.00},
	{zone: 20, weight: 10, price: 114.00},
	{zone: 20, weight: 11, price: 122.00},
	{zone: 20, weight: 12, price: 129.00},
	{zone: 20, weight: 13, price: 138.00},
	{zone: 20, weight: 14, price: 150.00},
	{zone: 20, weight: 15, price: 162.00},
	{zone: 20, weight: 16, price: 165.00},
	{zone: 20, weight: 17, price: 170.00},
	{zone: 20, weight: 18, price: 177.00},
	{zone: 20, weight: 19, price: 182.00},
	{zone: 20, weight: 20, price: 187.00},

	{zone: 30, weight: 1, price: 59.00},
	{zone: 30, weight: 2, price: 65.00},
	{zone: 30, weight: 3, price: 70.00},
	{zone: 30, weight: 4, price: 77.00},
	{zone: 30, weight: 5, price: 86.00},
	{zone: 30, weight: 6, price: 90.00},
	{zone: 30, weight: 7, price: 98.00},
	{zone: 30, weight: 8, price: 106.00},
	{zone: 30, weight: 9, price: 114.00},
	{zone: 30, weight: 10, price: 122.00},
	{zone: 30, weight: 11, price: 130.00},
	{zone: 30, weight: 12, price: 139.00},
	{zone: 30, weight: 13, price: 149.00},
	{zone: 30, weight: 14, price: 159.00},
	{zone: 30, weight: 15, price: 169.00},
	{zone: 30, weight: 16, price: 173.00},
	{zone: 30, weight: 17, price: 178.00},
	{zone: 30, weight: 18, price: 185.00},
	{zone: 30, weight: 19, price: 194.00},
	{zone: 30, weight: 20, price: 200.00},

	{zone: 40, weight: 1, price: 61.00},
	{zone: 40, weight: 2, price: 67.00},
	{zone: 40, weight: 3, price: 73.00},
	{zone: 40, weight: 4, price: 79.00},
	{zone: 40, weight: 5, price: 87.00},
	{zone: 40, weight: 6, price: 95.00},
	{zone: 40, weight: 7, price: 101.00},
	{zone: 40, weight: 8, price: 109.00},
	{zone: 40, weight: 9, price: 116.00},
	{zone: 40, weight: 10, price: 124.00},
	{zone: 40, weight: 11, price: 133.00},
	{zone: 40, weight: 12, price: 142.00},
	{zone: 40, weight: 13, price: 153.00},
	{zone: 40, weight: 14, price: 163.00},
	{zone: 40, weight: 15, price: 173.00},
	{zone: 40, weight: 16, price: 178.00},
	{zone: 40, weight: 17, price: 186.00},
	{zone: 40, weight: 18, price: 197.00},
	{zone: 40, weight: 19, price: 206.00},
	{zone: 40, weight: 20, price: 217.00}
]

const zonePriority = [
	{zone: 'A1', weight: 1, price: 60.00},
	{zone: 'A1', weight: 2, price: 72.00},
	{zone: 'A1', weight: 3, price: 80.00},
	{zone: 'A1', weight: 4, price: 92.00},
	{zone: 'A1', weight: 5, price: 102.00},
	{zone: 'A1', weight: 6, price: 105.00},
	{zone: 'A1', weight: 7, price: 110.00},
	{zone: 'A1', weight: 8, price: 117.00},
	{zone: 'A1', weight: 9, price: 125.00},
	{zone: 'A1', weight: 10, price: 133.00},
	{zone: 'A1', weight: 11, price: 139.00},
	{zone: 'A1', weight: 12, price: 145.00},
	{zone: 'A1', weight: 13, price: 155.00},
	{zone: 'A1', weight: 14, price: 162.00},
	{zone: 'A1', weight: 15, price: 171.00},
	{zone: 'A1', weight: 16, price: 179.00},
	{zone: 'A1', weight: 17, price: 187.00},
	{zone: 'A1', weight: 18, price: 196.00},
	{zone: 'A1', weight: 19, price: 202.00},
	{zone: 'A1', weight: 20, price: 211.00},

	{zone: 'A2', weight: 1, price: 70.00},
	{zone: 'A2', weight: 2, price: 82.00},
	{zone: 'A2', weight: 3, price: 98.00},
	{zone: 'A2', weight: 4, price: 102.00},
	{zone: 'A2', weight: 5, price: 114.00},
	{zone: 'A2', weight: 6, price: 117.00},
	{zone: 'A2', weight: 7, price: 124.00},
	{zone: 'A2', weight: 8, price: 131.00},
	{zone: 'A2', weight: 9, price: 139.00},
	{zone: 'A2', weight: 10, price: 145.00},
	{zone: 'A2', weight: 11, price: 151.00},
	{zone: 'A2', weight: 12, price: 160.00},
	{zone: 'A2', weight: 13, price: 166.00},
	{zone: 'A2', weight: 14, price: 172.00},
	{zone: 'A2', weight: 15, price: 179.00},
	{zone: 'A2', weight: 16, price: 187.00},
	{zone: 'A2', weight: 17, price: 196.00},
	{zone: 'A2', weight: 18, price: 204.00},
	{zone: 'A2', weight: 19, price: 211.00},
	{zone: 'A2', weight: 20, price: 221.00},

	{zone: 'A3', weight: 1, price: 70.00},
	{zone: 'A3', weight: 2, price: 82.00},
	{zone: 'A3', weight: 3, price: 98.00},
	{zone: 'A3', weight: 4, price: 102.00},
	{zone: 'A3', weight: 5, price: 114.00},
	{zone: 'A3', weight: 6, price: 117.00},
	{zone: 'A3', weight: 7, price: 124.00},
	{zone: 'A3', weight: 8, price: 131.00},
	{zone: 'A3', weight: 9, price: 139.00},
	{zone: 'A3', weight: 10, price: 145.00},
	{zone: 'A3', weight: 11, price: 158.00},
	{zone: 'A3', weight: 12, price: 167.00},
	{zone: 'A3', weight: 13, price: 176.00},
	{zone: 'A3', weight: 14, price: 185.00},
	{zone: 'A3', weight: 15, price: 194.00},
	{zone: 'A3', weight: 16, price: 212.00},
	{zone: 'A3', weight: 17, price: 221.00},
	{zone: 'A3', weight: 18, price: 230.00},
	{zone: 'A3', weight: 19, price: 239.00},
	{zone: 'A3', weight: 20, price: 249.00},

	{zone: 'A4', weight: 1, price: 34.00},
	{zone: 'A4', weight: 2, price: 37.00},
	{zone: 'A4', weight: 3, price: 39.00},
	{zone: 'A4', weight: 4, price: 41.00},
	{zone: 'A4', weight: 5, price: 45.00},
	{zone: 'A4', weight: 6, price: 48.00},
	{zone: 'A4', weight: 7, price: 51.00},
	{zone: 'A4', weight: 8, price: 53.00},
	{zone: 'A4', weight: 9, price: 56.00},
	{zone: 'A4', weight: 10, price: 59.00},
	{zone: 'A4', weight: 11, price: 62.00},
	{zone: 'A4', weight: 12, price: 64.00},
	{zone: 'A4', weight: 13, price: 67.00},
	{zone: 'A4', weight: 14, price: 70.00},
	{zone: 'A4', weight: 15, price: 72.00},
	{zone: 'A4', weight: 16, price: 75.00},
	{zone: 'A4', weight: 17, price: 78.00},
	{zone: 'A4', weight: 18, price: 81.00},
	{zone: 'A4', weight: 19, price: 83.00},
	{zone: 'A4', weight: 20, price: 86.00},

	{zone: 'A5', weight: 1, price: 66.00},
	{zone: 'A5', weight: 2, price: 78.00},
	{zone: 'A5', weight: 3, price: 94.00},
	{zone: 'A5', weight: 4, price: 98.00},
	{zone: 'A5', weight: 5, price: 110.00},
	{zone: 'A5', weight: 6, price: 113.00},
	{zone: 'A5', weight: 7, price: 120.00},
	{zone: 'A5', weight: 8, price: 127.00},
	{zone: 'A5', weight: 9, price: 135.00},
	{zone: 'A5', weight: 10, price: 141.00},
	{zone: 'A5', weight: 11, price: 147.00},
	{zone: 'A5', weight: 12, price: 156.00},
	{zone: 'A5', weight: 13, price: 162.00},
	{zone: 'A5', weight: 14, price: 168.00},
	{zone: 'A5', weight: 15, price: 175.00},
	{zone: 'A5', weight: 16, price: 183.00},
	{zone: 'A5', weight: 17, price: 192.00},
	{zone: 'A5', weight: 18, price: 200.00},
	{zone: 'A5', weight: 19, price: 207.00},
	{zone: 'A5', weight: 20, price: 217.00},

	{zone: 'B', weight: 1, price: 81.00},
	{zone: 'B', weight: 2, price: 102.00},
	{zone: 'B', weight: 3, price: 126.00},
	{zone: 'B', weight: 4, price: 146.00},
	{zone: 'B', weight: 5, price: 172.00},
	{zone: 'B', weight: 6, price: 184.00},
	{zone: 'B', weight: 7, price: 203.00},
	{zone: 'B', weight: 8, price: 222.00},
	{zone: 'B', weight: 9, price: 240.00},
	{zone: 'B', weight: 10, price: 258.00},
	{zone: 'B', weight: 11, price: 276.00},
	{zone: 'B', weight: 12, price: 297.00},
	{zone: 'B', weight: 13, price: 318.00},
	{zone: 'B', weight: 14, price: 339.00},
	{zone: 'B', weight: 15, price: 360.00},
	{zone: 'B', weight: 16, price: 390.00},
	{zone: 'B', weight: 17, price: 411.00},
	{zone: 'B', weight: 18, price: 433.00},
	{zone: 'B', weight: 19, price: 454.00},
	{zone: 'B', weight: 20, price: 475.00},

	{zone: 'C', weight: 1, price: 89.00},
	{zone: 'C', weight: 2, price: 116.00},
	{zone: 'C', weight: 3, price: 140.00},
	{zone: 'C', weight: 4, price: 170.00},
	{zone: 'C', weight: 5, price: 205.00},
	{zone: 'C', weight: 6, price: 225.00},
	{zone: 'C', weight: 7, price: 254.00},
	{zone: 'C', weight: 8, price: 283.00},
	{zone: 'C', weight: 9, price: 311.00},
	{zone: 'C', weight: 10, price: 336.00},
	{zone: 'C', weight: 11, price: 363.00},
	{zone: 'C', weight: 12, price: 386.00},
	{zone: 'C', weight: 13, price: 416.00},
	{zone: 'C', weight: 14, price: 448.00},
	{zone: 'C', weight: 15, price: 466.00},
	{zone: 'C', weight: 16, price: 500.00},
	{zone: 'C', weight: 17, price: 514.00},
	{zone: 'C', weight: 18, price: 538.00},
	{zone: 'C', weight: 19, price: 561.00},
	{zone: 'C', weight: 20, price: 586.00},

	{zone: 'D', weight: 1, price: 103.00},
	{zone: 'D', weight: 2, price: 145.00},
	{zone: 'D', weight: 3, price: 188.00},
	{zone: 'D', weight: 4, price: 231.00},
	{zone: 'D', weight: 5, price: 272.00},
	{zone: 'D', weight: 6, price: 312.00},
	{zone: 'D', weight: 7, price: 354.00},
	{zone: 'D', weight: 8, price: 398.00},
	{zone: 'D', weight: 9, price: 439.00},
	{zone: 'D', weight: 10, price: 481.00},
	{zone: 'D', weight: 11, price: 524.00},
	{zone: 'D', weight: 12, price: 566.00},
	{zone: 'D', weight: 13, price: 608.00},
	{zone: 'D', weight: 14, price: 650.00},
	{zone: 'D', weight: 15, price: 692.00},
	{zone: 'D', weight: 16, price: 723.00},
	{zone: 'D', weight: 17, price: 755.00},
	{zone: 'D', weight: 18, price: 772.00},
	{zone: 'D', weight: 19, price: 807.00},
	{zone: 'D', weight: 20, price: 840.00}
]

//** Calc. page **//
$(document).ready(function () {
	let currentCurrency = $("#active_currency_symbols").attr('current');
	let minNumber = '';
	let maxNumber = '';

	let currencyEUR = 4.3;

	initDeliverySettingsHTML()
	function initDeliverySettingsHTML() {
		// const deliverySettingsHTML = `
		// <div class="delivery-settings">
		// 	<div class="delivery-types">
    //     <div class="delivery-type delivery-type-eco">
    //       <input type="radio" id="delivdey-type-eco" name="delivdey-type" value="Ekonomiczna" checked>
    //       <label for="delivdey-type-eco"> Ekonomiczna</label>
    //     </div>
    //     <div class="delivery-type delivery-type-prem">
    //       <input type="radio" id="delivdey-type-prem" name="delivdey-type" value="Priorytetowa">
    //       <label for="delivdey-type-prem"> Priorytetowa</label>
    //     </div>
		// 	</div>
		// 	<div class="delivery-country-list">
		// 		<select name="county-list" id="country-select">
		// 			<option value="" disabled selected>Proszę wybrać kraj do wysyłki</option>
		// 		</select>
		// 	</div>
		// </div>
		// `
    const deliverySettingsHTML = `
		<div class="delivery-settings">
			<div class="delivery-types">
        <div class="delivery-type delivery-type-prem">
          <input type="radio" id="delivdey-type-prem" name="delivdey-type" checked value="Priorytetowa">
          <label for="delivdey-type-prem"> Priorytetowa</label>
        </div>
			</div>
			<div class="delivery-country-list">
				<select name="county-list" id="country-select">
					<option value="" disabled selected>Proszę wybrać kraj do wysyłki</option>
				</select>
			</div>
		</div>
		`
		$(".carriers-calc").parent().prepend(deliverySettingsHTML)
	}

	setCountryToSelect()
	function setCountryToSelect () {
		$('#country-select').empty();
		checkCountrySelected()
		if(checkDeliveryType() === "Ekonomiczna"){
			initCountryToSelect(countriesEconom)
		} else if(checkDeliveryType() === "Priorytetowa"){
			initCountryToSelect(countriesPriority)
		}
	}

	function initCountryToSelect(countrysType) {
		$('#country-select').append('<option value="" disabled selected>Proszę wybrać kraj do wysyłki</option>');
		$.each(countrysType, function(index, value) {
			$('#country-select').append('<option value="' + value.zone + '">' + value.name + '</option>');
		});
	}

	checkMinMaxRange()
	initDeliverySlider(1000, 20000)

	function initDeliverySlider(minRange, maxRange) {
		const rangeSlider = `
			<div class="range-box">
				<input type="range" min="${minRange}" max="${maxRange}" step="1000" value="0" id="slider">
				<output class="range-output">
				</output>
			</div>
		`
		$(".carriers-calc").parent().append(rangeSlider)
	}

	$("#country-select").on("input", function () {
		$(".carriers-calc .carriers-calc-body .poczta_polska .carriers-name").text(`Poczta Polska (${$(this).find('option:selected').text()})`)
		getCountryFromZone()
	})

	$("#slider").on("input", function () {
		showAndHideRows()
		getCountryFromZone()
	})

	function checkMinMaxRange() {
		$("tr[class^='pocztex-']").each(function () {
			const classes = $(this).attr("class").split("-");

			const number1 = parseInt(classes[1]);
			const number2 = parseInt(classes[2]);

			if (number1 < minNumber) {
				minNumber = number1;
			}

			if (number2 < minNumber) {
				minNumber = number2;
			}

			if (number1 > maxNumber) {
				maxNumber = number1;
			}

			if (number2 > maxNumber) {
				maxNumber = number2;
			}
		});
	}

	showAndHideRows()
	getCountryFromZone()
	checkCountrySelected()

	function getCountryFromZone() {
		checkCountrySelected()

		if(checkDeliveryType() === "Ekonomiczna"){
			switch ($("#country-select").val()){
				case '10':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '11':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '12':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '13':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '20':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '30':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case '40':
					setDeliveryPrice(...zoneEconom.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				default:
			}
		} else if(checkDeliveryType() === "Priorytetowa"){
			switch ($("#country-select").val()){
				case 'A1':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'A2':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'A3':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'A4':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'A5':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'B':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'C':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				case 'D':
					setDeliveryPrice(...zonePriority.filter(i => i.zone == $("#country-select").val() && i.weight == $("#slider").val() / 1000 ))
				default:
			}
		}
		$(".carriers-calc .carriers-calc-body .poczta_polska .carriers-weight").text($("#slider").val() / 1000 + " kg")
	}

	function checkCountrySelected(){
		if(!$("#country-select").val()) {
      $(".carriers-calc").hide();
      $(".box_title").hide();
      $(".range-box").hide();
			// $(".carriers-calc .poczta_polska").hide();
		} else {
      $(".carriers-calc").show();
      $(".box_title").show();
      $(".range-box").show();
			// $(".carriers-calc .poczta_polska").show();
		}
	}

	function checkDeliveryType(){
		return $('.delivery-type input[name=delivdey-type]:checked').val()
	}

	$(".delivery-type input[name=delivdey-type]").on("click", function() {
		setCountryToSelect()
	})

	function setDeliveryPrice(props) {
		if (!props){return;}
		if (currentCurrency == "PLN") {
			$(".carriers-calc .carriers-calc-body .poczta_polska .carriers-price").text(`${props.price.toFixed(2)} PLN`)
		} else {
			$(".carriers-calc .carriers-calc-body .poczta_polska .carriers-price").text(`${(props.price / currencyEUR).toFixed(2)} EUR`)
		}
	}

	function showAndHideRows () {
		var weight = parseInt($("#slider").val())
		$(".carriers-calc-body tr").hide()
		$(".carriers-calc-body tr").each(function () {
			var range = $(this).attr("class").split("-").slice(1).map(Number)
			if (weight >= range[0] && weight <= range[1]) {
				$(this).show()
			}
		})
	}

  $(".resetcss").each(function () {
		const range = $(this).find("#slider");
		const bubble = $(this).find(".range-output");

		range.on("input", function () {
			setBubble(range, bubble);
		});
		setBubble(range, bubble);
	});

	function setBubble(range, bubble) {
		const val = range.val();
		const min = range.attr("min") ? range.attr("min") : 0;
		const max = range.attr("max") ? range.attr("max") : 100;
		const newVal = Number(((val - min) * 100) / (max - min));
		bubble.html(`${val / 1000} kg`);
		bubble.css("left", `calc(${newVal}% + (${8 - newVal * 0.15}px))`);
	}
})
