<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="HS mulligan">
    <meta name="author" content="Juraj">

    <title>HS mulligan</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/style.css?aaaaa" rel="stylesheet">

  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
<!--           <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button> -->
          <a class="navbar-brand" href="#">HS mulligan</a>
        </div>
<!--         <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
          </ul>
        </div> --><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
		<div class="starter-template">
			<div class="row" style="margin-bottom: 10px;">
				<?php 
$karty = $_POST['karty'];
$pocetpokusov = $_POST['kola'];

$jsonData = file_get_contents("AllSets.json");
$phpArray = json_decode($jsonData, true);

function vypocitaj_score_klasik($strategia, $nextcard1, $nextcard2, $nextcard3) {
	$score = 0;
	//turn 1
	$strategia[] = $nextcard1;
	if (($key = array_search('1', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	//turn 2
	$strategia[] = $nextcard1;
	if (($key = array_search('2', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}	
	}
	//turn 3
	$strategia[] = $nextcard2;
	if (($key = array_search('3', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('2', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);			
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}			
	}		
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.25;
		unset($strategia[$key]);
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}			
	}
	//turn 4
	$strategia[] = $nextcard3;
	if (($key = array_search('4', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('3', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}			
	}		
	elseif	(($key = array_search('2', $strategia)) !== FALSE) {	
		$score = $score + 0.25;
		unset($strategia[$key]);	
		if (($key = array_search('2', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.12; 
			unset($strategia[$key]);
		}	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.12; 
			unset($strategia[$key]);
		}			
	}
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.12;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.12; 
			unset($strategia[$key]);
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.12; 
			unset($strategia[$key]);
		}	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.12; 
			unset($strategia[$key]);
		}			
	}		
	return $score;
} 

function vypocitaj_score_rush($strategia, $nextcard1, $nextcard2, $nextcard3) {
	$score = 0;
	//turn 1
	$strategia[] = $nextcard1;
	if (($key = array_search('1', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	//turn 2
	$strategia[] = $nextcard1;
	if (($key = array_search('2', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.5; 
			unset($strategia[$key]);
		}	
	}
	//turn 3
	$strategia[] = $nextcard2;
	if (($key = array_search('3', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('2', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);			
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.5; 
			unset($strategia[$key]);
		}			
	}		
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.33;
		unset($strategia[$key]);
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.33; 
			unset($strategia[$key]);
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.33; 
			unset($strategia[$key]);
		}			
	}
	//turn 4
	$strategia[] = $nextcard3;
	if (($key = array_search('4', $strategia)) !== FALSE) {
		$score = $score + 1; 
		unset($strategia[$key]);
	}
	elseif	(($key = array_search('3', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.5; 
			unset($strategia[$key]);
		}			
	}		
	elseif	(($key = array_search('2', $strategia)) !== FALSE) {	
		$score = $score + 0.5;
		unset($strategia[$key]);	
		if (($key = array_search('2', $strategia)) !== FALSE) {
			$score = $score + 0.5; 
			unset($strategia[$key]);
			break;
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}			
	}
	elseif	(($key = array_search('1', $strategia)) !== FALSE) {	
		$score = $score + 0.25;
		unset($strategia[$key]);	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}	
		if (($key = array_search('1', $strategia)) !== FALSE) {
			$score = $score + 0.25; 
			unset($strategia[$key]);
		}			
	}		
	return $score;
} 

if(isset($_POST['karty'])) {
	echo "<p>Vybrali ste karty: <br>";
	echo "<ul style='list-style-type: none;'>";
	$i = 1;
	foreach ($karty as $karta){
		echo "<li style='float: left; width: 33%;'>" .$karta."</li>";
		$i++;
	}
	echo "</ul></p><br>";
	echo "<p>Počet kariet: <strong>" . $i . "</strong></p><br>";
	
	foreach ($karty as $karta){
		foreach ($phpArray['Basic'] as $key => $value) { 
			if ((($value['type'] == "Minion" && $value['collectible'] == true) || ($value['type'] == "Spell" && $value['collectible'] == true )) && $value['id'] == $karta) { 
				$carddata = [$value['name'], $value['cost']];
				$deck[] = $carddata;
			}
		}
		foreach ($phpArray['Classic'] as $key => $value) { 
			if ((($value['type'] == "Minion" && $value['collectible'] == true) || ($value['type'] == "Spell" && $value['collectible'] == true )) && $value['id'] == $karta) { 
				$carddata = [$value['name'], $value['cost']];
				$deck[] = $carddata;
			}
		}
		foreach ($phpArray['Curse of Naxxramas'] as $key => $value) { 
			if ((($value['type'] == "Minion" && $value['collectible'] == true) || ($value['type'] == "Spell" && $value['collectible'] == true )) && $value['id'] == $karta) { 
				$carddata = [$value['name'], $value['cost']];
				$deck[] = $carddata;
			}
		}
		foreach ($phpArray['Goblins vs Gnomes'] as $key => $value) { 
			if ((($value['type'] == "Minion" && $value['collectible'] == true) || ($value['type'] == "Spell" && $value['collectible'] == true )) && $value['id'] == $karta) { 
				$carddata = [$value['name'], $value['cost']];
				$deck[] = $carddata;
			}
		}		
	}
	
	$filename = "export.csv"; 
	$delimiter=",";
	$averages_no = array();
	$averages_one = array();
	$averages_two = array();
	$averages_three = array();
	if($_POST['prvy'] != '1') { $averages_four = array();}

    $f = fopen('export.csv', 'w');
	
	if($_POST['prvy'] != '1') {
		fputcsv($f, array('Card 1', 'Mana', 'Card 2', 'Mana', 'Card 3', 'Mana', 'Card 4', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'No drop score', 'One drop score', 'Two drop score', 'Three drop score', 'Four drop score'));
	}
	else {
		fputcsv($f, array('Card 1', 'Mana', 'Card 2', 'Mana', 'Card 3', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'Next card', 'Mana', 'No drop score', 'One drop score', 'Two drop score', 'Three drop score'));
	}
	
	for ($i = 1; $i <= $pocetpokusov; $i++) {
		$random = array_rand($deck, 11);
		$card1 = $deck[$random[0]][0];
		$value1 = $deck[$random[0]][1];
		$card2 = $deck[$random[1]][0];
		$value2 = $deck[$random[1]][1];
		$card3 = $deck[$random[2]][0];
		$value3 = $deck[$random[2]][1];			
		$card4 = $deck[$random[3]][0];
		$value4 = $deck[$random[3]][1];		
		$card5 = $deck[$random[4]][0];
		$value5 = $deck[$random[4]][1];
		$card6 = $deck[$random[5]][0];
		$value6 = $deck[$random[5]][1];		
		$card7 = $deck[$random[6]][0];
		$value7 = $deck[$random[6]][1];	
		$card8 = $deck[$random[7]][0];
		$value8 = $deck[$random[7]][1];
		$card9 = $deck[$random[8]][0];
		$value9 = $deck[$random[8]][1];
		$card10 = $deck[$random[9]][0];
		$value10 = $deck[$random[9]][1];	
		$card11 = $deck[$random[10]][0];
		$value11 = $deck[$random[10]][1];

		
		//No drop
		if($_POST['prvy'] != '1') {
			$nodroparray = [$value1, $value2, $value3, $value4];
		}
		else {
			$nodroparray = [$value1, $value2, $value3];
		}
		if($_POST['strategia'] == "klastrat") {
			$nodropscore = vypocitaj_score_klasik($nodroparray, $value5, $value6, $value7);
			}
		else {
			$nodropscore = vypocitaj_score_rush($nodroparray, $value5, $value6, $value7);
			}
		$averages_no[] = $nodropscore;		
		
		//One drop
		if($_POST['prvy'] != '1') {
			$onedroparray = [$value1, $value2, $value3, $value4];
		}
		else {
			$onedroparray = [$value1, $value2, $value3];
		}		
		$value = max($onedroparray);
		$key = array_search($value, $onedroparray);
		unset($onedroparray[$key]);
		$onedroparray[] = $value5;
		if($_POST['strategia'] == "klastrat") {
			$onedropscore = vypocitaj_score_klasik($nodroparray, $value6, $value7, $value8);
			}
		else {
			$onedropscore = vypocitaj_score_rush($nodroparray, $value6, $value7, $value8);
			}		 
		$averages_one[] = $onedropscore;
		
		//Two drop
		if($_POST['prvy'] != '1') {
			$twodroparray = [$value1, $value2, $value3, $value4];
		}
		else {
			$twodroparray = [$value1, $value2, $value3];
		}		
		$value = max($twodroparray);
		$key = array_search($value, $twodroparray);
		unset($twodroparray[$key]);
		$value = max($twodroparray);
		$key = array_search($value, $twodroparray);
		unset($twodroparray[$key]);		
		$twodroparray[] = $value5;
		$twodroparray[] = $value6;
		if($_POST['strategia'] == "klastrat") {
			$twodropscore = vypocitaj_score_klasik($twodroparray, $value7, $value8, $value9);
			}
		else {
			$twodropscore = vypocitaj_score_rush($twodroparray, $value7, $value8, $value9);
			}		
		$averages_two[] = $twodropscore;

		//Three drop
		if($_POST['prvy'] != '1') {
			$threedroparray = [$value1, $value2, $value3, $value4];
		}
		else {
			$threedroparray = [$value1, $value2, $value3];
		}		
		$value = max($threedroparray);
		$key = array_search($value, $threedroparray);
		unset($threedroparray[$key]);
		$value = max($threedroparray);
		$key = array_search($value, $threedroparray);
		unset($threedroparray[$key]);
		$value = max($threedroparray);
		$key = array_search($value, $threedroparray);
		unset($threedroparray[$key]);		
		$threedroparray[] = $value5;
		$threedroparray[] = $value6;
		$threedroparray[] = $value7;
		if($_POST['strategia'] == "klastrat") {
			$threedropscore = vypocitaj_score_klasik($threedroparray, $value8, $value9, $value10);
			}
		else {
			$threedropscore = vypocitaj_score_rush($threedroparray, $value8, $value9, $value10);
			}	
		$averages_three[] = $threedropscore;
		
		//Four drop
		if($_POST['prvy'] != '1') {
			$fourdroparray = [$value1, $value2, $value3, $value4];
			$value = max($fourdroparray);
			$key = array_search($value, $fourdroparray);
			unset($fourdroparray[$key]);
			$value = max($fourdroparray);
			$key = array_search($value, $fourdroparray);
			unset($fourdroparray[$key]);
			$value = max($fourdroparray);
			$key = array_search($value, $fourdroparray);
			unset($fourdroparray[$key]);		
			$fourdroparray[] = $value5;
			$fourdroparray[] = $value6;
			$fourdroparray[] = $value7;
			$fourdroparray[] = $value8;	
			if($_POST['strategia'] == "klastrat") {
				$fourdropscore = vypocitaj_score_klasik($fourdroparray, $value9, $value10, $value11);
				}
			else {
				$fourdropscore = vypocitaj_score_rush($fourdroparray, $value9, $value10, $value11);
				}	
			$averages_four[] = $fourdropscore;		
		}	
		
		if($_POST['prvy'] != '1') {
			$line = array($card1, $value1, $card2, $value2, $card3, $value3, $card4, $value4, $card5, $value5, $card6, $value6, $card7, $value7, $card8, $value8, $card9, $value9, $card10, $value10, $card11, $value11, $nodropscore, $onedropscore, $twodropscore, $threedropscore, $fourdropscore);
		}
		else {
			$line = array($card1, $value1, $card2, $value2, $card3, $value3, $card4, $value4, $card5, $value5, $card6, $value6, $card7, $value7, $card8, $value8, $card9, $value9, $card10, $value10, $card11, $value11, $nodropscore, $onedropscore, $twodropscore, $threedropscore);
		}
		
		fputcsv($f, $line, $delimiter);
		
	}
	
	echo "<strong>Priemerné score:</strong><br>";
	echo "Nezhadzovať: " . array_sum($averages_no) / count($averages_no) ."<br>";
	echo "Zhodiť 1 kartu: " . array_sum($averages_one) / count($averages_one)."<br>";
	echo "Zhodiť 2 karty: " . array_sum($averages_two) / count($averages_two)."<br>";
	echo "Zhodiť 3 karty: " . array_sum($averages_three) / count($averages_three)."<br>";
	if($_POST['prvy'] != '1') {
		echo "Zhodiť 4 karty: " . array_sum($averages_four) / count($averages_four)."<br>";
	}
	
	
	echo '<br><a href="export.csv" style="">Stiahnuť .CSV súbor</a><br><hr>';
}	

?>		
			</div>
			<div class="row">	
				<form class="form-horizontal" method="POST" action="">
				<div class="col-md-3">
					<label class="col-md-4 control-label" for="class-selector">Trieda</label>
					<div class="col-md-8">
						<select id="class-selector" class="form-control">
							<option value="druid">Druid</option>
							<option value="hunter">Hunter</option>					
							<option value="mage">Mage</option>
							<option value="paladin">Paladin</option>
							<option value="priest">Priest</option>			
							<option value="rogue">Rogue</option>
							<option value="shaman">Shaman</option>
							<option value="warrior">Warrior</option>
							<option value="warlock">Warlock</option>					
						</select>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<label class="col-md-4 control-label" for="strategia">Stratégia</label>
						<div class="col-md-8">
							<select id="strategia" name="strategia" class="form-control">
								<option value="klastrat">Klasik</option>
								<option value="rustrat">Rush</option>
							</select>
						</div>
					</div>
				</div>				
				<div class="col-md-3">
					<div class="form-group" id="prvy">
						<div class="form-group">
						  <label class="col-md-8 control-label" for="checkboxes">Hráč začína</label>
						  <div class="col-md-4">
							  <input type="checkbox" name="prvy" id="prvy" value="1" style="margin-top: 10px;">
						  </div>
						</div>
					</div>	
				</div>

				<div class="col-md-3">
					<div class="form-group">
						<label for="kola" class="col-md-8 control-label">Počet hier:</label>
						<div class="col-md-4">
							<input type="text" class="form-control" id="kola" name="kola">
						</div>	
					</div>
				</div>				
				<div class="col-md-1">
					<div class="form-group">			
						<button type="submit" class="btn btn-default">Vypočítať</button>
					</div>
				</div>				
				</div>			
			</div>
			
			<div class="row">
				

					<div class="col-md-3">
					<div class="row">
					<div class="" id="trieda">
						<h2>Karty triedy</h2>
						<?php

						
						$classArray = ["Druid", "Shaman","Mage","Paladin","Hunter","Priest","Rogue","Warrior","Warlock"];
						
						foreach($classArray as $trieda) {
						
							foreach ($phpArray['Basic'] as $key => $value) { 
								if (($value['type'] == "Minion" && $value['collectible'] == true && $value['playerClass'] == $trieda) || ($value['type'] == "Spell" && $value['collectible'] == true && $value['playerClass'] == $trieda)) { 
									echo '<div class="form-group triedne '. lcfirst($trieda) .'"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
								}
							}

							foreach ($phpArray['Classic'] as $key => $value) { 
								if (($value['type'] == "Minion" && $value['collectible'] == true && $value['playerClass'] == $trieda) || ($value['type'] == "Spell" && $value['collectible'] == true && $value['playerClass'] == $trieda)) { 
									echo '<div class="form-group triedne '. lcfirst($trieda) .'"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
								}
							}

							foreach ($phpArray['Curse of Naxxramas'] as $key => $value) { 
								if (($value['type'] == "Minion" && $value['collectible'] == true && $value['playerClass'] == $trieda) || ($value['type'] == "Spell" && $value['collectible'] == true && $value['playerClass'] == $trieda)) { 
									echo '<div class="form-group triedne '. lcfirst($trieda) .'"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
								}
							}

							foreach ($phpArray['Goblins vs Gnomes'] as $key => $value) { 
								if (($value['type'] == "Minion" && $value['collectible'] == true && $value['playerClass'] == $trieda) || ($value['type'] == "Spell" && $value['collectible'] == true && $value['playerClass'] == $trieda)) { 
									echo '<div class="form-group triedne '. lcfirst($trieda) .'"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
								}
							}	
								
							
						}
						?>
					</div>
					</div>
					</div>

					<div id="ostatne" class="col-md-9">
						<h2>Neutrálne karty</h2>

						<?php
						foreach ($phpArray['Basic'] as $key => $value) { 
							if (($value['type'] == "Minion" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray)) || ($value['type'] == "Spell" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray))) { 
								echo '<div class="form-group ostatne"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
							}
						}
						foreach ($phpArray['Classic'] as $key => $value) { 
							if (($value['type'] == "Minion" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray)) || ($value['type'] == "Spell" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray))) { 
								echo '<div class="form-group ostatne"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
							}
						}
						foreach ($phpArray['Curse of Naxxramas'] as $key => $value) { 
							if (($value['type'] == "Minion" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray)) || ($value['type'] == "Spell" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray))) { 
								echo '<div class="form-group ostatne"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
							}
						}
						foreach ($phpArray['Goblins vs Gnomes'] as $key => $value) { 
							if (($value['type'] == "Minion" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray)) || ($value['type'] == "Spell" && $value['collectible'] == true && !in_array($value['playerClass'], $classArray))) { 
								echo '<div class="form-group ostatne"><label class="col-md-9 control-label" for="checkboxes">'.$value['name'].'</label><div class="col-md-3 cehckboxiky"><input type="checkbox" name="karty[]" value="'.$value['id'].'"> <input type="checkbox" name="karty[]" value="'.$value['id'].'"> </div></div>';
							}
						}						
						?>	
					
					</div>

					<div class="form-group">			
						<button type="submit" class="btn btn-default">Vypočítať</button>
					</div>
				</form>
			</div>	
			

		</div>
    </div><!-- /.container -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
	$( document ).ready(function() {	
		$(".triedne").addClass("hidden");
		$(".druid").removeClass("hidden");
		
		$("#class-selector").change(function () {
			event.preventDefault();
			var end = this.value;
			$(".triedne").addClass("hidden");
			$("."+end).removeClass("hidden");
			//$("."+end).addClass("show");

		});		
	});	
	

	</script>
  </body>
</html>
