function zalozka_click() {
  $('.zalozky').hide();
  $('a.zalozka').removeClass('act');
  $(this).addClass('act');
  var show = $(this).attr('id'); 
  $('#zalozka-'+show).show();
  //window.location.hash = show;
  $.cookie('zalozka_last', show);
  return false;
}

$(document).ready(function() {
  $("a[rel='gallery']").colorbox({opacity:0.80, current: '{current} / {total}'});
  $("a.video").colorbox({opacity:0.80, iframe:true, innerWidth:425, innerHeight:344});
  $(".pro_detail").each(function() {
    $(this).simpletip({ content: $("#detail-" + ($(this).attr('rel'))).html() });
  });
  $('a.titlebox').hover(
    function() { $('span.outer', this).stop(true, false).animate({top:150}, 'fast'); }, 
    function() { $('span.outer', this).stop(true, false).animate({top:240}, 'fast'); }
  );  
  // preklikavani zalozek
  $('a.zalozka').click(zalozka_click);
  $('.zalozky').hide();
  // zobrazeni prvni zalozky 
  var show = $('a.zalozka:first').attr('id');
  if ((window.location.hash == '') && ($.cookie('zalozka_last') != '')) {
    var cookie = $.cookie('zalozka_last'); 
    if ($('a#'+cookie).length != 0) show = cookie;
  }
  if (window.location.hash != '') show = window.location.hash.substring(1);
  $('a#'+show).addClass('act');
  $('#zalozka-'+show).show();
  $.cookie('zalozka_last', show);
  // zobrazeni zalozek
  $('#zalozky').show();
  // carousel na detailu produktu
  $('#product-detail-img-scroll').jcarousel({scroll:1});
  // filter
  $('#mark-filter input').change(function() { 
    if ($(this).attr('checked')) {
      if ($(this).hasClass('all')) {
        $('#mark-filter input').not('.all').attr('checked', false);
      } else {
        $('#mark-filter input.all').attr('checked', false);
      }
    } else {
      if ($('#mark-filter input:checked').length == 0) $('#mark-filter input.all').attr('checked', true); 
    }
    $('#filter').submit();
  });
  $('#orderby').change(function() {
    $('#filter').submit();
  });
  $('.expandable').each(function() {
    if ($(this).text().length < 200) return;
    var h = $(this).height(); 
    $(this).css('height','6.5em');
    $(this).append('<a href="#" class="more" rel="'+h+'">&nbsp;</a>');
    $(this).append('<a href="#" class="less" rel="'+h+'">&nbsp;</a>');
  });
  $('.expandable a.more').click(function() {
    var h = $(this).attr('rel');
    $(this).hide();
    $(this).parent().animate({height: h}, 1000, function() {
      $('a.less', $(this).parent()).show();
    });
    return false;
  });
  $('.expandable a.less').click(function() {
    $(this).hide();
    $(this).parent().animate({height: '6.5em'}, 1000, function() {
      $('a.more', $(this).parent()).show();
    });
    return false;
  }).hide();
});
