/**
 * karosar.cz js
*/

function moveTop(button,element){
  if ($(button) && $(element)){
    $(button).click(function(){
      $(element).animate({scrollTop:0}, 'slow');
    });
  }
}

function refBox(){
  var btns = $('.description-btn');
  
  btns.click(function(btn){
    if ($(this).hasClass('closed')){
      $(this).removeClass('closed');
      $(this).parent().next().children('.description').slideDown();
    }
    else {
      $(this).addClass('closed');
      $(this).parent().next().children('.description').slideUp();
    }
  });
}

$(document).ready(function() {
  moveTop('#move-top','html, body');
  refBox();

  /*
  $(function() {
    $(".subnav").accordion({
      active: false,
      event: 'mouseenter',
      navigation: false,
      animated: 'slide',
      fillSpace: false,
      clearStyle: true
    });
  });
  */
  
  $(function() {
    $('#multibanner').before("<div id='mb-handles'>").cycle({
      fx: 'fade',
      timeout: 20000,
      pager: '#mb-handles'
    });
  });
  
  $(function() {
    $('#news-items').after("<div id='news-handles'>").cycle({
      fx: 'fade',
      timeout: 10000, 
      pager: '#news-handles',
      cleartypeNoBg: true
    });
  });

  $("#contact-forms input[type=file], #registration input[type=file]").filestyle({
    image: "gfx/images/input-file.gif",
    imageheight : 20,
    imagewidth : 68,
    width : 164
  });
  
    $bt = $('#bannertop');
    if($bt.length > 0){
        $bt.html('<marquee behavior="scroll" scrollamount="3" direction="left" width="922">'+$bt.html()+'</marquee>');
        $.getScript('js/jquery.marquee.js', function(){
             $bt.find('marquee').marquee();
        })
    }
    var lboxes = $('.thumb');
    if(lboxes.length > 0){
        $('head').append('<scr'+'ipt type="text/javascript" src="js/lightbox/lightbox.js"></sc'+'ript>').append('<li'+'nk rel="stylesheet" type="text/css" href="js/lightbox/lightbox.css" media="screen" />');
        lboxes.lightBox({
            	imageLoading: '/js/lightbox/loading.gif',
            	imageBtnClose: '/js/lightbox/close.gif',
            	imageBtnPrev: '/js/lightbox/prev.gif',
            	imageBtnNext: '/js/lightbox/next.gif',
                //txtImage: 'Obrázek',
                //txtOf: 'ze',
                containerResizeSpeed: 0
        });
    }
});
