/*$(function(){
  
  $('#navigace ul li ul').hide();
  
  $('#navigace ul li').bind('click', function(){
    //spočítat level schovat všechny stejný a menší
    level = 0;
    obj = $(this);
    while(obj.attr('tagName').toLowerCase() != 'div'){
      obj = obj.parent();
      level++;
    }
    level = (level/2);
    
    s = '#navigace ul li';
    for(i=0;i<=level;i++){
      s += ' ul';
    }
    //$(s+':visible').toggle('blind');
    //$(this).toggle('blind');
    
    $(this).find('>ul').toggle('blind');
    return false;
  });
  
  
});*/

function initMenu() {
  $('#navigace ul li ul').hide();
  $('#navigace li a').click(function() {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
      return false;
    }
    if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
      level = 0;
      obj = $(this);
      while(obj.attr('tagName').toLowerCase() != 'div'){
        obj = obj.parent();
        if(obj.attr('tagName').toLowerCase() == 'ul'){
          level++;
        }
      }
      s = '#navigace ul ';
      for(i=0;i<level;i++){
        s += ' ul';
      }  
      $(s+':visible').slideUp('normal');
      checkElement.slideDown('normal');
      return false;
    }
  });
  $('#navigace li a.actual').each(function(){
    obj = $(this);
    while(obj.attr('tagName').toLowerCase() != 'div'){
      if(obj.attr('tagName').toLowerCase() == 'ul'){
        obj.show();
      }
      obj = obj.parent();
    }
  });
}
$(document).ready(function() {
  initMenu();
});


Abtera_Eshop_Kosik = {
  changeDoprava: function(id, cena, cena_zbozi, vysledek){
    $('#'+vysledek).html(cena+cena_zbozi);
    $('table.doprava tr td:last-child strong').removeClass('actual');
    $('#doprava_'+id).parent().next().children().addClass('actual');
  }
}
