<?php
if (!isset($_SESSION['nazwa'])) {
    header('Location: login.php');
    exit();
  }
?>

<link rel="stylesheet" href="css/audio.css" />

<div id="tab_tlo">
<h1 id="h3_tytul">Kraina dźwięków<small> wywiady/muzyka...</small></h1>  
<div id="taby" style="width: 840px">

    <a class="tab_link tab_link_wybrany" title="#tab1" href="#">Wywiady</a>
    <a class="tab_link" title="#tab2" href="#">Pianino</a>
    <a class="tab_link" title="#tab3" href="#">Komunikaty</a>
 
  <div class="clear">
    </div>
 
<div id="tab1" class="tab_text tab_wybrany">
  <div id="audio_tlo_osobie">
  <p id="audio_text"><b>Materiał dźwiękowy</b> - Poniżej zamieszczone są nagrania dźwiękowe, w których uczestnicy w kilku zdaniach</p>
  <p id="audio_text">opowiadają o sobie. </p>
<?php
	$lp = count($_SESSION['usersn']);
	for ($i=0; $i<$lp; $i++) {
		echo ' <div id="audio_tlo1">';
		echo '<p id="audio_p">'.$_SESSION['usersn'][$i].'</p>';
		echo '<audio id="audio1" controls>';
		echo '<source src="audio/wywiady/'.$_SESSION['usersn'][$i].'.mp3" type="audio/mp3">';
		echo '</audio></div>';
	}
?>
            
    </div>
