var news_it = 0;



function show_news_item(cnt, anim)
{
  
  if( cnt >= $('table.novinky').find('tr.nadpis').size() )
  {
    cnt = 0;
  }
  
  var nadpis = $('table.novinky').find('tr.nadpis').eq(cnt).find('td').eq(0).text();
  var telo   = $('table.novinky').find('tr.obsah').eq(cnt).find('td').eq(0).text();
  var src    = $('table.novinky').find('tr.obsah').eq(cnt).find('img').attr('src');
  
  /*
  $('div.news').find('.text').find('span').eq(0).html(nadpis);
  $('div.news').find('.text').find('span').eq(1).html(telo);
  $('div.news').find('.img').find('img').attr('src', src);
  */
  
  if( anim )
  {
    $('div.news').fadeTo
    ( 
      350, 0, 
      
      function()
      {
        $('div.news').find('.text').find('span').eq(0).html(nadpis);
        $('div.news').find('.text').find('span').eq(1).html(telo);
        $('div.news').find('.img').find('img').attr('src', src);
        
        $('div.news').fadeTo
        ( 
          350, 1
        );
        
      } 
    );
  }
  
  news_it = cnt + 1;
}


$(document).ready
(
  function()
  {
    var nadpis = $('table.novinky').find('tr.nadpis').eq(0).find('td').eq(0).text();
    var telo   = $('table.novinky').find('tr.obsah').eq(0).find('td').eq(0).text();
    
    $('div.news').find('.text').find('span').eq(0).html(nadpis);
    $('div.news').find('.text').find('span').eq(1).html(telo);
    
    show_news_item(news_it, false);
    window.setInterval( function() { show_news_item(news_it, true); }, 10000 );
  }
);

$(document).ready
  (
    function()
    {
      $("a[type^=\"lightbox\"]").each
      (
        function()
        {
          var t = $(this).attr('type');
              
              t = t.replace(/lightbox/i, '');
              t = t.replace(/\]/i, '');
              t = t.replace(/\[/i, '');
              
              $(this).attr('rel', t);
              
        }
      );
      
      $("a[type^=\"lightbox\"]").fancybox({
    		'transitionIn'	:	'elastic',
    		'transitionOut'	:	'elastic',
    		'speedIn'		:	200, 
    		'speedOut'		:	200, 
    		'overlayShow'	:	false
    	});
    }
  );
