
function fokus(odp)
{
  var el = document.getElementById(odp);
  if (el) el.focus();
}



$(document).ready(function(){




 $('.intab').keyup(function(event){
    if (event.keyCode == 39) {
      $(this).parent().parent().children().children('.intab').next('.intab').focus();
      
      index = parseInt($(this).attr('tabindex'));
      index = index-1;
      
      $(this).parent().parent().parent().children().children().children('.intab').each(function(){
        if ($(this).attr('tabindex')==index) $(this).focus();
      });
    }
    if (event.keyCode == 37) {
      $(this).prev('.intab').focus();
      $(this).parent().parent().children().children('.intab').next('.intab').focus();
      index = parseInt($(this).attr('tabindex'));
      index = index+1;
      $(this).parent().parent().parent().children().children().children('.intab').each(function(){
        if ($(this).attr('tabindex')==index) $(this).focus();
      });
      
    }
  });




  $('.ltab').keyup(function(event){
    if (event.keyCode == 39) {
      index = parseInt($(this).attr('tabindex'));
      index = index+1;
      $(this).parent().parent().parent().children().children().children('.ltab').each(function(){
        if ($(this).attr('tabindex')==index) $(this).focus();
      });
    }
    if (event.keyCode == 37) {
      index = parseInt($(this).attr('tabindex'));
      index = index-1;
      $(this).parent().parent().parent().children().children().children('.ltab').each(function(){
        if ($(this).attr('tabindex')==index) $(this).focus();
      });

    }
  });





  
$('input[type="text"]').keyup(function(event){
  if (event.keyCode == 39) {
    $(this).next('input[type="text"]').focus();
  }
  if (event.keyCode == 37) {
    $(this).prev('input[type="text"]').focus();
  }
});

$('#form1 input[type="text"]').bind('keydown', function(event){
  if (event.keyCode == 32) {
    return false;
  }
  else return true;
});

   
   

$('.cat').click(function(){
  $(this).parent().parent().children('div').slideToggle('slow');
});

$('.test').click(function(){
  odp = $(this).html();
  $('#odp').val(odp);
  $('#form1').submit();
});

$('#dodaj_button').click(function(){
  $('#dodaj_komentarz').submit();
});

$('#rozwiaz').click(function(){
  var spr = $('#odp').val();
  if (spr=='') {
    alert('Musisz co\u015b wpisać');
    return false;
  }
  else return true;
});



$('#fb').hover(function(){
$(this).css('right','-10px');
},function(){
$(this).css('right','-208px');
}
);




});