</div>  

  <div id="tab2" class="tab_text">
    <div id="audio_tlo_klawisze">  
      <div id="audio_tlo_klawisze2">
        <input type="button" id="audio_but2" class="audio_nut1" Title="Gis" value=" 2">
        <input type="button" id="audio_but2" class="audio_nut3" Title="As" value="3">
        <div id="audio_but3"></div>
        <input type="button" id="audio_but2" class="audio_nut6" Title="Cis" value="5">
        <input type="button" id="audio_but2" class="audio_nut8" Title="Dis" value="6">
        <div id="audio_but3"></div>
        <input type="button" id="audio_but2" class="audio_nut11" Title="Fis" value="8">
        <input type="button" id="audio_but2" class="audio_nut13" Title="Gis" value="9">
        <input type="button" id="audio_but2" class="audio_nut15" Title="As" value="0">
        <div id="audio_but3"></div>    
        <input type="button" id="audio_but2" class="audio_nut18" Title="Cis" value="=">
        <input type="button" id="audio_but2" class="audio_nut20" Title="Dis" value="A">
        <div id="audio_but3"></div>
        <input type="button" id="audio_but2" class="audio_nut23" Title="Fis" value="D">
        <input type="button" id="audio_but2" class="audio_nut25" Title="Gis" value="F">
        <input type="button" id="audio_but2" class="audio_nut27" Title="As"  value="G">
        <div id="audio_but3"></div>    
        <input type="button" id="audio_but2" class="audio_nut30" Title="Cis" value="J">
        <input type="button" id="audio_but2" class="audio_nut32" Title="Dis" value="K">
        <div id="audio_but3"></div>  
        <input type="button" id="audio_but2" class="audio_nut35" Title="Fis" value=";">
      </div>
      <div id="audio_tlo_klawisze1">
        <input type="button" id="audio_but1" class="audio_nut0" Title="G" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Q">
        <input type="button" id="audio_but1" class="audio_nut2" Title="A" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; W">
        <input type="button" id="audio_but1" class="audio_nut4" Title="H" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E">
        <input type="button" id="audio_but1" class="audio_nut5" Title="C" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R">
        <input type="button" id="audio_but1" class="audio_nut7" Title="D" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T">
        <input type="button" id="audio_but1" class="audio_nut9" Title="E" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y">
        <input type="button" id="audio_but1" class="audio_nut10" Title="F" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; U">
        <input type="button" id="audio_but1" class="audio_nut12" Title="G" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I">
        <input type="button" id="audio_but1" class="audio_nut14" Title="A" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O">
        <input type="button" id="audio_but1" class="audio_nut16" Title="H" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; P">
        <input type="button" id="audio_but1" class="audio_nut17" Title="C" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ ">
        <input type="button" id="audio_but1" class="audio_nut19" Title="D" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ] ">  
        <input type="button" id="audio_but1" class="audio_nut21" Title="E" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Z">
        <input type="button" id="audio_but1" class="audio_nut22" Title="F" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X">
        <input type="button" id="audio_but1" class="audio_nut24" Title="G" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C">
        <input type="button" id="audio_but1" class="audio_nut26" Title="A" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; V">
        <input type="button" id="audio_but1" class="audio_nut28" Title="H" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B">
        <input type="button" id="audio_but1" class="audio_nut29" Title="C" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N">
        <input type="button" id="audio_but1" class="audio_nut31" Title="D" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M">
        <input type="button" id="audio_but1" class="audio_nut33" Title="E" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#44;">
        <input type="button" id="audio_but1" class="audio_nut34" Title="F" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#46;">
        <input type="button" id="audio_but1" class="audio_nut36" Title="G" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#47;">      
      </div>
    </div>
    <p id="audio_napis_piano">***&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pianino - Samgram&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;***</p>
    <div id="audio_nuty_tlo">
      <div id="audio_nuty_gora">
        Zagraj to sam - Nuty rozpisane na klawiaturę
      </div>
      <div id="audio_nuty">
        <p id="audio_nuty_tytul" style="text-align: center; color: #080;">
        Wlazł kotek na płotek wer. 1 - 
        <span style="color: #842; font-size: 0.9em; font-weight: normal;">Liczba nut: 18</span>
        </p>
        <p id="audio_nuty_tekst">
        C Z Z X&nbsp;&nbsp;&nbsp;] ] [ Z&nbsp;&nbsp;&nbsp;C C Z Z&nbsp;&nbsp;&nbsp;X ] ] [&nbsp;&nbsp;&nbsp;Z [      
      </div>
      <div id="audio_nuty_menu">
        <div id="audio_nuty_menu_poziom">
          Wybór utworu do nauki
          <select id="audio_wybierz_utwor">
            <option value="wu0">Wlazł kotek na płotek wer. 1</option>
            <option value="wu1">Wlazł kotek na płotek wer. 2</option>
            <option value="wu2">Sto lat wer. 1</option>
            <option value="wu3">Sto lat wer. 2</option>
            <option value="wu4">Zagraj mi piękny cyganie wer. 1</option>
            <option value="wu5">Zagraj mi piękny cyganie wer. 2</option>
            <option value="wu6">Prząśniczka wer. 1</option>
            <option value="wu7">Prząśniczka wer. 2</option>
            <option value="wu8">Podmoskiewski zmierzch wer. 1</option>
            <option value="wu9">Podmoskiewski zmierzch wer. 2</option>
            <option value="wu10">Gdybym miał gitarę</option>
            <option value="wu11">Hej sokoły</option>
            <option value="wu12">Szła dzieweczka do laseczka</option>
            <option value="wu13">Dla Elizy</option>
            <option value="wu14">Melodia z filmu Love Story</option>
          </select>
        </div>  
        <div id="audio_nuty_menu_poziom">
        Zagraj wybrany utwór
          <input id="button_menu3" style="margin: 5px 0 0 15px;" type="button" class="audio_graj" value="Graj">
          <input id="button_menu3" style="margin: 5px 0 0 15px;" type="button" class="audio_stop" value="Stop">
        </div>  
        <div id="audio_nuty_menu_poziom">
        Rozpocznij naukę gry
          <input type="button" id="button_menu3" class="audio_nauka" value="start">
        </div>
        <div id="audio_nuty_menu_poziom">
        <span id="audio_tryb">Tryb nauki - nieaktywny</span><br />
        Liczba nut do zagrania
          <input type="text" id="audio_nuty_info1" value="0">
          <div id="audio_dioda"></div>
        </div>  
      </div>
    </div>    
    </div>
  
  
  <div id="tab3" class="tab_text">
         <div id="audio_tlo_osobie">
  <p id="audio_text"><b>Komunikaty dźwiękowe Administratora</b></p>
<?php
	$nazwy  = glob('audio/komunikaty/*.mp3');
	$lp = count($nazwy);
	echo 'audio/wywiady/'.basename($nazwy[0]);
	for ($i=0; $i<$lp; $i++) {
		echo ' <div id="audio_tlo1">';
		echo '<p id="audio_p">'.basename($nazwy[$i]).'</p>';
		echo '<audio id="audio1" controls>';
		echo '<source src="audio/komunikaty/'.basename($nazwy[$i]).'" type="audio/mp3">';
		echo '</audio></div>';
	}
?>
       
    </div>
  
    </div>
  
</div>
</div>
<script type="text/javascript">

$(document).ready(function(){
  //--------Zmienne globalne
  var audio_komunikat_01 = new buzz.sound("audio/komunikaty/komunika_start.mp3");
  
  var nuta_G0 = new buzz.sound("audio/Nuty/G0.mp3");  
  var nuta_Gs0 = new buzz.sound("audio/Nuty/Gs0.mp3");
  var nuta_A0 = new buzz.sound("audio/Nuty/A0.mp3");
  var nuta_As0 = new buzz.sound("audio/Nuty/As0.mp3");
  var nuta_H0 = new buzz.sound("audio/Nuty/H0.mp3");
  var nuta_C1 = new buzz.sound("audio/Nuty/C1.mp3");
  var nuta_Cs1 = new buzz.sound("audio/Nuty/Cs1.mp3");
  var nuta_D1 = new buzz.sound("audio/Nuty/D1.mp3");
  var nuta_Ds1 = new buzz.sound("audio/Nuty/Ds1.mp3");
  var nuta_E1 = new buzz.sound("audio/Nuty/E1.mp3");
  var nuta_F1 = new buzz.sound("audio/Nuty/F1.mp3");
  var nuta_Fs1 = new buzz.sound("audio/Nuty/Fs1.mp3");
  var nuta_G1 = new buzz.sound("audio/Nuty/G1.mp3");
  var nuta_Gs1 = new buzz.sound("audio/Nuty/Gs1.mp3");
  var nuta_A1 = new buzz.sound("audio/Nuty/A1.mp3");
  var nuta_As1 = new buzz.sound("audio/Nuty/As1.mp3");
  var nuta_H1 = new buzz.sound("audio/Nuty/H1.mp3");
  var nuta_C2 = new buzz.sound("audio/Nuty/C2.mp3");
  var nuta_Cs2 = new buzz.sound("audio/Nuty/Cs2.mp3");
  var nuta_D2 = new buzz.sound("audio/Nuty/D2.mp3");
  var nuta_Ds2 = new buzz.sound("audio/Nuty/Ds2.mp3");
  var nuta_E2 = new buzz.sound("audio/Nuty/E2.mp3");
  var nuta_F2 = new buzz.sound("audio/Nuty/F2.mp3");
  var nuta_Fs2 = new buzz.sound("audio/Nuty/Fs2.mp3");
  var nuta_G2 = new buzz.sound("audio/Nuty/G2.mp3");
  var nuta_Gs2 = new buzz.sound("audio/Nuty/Gs2.mp3");
  var nuta_A2 = new buzz.sound("audio/Nuty/A2.mp3");
  var nuta_As2 = new buzz.sound("audio/Nuty/As2.mp3");
  var nuta_H2 = new buzz.sound("audio/Nuty/H2.mp3");
  var nuta_C3 = new buzz.sound("audio/Nuty/C3.mp3");  
  var nuta_Cs3 = new buzz.sound("audio/Nuty/Cs3.mp3");
  var nuta_D3 = new buzz.sound("audio/Nuty/D3.mp3");
  var nuta_Ds3 = new buzz.sound("audio/Nuty/Ds3.mp3");
  var nuta_E3 = new buzz.sound("audio/Nuty/E3.mp3");
  var nuta_F3 = new buzz.sound("audio/Nuty/F3.mp3");
  var nuta_Fs3 = new buzz.sound("audio/Nuty/Fs3.mp3");
  var nuta_G3 = new buzz.sound("audio/Nuty/G3.mp3");
  
  var demo_01 = new buzz.sound("audio/piano-demo/01_wlazl kotek.mp3");
  var demo_02 = new buzz.sound("audio/piano-demo/02_sto lat.mp3");
  var demo_03 = new buzz.sound("audio/piano-demo/03_zagraj mi piekny cyganie.mp3");
  var demo_04 = new buzz.sound("audio/piano-demo/05_przasniczka.mp3");
  var demo_05 = new buzz.sound("audio/piano-demo/06_podmoskiewski zmierzch.mp3");
  var demo_06 = new buzz.sound("audio/piano-demo/07_gdybym mial gitare.mp3");
  var demo_07 = new buzz.sound("audio/piano-demo/08_hej sokoly.mp3");
  var demo_08 = new buzz.sound("audio/piano-demo/09_szla dzieweczka.mp3");
  var demo_09 = new buzz.sound("audio/piano-demo/10_dla elizy.mp3");
  var demo_10 = new buzz.sound("audio/piano-demo/11_love story.mp3");
  
  var grupa = new buzz.sound([
    "audio/Nuty/C2.mp3", "audio/Nuty/D2.mp3", "audio/Nuty/E2.mp3"
  ]);
  
  var kolory_klawiszy = ['#fffff8', '#080808', '#fffff8', '#080808', '#fffff8', '#fffff8', '#080808', '#fffff8', '#080808', '#fffff8',
               '#fffff8', '#080808', '#fffff8', '#080808', '#fffff8', '#080808', '#fffff8', '#fffff8', '#080808', '#fffff8',
               '#080808', '#fffff8', '#fffff8', '#080808', '#fffff8', '#080808', '#fffff8', '#080808', '#fffff8', '#fffff8',
               '#080808', '#fffff8', '#080808', '#fffff8', '#fffff8', '#080808', '#fffff8'];
  var tekst_klawiszy = ['Q', '2', 'W', '3', 'E', 'R', '5', 'T', '6', 'Y', 'U', '8', 'I', 
              '9', 'O', '0', 'P', '[', '=', ']', 'A', 'Z', 'X', 'D', 'C', 'F', 
              'V', 'G', 'B', 'N', 'J', 'M', 'K', ',', '.', ';', '/'];  
              
  var gama1 = [nuta_G0, nuta_Gs0, nuta_A0, nuta_As0, nuta_H0, nuta_C1, nuta_Cs1, nuta_D1, nuta_Ds1, nuta_E1, 
         nuta_F1, nuta_Fs1, nuta_G1, nuta_Gs1, nuta_A1, nuta_As1, nuta_H1, nuta_C2, nuta_Cs2, nuta_D2, 
         nuta_Ds2, nuta_E2,  nuta_F2, nuta_Fs2, nuta_G2, nuta_Gs2, nuta_A2, nuta_As2, nuta_H2, nuta_C3,
         nuta_Cs3, nuta_D3,  nuta_Ds3, nuta_E3, nuta_F3, nuta_Fs3, nuta_G3];
  var utwory_demo = [demo_01, demo_01, demo_02, demo_02, demo_03, demo_03, demo_04, demo_04, demo_05, 
             demo_05, demo_06, demo_07, demo_08, demo_09, demo_10];
  
  var czas1 = [350, 250, 250, 250, 350, 250, 250, 1000, 350, 250, 250, 350, 250, 250, 1500,
               350, 250, 250, 250, 350, 250, 250, 750, 350, 250, 250, 350, 250, 250, 1000,
         350, 250, 250, 250, 350, 250, 250, 750, 350, 250, 250, 350, 250, 250, 2000];
         
  //-------------------------------------------------------------------------------------------  
  //wlazl kotek na plotek - wer. 1
  var utwor1 = [12, 9, 9, 10, 7, 7, 5, 9, 12, 12, 9, 9, 10, 7, 7, 5, 9, 5];
  
  //wlazl kotek na plotek - wer. 2
  var utwor2 = [24, 21, 21, 22, 19, 19, 17, 21, 24, 24, 21, 21, 22, 19, 19, 17, 21, 17];
  
  //Sto lat - wer. 1
  var utwor3 = [12, 9, 12, 9, 12, 14, 12, 10, 9, 10, 10, 7, 10, 7, 10, 12, 10, 9, 7, 9, 12, 12, 9, 12, 12, 9,
                12, 17, 16, 14, 13, 14, 16, 16, 16, 17];  
  //Sto lat - wer. 2
  var utwor4 = [24, 21, 24, 21, 24, 26, 24, 22, 21, 22, 22, 19, 22, 19, 22, 24, 22, 21, 19, 21, 24, 24, 21, 24, 24, 21,
                24, 29, 28, 26, 25, 26, 28, 28, 28, 29];          
          
  //Zagraj mi piekny Cyganie - wer. 1        
  var utwor5 = [12, 9, 10, 12, 14, 12, 12, 9, 12, 9, 10, 12, 14, 12, 16,
          16, 16, 16, 16, 14, 16, 14, 12, 14, 14, 14, 14, 12, 10, 9,
          16, 16, 16, 16, 14, 16, 14, 12, 14, 14, 14, 14, 12, 10, 9];
          
  //Zagraj mi piekny Cyganie - wer. 2
  var utwor6 = [24, 21, 22, 24, 26, 24, 24, 21, 24, 21, 22, 24, 26, 24, 28,
          28, 28, 28, 28, 26, 28, 26, 24, 26, 26, 26, 26, 24, 22, 21,
          28, 28, 28, 28, 26, 28, 26, 24, 26, 26, 26, 26, 24, 22, 21];        
  
  //Przasniczka - wer. 1
  var utwor7 = [7, 7, 10, 12, 14, 7, 7, 15, 14, 12, 14, 14, 14, 9, 14, 9, 10, 7, 10, 14, 9, 9, 10, 14, 17, 
                15, 14, 12, 10, 10, 12, 12, 9, 5, 14, 14, 15, 14, 12, 14, 19, 15, 12, 9, 14, 7];
  //Przasniczka - wer. 2
  var utwor8 = [19, 19, 22, 24, 26, 19, 19, 27, 26, 24, 26, 26, 26, 21, 26, 21, 22, 19, 22, 26, 21, 21, 22, 26, 29, 
                27, 26, 24, 22, 22, 24, 24, 21, 17, 26, 26, 27, 26, 24, 26, 31, 27, 24, 21, 26, 19];        

  //Podmoskiewski zmierzch - wer. 1
  var utwor9 = [2, 5, 9, 5, 7, 5, 4, 9, 7, 2, 5, 9, 12, 12, 14, 12, 10, 9, 11, 13, 
          16, 14, 9, 4, 2, 9, 7, 10, 12, 10, 9, 7, 5, 9, 7, 9, 11, 13, 16, 14, 
          9, 4, 2, 9, 7, 10, 12, 10, 9, 7, 5, 9, 7, 2];  
  //Podmoskiewski zmierzch - wer. 2
  var utwor10 = [14, 17, 21, 17, 19, 17, 16, 21, 19, 14, 17, 21, 24, 24, 26, 24, 22, 21, 23, 25, 
          28, 26, 21, 16, 14, 21, 19, 22, 24, 22, 21, 19, 17, 21, 19, 21, 23, 25, 28, 26, 
          21, 16, 14, 21, 19, 22, 24, 22, 21, 19, 17, 21, 19, 14];          
  
  //Gdybym mial gitare
  var utwor11 = [16, 19, 23, 21, 19, 23, 23, 18, 21, 19, 21, 23, 21, 24, 28, 26, 24, 28, 23, 23, 21, 19, 18, 
                21, 19, 19, 21, 23, 21, 24, 28, 26, 24, 28, 23, 23, 21, 19, 18, 21, 19, 19, 18, 16,
          16, 16, 19, 23, 21, 19, 23, 23, 18, 21, 19, 21, 23, 21, 24, 28, 26, 24, 28, 23, 23, 21, 19, 
          18, 21, 19, 19, 21, 23, 21, 24, 28, 26, 24, 28, 23, 23, 21, 19, 18, 21, 19, 19, 18, 16];  
  
  //Hej sokoly
  var utwor12 = [19, 22, 19, 22, 26, 26, 24, 22, 21, 24, 21, 24, 27, 27, 26, 24, 19, 22, 19, 22, 26, 26,
                24, 22, 26, 27, 26, 24, 22, 21, 19, 21, 22, 24, 26, 26, 29, 29, 27, 26, 29, 29, 29, 29, 29,
          31, 29, 27, 26, 24, 19, 22, 19, 22, 26, 26, 24, 22, 26, 27, 26, 24, 22, 21, 19, 21, 22, 24,
          26, 26, 29, 29, 27, 26, 29, 29, 29, 29, 29, 31, 29, 27, 26, 24, 19, 22, 19, 22, 26, 26, 24, 
          22, 26, 27, 26, 24, 22, 21, 19, 18, 19 ];
    
  //Szla dzieweczka do laseczka
  var utwor13 = [19, 24, 28, 26, 24, 23, 24, 23, 21, 19, 19, 16, 17, 19, 17, 17, 14, 16, 17, 19, 19, 16, 17, 
           19, 19, 24, 28, 26, 24, 23, 24, 23, 21, 19, 19, 16, 17, 19, 17, 17, 14, 16, 17, 19, 19,
           28, 26, 24, 28, 28, 24, 28, 28, 24, 28, 29, 28, 26, 26, 26, 23, 26, 26, 23, 26, 28, 26, 24,
           28, 28, 24, 28, 28, 24, 28, 29, 28, 26, 29, 28, 26, 24, 23, 21, 19, 21, 23, 24];
  
  //Dla Elizy
  var utwor14 = [33 ,32, 33, 32, 33, 28, 31, 29, 26, 17, 21, 26, 28, 21, 25, 28, 29, 21, 33, 32, 33, 32, 33, 28, 31, 29, 26, 
          17, 21, 26, 28, 21, 29, 28, 26, 28, 29, 31, 33, 24, 34, 33, 31, 22, 33, 31, 29, 21, 31, 29, 28, 21, 33,
          32, 33, 32, 33, 32, 33, 32, 33, 28, 31, 29, 26, 17, 21, 26, 28, 21, 25, 28, 29, 21, 33, 32, 
          33, 32, 33, 28, 31, 29, 26, 17, 21, 26, 28, 19, 29, 28, 26
          ];

  //Melodia z filmu Love Story"
  var utwor15 = [27, 19, 19, 27, 27, 19, 19, 27, 27, 19, 20, 19, 17, 17, 17, 26, 26, 17, 17, 26, 26, 17, 19, 17, 
           15, 15, 15, 24, 24, 15, 15, 24, 24, 15, 17, 15, 14, 14, 14, 23, 23, 24, 26, 20, 19, 27, 19, 19, 
           27, 27, 19, 19, 27, 27, 19, 20, 19, 17, 17, 17, 26, 26, 17, 17, 26, 26, 17, 19, 17, 15, 15, 15, 
           24, 24, 15, 15, 24, 24, 15, 17, 15, 14, 14, 14, 23, 23, 24, 26, 23, 28, 29, 31, 24, 32, 24, 32, 
           24, 24, 26, 26, 29, 32, 22, 31, 22, 22, 24, 24, 27, 31, 27, 29, 26, 29, 26, 27, 29, 31, 24, 27, 
           31, 32, 20, 24, 27, 27, 26, 26, 27, 29, 20, 19, 20, 22, 26, 26, 24, 24, 24, 22, 20, 19, 18, 21, 
           24, 21, 23, 27, 19, 19, 27, 27, 19, 19, 27, 27, 19, 20, 19, 17, 17, 17, 26, 26, 17, 17, 26, 26, 
           17, 19, 17, 15, 15, 15, 24, 24, 15, 15, 24, 24, 15, 17, 15, 14, 14, 14, 22, 22, 24, 26, 23, 24];
          
  var lista_utworow = [utwor1, utwor2, utwor3, utwor4, utwor5, utwor6, utwor7, utwor8, utwor9, utwor10, utwor11,
               utwor12, utwor13, utwor14, utwor15];
  
  var stan_klawiszy = [
  ];
  
  
  //Zmienne dla nauka gry
  var audio_nauka_start = false;
  var audio_nauka_demo = false;
  var audio_nauka_lp=0;  
  var audio_nauka_bledy=0;
  var audio_nauka_numer_utworu=0;
  var audio_nauka_dioda=0;
  //-------------------------
  audioStart();
  
  
  //---------WYWIADY - Material dzwiekowy-------------
        $(".tab_wybrany").fadeIn();

        $(".tab_link").on("click", function(event){
            event.preventDefault();
            $(".tab_link_wybrany").removeClass("tab_link_wybrany");
            $(this).addClass("tab_link_wybrany");
            var container_id = $(this).attr("title");
      $('.tab_wybrany').animate({
          height: "toggle",
          opacity: "toggle"}, 
          {
          duration: 500,
          easing: 'easeOutBack',
          complete: function() {
            $(this).removeClass("tab_wybrany");
            $(container_id).addClass("tab_wybrany");
            $(".tab_wybrany").animate({
              height : "toggle", 
              opacity : "toggle"},
              {duration: 1000,
              easing: 'easeOutBounce',}
              );
          }});
        });
    //-----------------------------------------------------------------
    
    function audioStart() {
      for (i=0; i<37; i++) {
        stan_klawiszy[i]=true;
      }
    }

  function naukaSprawdz(nrk) {
    if (lista_utworow[audio_nauka_numer_utworu][audio_nauka_lp]==nrk) {
      odtworzNute(nrk);
      $(".audio_nut"+lista_utworow[audio_nauka_numer_utworu][audio_nauka_lp]).css("background-color", kolory_klawiszy[nrk]);
      
      audio_nauka_lp++;
      $('#audio_nuty_info1').val(lista_utworow[audio_nauka_numer_utworu].length-audio_nauka_lp);
      if (audio_nauka_lp < lista_utworow[audio_nauka_numer_utworu].length) {
        $(".audio_nut"+lista_utworow[audio_nauka_numer_utworu][audio_nauka_lp]).css("background-color", "#dd0");
      } else {
        audio_nauka_start = false;
        $('#audio_tryb').html('Tryb nauki - nieaktywny');
        $("#audio_dioda").css("border-color", '#800');
        $("#audio_dioda").css("background-color", '#e00');
        $('.audio_nauka').val('Start');
        $("#audio_wybierz_utwor").show(500);
        for (i=0; i<37; i++) {
          $(".audio_nut"+i).css("background-color", kolory_klawiszy[i]);
        }
      }
    } else {
      audio_nauka_bledy++;
    }
  }
  
  function odtworzNute(nrk) {
    gama1[nrk].stop();
    gama1[nrk].play();
  }
  
  //Klawisze - klik
  $('.audio_nut0').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(0);
    } else {
      odtworzNute(0);
    }
  });
  
  $('.audio_nut2').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(2);
    } else {
      odtworzNute(2);
    }
  });
  
  $('.audio_nut4').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(4);
    } else {
      odtworzNute(4);
    }
  });
  
  $('.audio_nut5').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(5);
    } else {
      odtworzNute(5);
    }
  });
  
  $('.audio_nut7').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(7);
    } else {
      odtworzNute(7);
    }
  });
  
  $('.audio_nut9').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(9);
    } else {
      odtworzNute(9);
    }
  });
  
  $('.audio_nut10').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(10);
    } else {
      odtworzNute(10);
    }
  });
  
  $('.audio_nut12').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(12);
    } else {
      odtworzNute(12);
    }
  });
  
  $('.audio_nut14').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(14);
    } else {
      odtworzNute(14);
    }
  });
  
  $('.audio_nut16').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(16);
    } else {
      odtworzNute(16);
    }
  });
  
  $('.audio_nut17').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(17);
    } else {
      odtworzNute(17);
    }
  });
  
  $('.audio_nut19').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(19);
    } else {
      odtworzNute(19);
    }
  });
  
  $('.audio_nut21').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(21);
    } else {
      odtworzNute(21);
    }
  });
  
  $('.audio_nut22').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(22);
    } else {
      odtworzNute(22);
    }
  });
  
  $('.audio_nut24').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(24);
    } else {
      odtworzNute(24);
    }
  });
  
  $('.audio_nut26').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(26);
    } else {
      odtworzNute(26);
    }
  });
  
  $('.audio_nut28').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(28);
    } else {
      odtworzNute(28);
    }
  });
  
  $('.audio_nut29').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(29);
    } else {
      odtworzNute(29);
    }
  });
  
  $('.audio_nut31').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(31);
    } else {
      odtworzNute(31);
    }
  });
  
  $('.audio_nut33').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(33);
    } else {
      odtworzNute(33);
    }
  });
  
  $('.audio_nut34').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(34);
    } else {
      odtworzNute(34);
    }
  });
  
  $('.audio_nut36').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(36);
    } else {
      odtworzNute(36);
    }
  });
  
  //Nuty podwyzszone o pol tonu
  $('.audio_nut1').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(1);
    } else {
      odtworzNute(1);
    }
  });
  
  $('.audio_nut3').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(3);
    } else {
      odtworzNute(3);
    }
  });
  
  $('.audio_nut6').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(6);
    } else {
      odtworzNute(6);
    }
  });
  
  $('.audio_nut8').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(8);
    } else {
      odtworzNute(8);
    }
  });
  
  $('.audio_nut11').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(11);
    } else {
      odtworzNute(11);
    }
  });
  
  $('.audio_nut13').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(13);
    } else {
      odtworzNute(13);
    }
  });
  
  $('.audio_nut15').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(15);
    } else {
      odtworzNute(15);
    }
  });
  
  $('.audio_nut18').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(18);
    } else {
      odtworzNute(18);
    }
  });
  
  $('.audio_nut20').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(20);
    } else {
      odtworzNute(20);
    }
  });
  
  $('.audio_nut23').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(23);
    } else {
      odtworzNute(23);
    }
  });
  
  $('.audio_nut25').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(25);
    } else {
      odtworzNute(25);
    }
  });
  
  $('.audio_nut27').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(27);
    } else {
      odtworzNute(27);
    }
  });
  
  $('.audio_nut30').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(30);
    } else {
      odtworzNute(30);
    }
  });
  
  $('.audio_nut32').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(32);
    } else {
      odtworzNute(32);
    }
  });
  
  $('.audio_nut35').click (function() {
    if (audio_nauka_start==true) {
      naukaSprawdz(35);
    } else {
      odtworzNute(35);
    }
  });  
  //-----------------------------------------------------
  

  $(window).bind("keyup", function(e){  
    var klawkey = e.charCode || e.keyCode;
    switch(klawkey) {
        case 81:  //Q
          stan_klawiszy[0]=true;
          ustawKolor('0', 0);
          break;
        case 50:  //2
          stan_klawiszy[1]=true;
          ustawKolor('1', 2);
          break;
        case 87:   //W
          stan_klawiszy[2]=true;
          ustawKolor('2', 0);
          break;
        case 51:   //3
          stan_klawiszy[3]=true;
          ustawKolor('3', 2);
          break;  
        case 69:   //E
          stan_klawiszy[4]=true;
          ustawKolor('4', 0);
          break;
        case 82:   //R
          stan_klawiszy[5]=true;
          ustawKolor('5', 0);
          break;
        case 53:   //5
          stan_klawiszy[6]=true;
          ustawKolor('6', 2);
          break;  
        case 84:   //T
          stan_klawiszy[7]=true;
          ustawKolor('7', 0);
          break;
        case 54:   //6
          stan_klawiszy[8]=true;
          ustawKolor('8', 2);
          break;  
        case 89:   //Y
          stan_klawiszy[9]=true;
          ustawKolor('9', 0);
          break;
        case 85:   //U
          stan_klawiszy[10]=true;
          ustawKolor('10', 0);
          break;
        case 56:   //8
          stan_klawiszy[11]=true;
          ustawKolor('11', 2);
          break;  
        case 73:   //I
          stan_klawiszy[12]=true;
          ustawKolor('12', 0);
          break;
        case 57:   //9
          stan_klawiszy[13]=true;
          ustawKolor('13', 2);
          break;  
        case 79:   //O
          stan_klawiszy[14]=true;
          ustawKolor('14', 0);
          break;
        case 48:   //0
          stan_klawiszy[15]=true;
          ustawKolor('15', 2);
          break;  
        case 80:   //P
          stan_klawiszy[16]=true;
          ustawKolor('16', 0);
          break;
        case 219:   //[
          stan_klawiszy[17]=true;
          ustawKolor('17', 0);
          break;
        case 187:   //=
          stan_klawiszy[18]=true;
          ustawKolor('18', 2);
          break;  
        case 221:   //]
          stan_klawiszy[19]=true;
          ustawKolor('19', 0);
          break;
        case 65:   //A
          stan_klawiszy[20]=true;
          ustawKolor('20', 2);
          break;
        case 90:   //Z
          stan_klawiszy[21]=true;
          ustawKolor('21', 0);
          break;  
        case 88:   //X
          stan_klawiszy[22]=true;
          ustawKolor('22', 0);
          break;
        case 68:   //D
          stan_klawiszy[23]=true;
          ustawKolor('23', 2);
          break;  
        case 67:   //C
          stan_klawiszy[24]=true;
          ustawKolor('24', 0);
          break;
        case 70:   //F
          stan_klawiszy[25]=true;
          ustawKolor('25', 2);
          break;
        case 86:   //V
          stan_klawiszy[26]=true;
          ustawKolor('26', 0);
          break;
        case 71:   //G
          stan_klawiszy[27]=true;
          ustawKolor('27', 2);
          break;
        case 66:   //B
          stan_klawiszy[28]=true;
          ustawKolor('28', 0);
          break;
        case 78:   //N
          stan_klawiszy[29]=true;
          ustawKolor('29', 0);
          break;  
        case 74:   //J
          stan_klawiszy[30]=true;
          ustawKolor('30', 2);
          break;
        case 77:   //M
          stan_klawiszy[31]=true;
          ustawKolor('31', 0);
          break;  
        case 75:   //K
          stan_klawiszy[32]=true;
          ustawKolor('32', 2);
          break;
        case 188:   //,
          stan_klawiszy[33]=true;
          ustawKolor('33', 0);
          break;  
        case 190:   //.
          stan_klawiszy[34]=true;
          ustawKolor('34', 0);
          break;
        case 186:   //;
          stan_klawiszy[35]=true;
          ustawKolor('35', 2);
          break;
        case 191:   ///
          stan_klawiszy[36]=true;
          ustawKolor('36', 0);
          break;  
    }
    });
  
  $(window).bind("keydown", function(e){  
    var klawkey = e.charCode || e.keyCode;
    var czy_grac = true;
    var nrd = 0;
    switch(klawkey) {
        case 81:  //Q
          nrd=0;   //G0
          ustawKolor('0', 1);
          break;
        case 50:  //2
          nrd=1;     //Gis0
          ustawKolor('1', 1);
          break;
        case 87:   //W
          nrd=2;     //A0
          ustawKolor('2', 1);
          break;
        case 51:   //3
          nrd=3;     //As0
          ustawKolor('3', 1);
          break;  
        case 69:   //E
          nrd=4;     //H0
          ustawKolor('4', 1);
          break;
        case 82:   //R
          nrd=5;     //C1
          ustawKolor('5', 1);
          break;
        case 53:   //5
          nrd=6;     //Cis1
          ustawKolor('6', 1);
          break;  
        case 84:   //T
          nrd=7;     //D1
          ustawKolor('7', 1);
          break;
        case 54:   //6
          nrd=8;     //Dis1
          ustawKolor('8', 1);
          break;  
        case 89:   //Y
          nrd=9;     //E1
          ustawKolor('9', 1);
          break;
        case 85:   //U
          nrd=10;     //F1
          ustawKolor('10', 1);
          break;
        case 56:   //8
          nrd=11;     //Fis1
          ustawKolor('11', 1);
          break;  
        case 73:   //I
          nrd=12;     //G1
          ustawKolor('12', 1);
          break;
        case 57:   //9
          nrd=13;     //Gis1
          ustawKolor('13', 1);
          break;  
        case 79:   //O
          nrd=14;     //A1
          ustawKolor('14', 1);
          break;
        case 48:   //0
          nrd=15;     //As1
          ustawKolor('15', 1);
          break;  
        case 80:   //P
          nrd=16;     //H1
          ustawKolor('16', 1);
          break;
        case 219:   //[
          nrd=17;     //C2
          ustawKolor('17', 1);
          break;
        case 187:   //=
          nrd=18;     //Cis2
          ustawKolor('18', 1);
          break;  
        case 221:   //]
          nrd=19;     //D2
          ustawKolor('19', 1);
          break;
        case 65:   //A
          nrd=20;     //Dis2
          ustawKolor('20', 1);
          break;
        case 90:   //Z
          nrd=21;     //E2
          ustawKolor('21', 1);
          break;  
        case 88:   //X
          nrd=22;     //F2
          ustawKolor('22', 1);
          break;
        case 68:   //D
          nrd=23;     //Fis2
          ustawKolor('23', 1);
          break;  
        case 67:   //C
          nrd=24;     //G2
          ustawKolor('24', 1);
          break;
        case 70:   //F
          nrd=25;     //Gis2
          ustawKolor('25', 1);
          break;
        case 86:   //V
          nrd=26;     //A2
          ustawKolor('26', 1);
          break;
        case 71:   //G
          nrd=27;     //As2
          ustawKolor('27', 1);
          break;
        case 66:   //B
          nrd=28;     //H2
          ustawKolor('28', 1);
          break;
        case 78:   //N
          nrd=29;     //C3
          ustawKolor('29', 1);
          break;  
        case 74:   //J
          nrd=30;     //Cis3
          ustawKolor('30', 1);
          break;
        case 77:   //M
          nrd=31;     //D3
          ustawKolor('31', 1);
          break;  
        case 75:   //K
          nrd=32;     //Dis3
          ustawKolor('32', 1);
          break;
        case 188:   //,
          nrd=33;     //E3
          ustawKolor('33', 1);
          break;  
        case 190:   //.
          nrd=34;     //F3
          ustawKolor('34', 1);
          break;
        case 186:   //;
          nrd=35;     //Fis3
          ustawKolor('35', 1);
          break;
        case 191:   ///
          nrd=36;     //G3
          ustawKolor('36', 1);
          break;
        default:
           czy_grac=false;
           break;  
    }
    if (czy_grac) {
      if (stan_klawiszy[nrd]==true) {
        stan_klawiszy[nrd]=false;
        if (audio_nauka_start==true) {          
          naukaSprawdz(nrd);
        } else {
          gama1[nrd].stop();
          gama1[nrd].play();
        }
      }
    }
    event.preventDefault();
    });
  
  
  $('.audio_graj').click (function() {
    audio_nauka_demo=true;
    utwory_demo[audio_nauka_numer_utworu].stop();
    utwory_demo[audio_nauka_numer_utworu].play();
  });
  
  $('.audio_stop').click (function() {
    audio_nauka_demo=false;
    utwory_demo[audio_nauka_numer_utworu].stop();
  });
    
  function ustawKolor(klawisz, kolor) {
    if (audio_nauka_start==true) {
      if (lista_utworow[audio_nauka_numer_utworu][audio_nauka_lp]==klawisz) {
        $(".audio_nut"+klawisz).css("background-color", "#dd0");
      }
    } else {
      if (kolor==2) {
        $(".audio_nut"+klawisz).css("background-color", "#080808");
      }
      if (kolor==1) {
        $(".audio_nut"+klawisz).css("background-color", "#0a0");
      }
      if (kolor==0) {
        $(".audio_nut"+klawisz).css("background-color", "#fffff8");
      }
    }
  }    
    
    
  //---Nauka grania ---
  
  $('.audio_nauka').click (function() {
    if (!audio_nauka_start) {
      audio_nauka_start = true;
      audio_nauka_lp=0;
      audio_nauka_bledy=0;
      audio_nauka_dioda=0;
      audio_dioda();
      $('#audio_nuty_info1').val(lista_utworow[audio_nauka_numer_utworu].length-audio_nauka_lp);
      $('.audio_nauka').val('Stop');
      $('#audio_tryb').html('Tryb nauki - aktywny');
      $("#audio_dioda").css("border-color", '#080');
      $("#audio_dioda").css("background-color", '#0e0');
      $(".audio_nut"+lista_utworow[audio_nauka_numer_utworu][audio_nauka_lp]).css("background-color", "#dd0");
      $("#audio_wybierz_utwor").hide(500);
    } else {
      audio_nauka_start = false;
      $('#audio_tryb').html('Tryb nauki - nieaktywny');
      $("#audio_dioda").css("border-color", '#800');
      $("#audio_dioda").css("background-color", '#e00');
      $('.audio_nauka').val('Start');
      $('#audio_nuty_info1').val('0');
      $("#audio_wybierz_utwor").show(500);
      for (i=0; i<37; i++) {
        $(".audio_nut"+i).css("background-color", kolory_klawiszy[i]);
      }
    }
  });    
    
  
  $('#audio_wybierz_utwor').change(function() { 
    var nrup = audio_nauka_numer_utworu;
    var opcja = $('#audio_wybierz_utwor').val();
    var nru = opcja.slice(2, opcja.length);
    var lnut = lista_utworow[nru].length;
    var t = '';
    audio_nauka_numer_utworu=nru;
    var j=0;
    var k=0;
    for (i=0; i<lnut; i++) {
      t+=tekst_klawiszy[lista_utworow[audio_nauka_numer_utworu][i]]+'&nbsp;';
      j++;
      k++;
      if (j>3) {
        j=0;
        t+='&nbsp;&nbsp;&nbsp;';
      }
      if (k>23) {
        k=0;
        t+='<br />';
      }
    }
    $('#audio_nuty_tekst').html(t);
    var ln = '<span style="color: #842; font-size: 0.9em; font-weight: normal;">Liczba nut: '+lnut+'</span>';
    $('#audio_nuty_tytul').html($("#audio_wybierz_utwor option[value="+opcja+"]").text()+' - '+ln);
    
    if (audio_nauka_demo) {
      utwory_demo[nrup].stop();
      utwory_demo[audio_nauka_numer_utworu].play();
    }
  })
    
    
  function audio_dioda() {
    if (audio_nauka_start) {
      if (audio_nauka_dioda==0) {
        $("#audio_dioda").css("border-color", '#080');
        $("#audio_dioda").css("background-color", '#0b0');
      } else {
        $("#audio_dioda").css("border-color", '#090');
        $("#audio_dioda").css("background-color", '#0e0');
      }
      audio_nauka_dioda++;
      if (audio_nauka_dioda>1) audio_nauka_dioda=0;
      window.setTimeout(audio_dioda, 500);
      
    }
  }  
  
  //------------------------------------------------------------  
      
});
</script>