$(document).ready(function() {
    $('.more').click(function(){
      $(this).parents('div.tresc').toggleClass('tresc-open');
      $(this).parents('div').children('div.tekst').toggleClass('tekst-none');
      
      if($(this).parent().parent().prev('.top-tresc').children('a').attr('id').length)
      {
        window.location='#'+$(this).parent().parent().prev('.top-tresc').children('a').attr('id');
      }
    });
    
    
    $('#image_button').click(function(){
      $('#popup').fadeIn('slow');
      return false;
    });
    $('.popup_close').click(function(){
      $('#popup').fadeOut('slow');
      return false;
    });
    
    /* open video after thumb clik */
     if($('#video_thumbs').length > 0 && $('#popup_content').length > 0)
    {
    $('#video_thumbs').each(function(){
      $(this).children('div').children('ul').children('li').children('a').click(function(event){
        event.preventDefault();

        var imgSrc = $(this).attr('href');
        if(imgSrc.indexOf('.flv') > 0 || imgSrc.indexOf('.f4v') > 0)
        {
          var flashvars = {  };
          var params = {
            bgcolor: "#FFFFFF",
            allowScriptAccess: "always",
            menu: "false",
            wmode: "transparent",
            flashVars: "movie=../"+imgSrc+"&autostart=false&startThumb=/images/player/startThumb.png&endThumb=/images/player/endThumb.png&iconColor=0xFF0000&progressBarColor=0xff0000&mainColor=0xffffff&bufferBarColor=0x989898&unbufferedBarColor=0xeeeeee"
          };
          swfobject.embedSWF("/player.swf", "popup_content", "600", "360", "6.0.65.0", "/swf/expressInstall.swf",  flashvars, params );
        }
        return false;
      });
    });
    $($('#video_thumbs').children('a')[0]).trigger('click');    
  }
  	     /* animacja dla video */
    if($('.jCarouselLite > ul > li').length > 1)
    {
      $(".jCarouselLite").jCarouselLite({
          btnNext: ".video_thumb_next_btn, .next",
          btnPrev: ".video_thumb_prev_btn, .prev",
          circular: true
      });
      
    } else if($('.jCarouselLite > ul > li').length == 1)
    {
      $(".video_thumb_prev_btn, .video_thumb_next_btn").css('display','none');
      $("#popup .jCarouselLite").css('margin-top','0');
    }
});

