/**
 * --------------------------------------------------------------------
 * Common functions
 * --------------------------------------------------------------------
 */
function fbs_click(fblink) {url=fblink.href;window.open(url,'sharer','toolbar=0,status=0,width=626,height=436');return false;}


/**
 * --------------------------------------------------------------------
 * On document ready routines
 * --------------------------------------------------------------------
 */
$(function(){

        /**
         * --------------------------------------------------------------------
         * links
         * --------------------------------------------------------------------
         */
        $("a:not([href^='http://www.uzlatehoselatka.cz'])").attr('target','_blank').addClass("external");
        $("a[href^='mailto:']").attr('target','').removeClass("external");
        $("a[href^='javascript:']").attr('target','').removeClass("external");
        $("a[href^='skype:']").attr('target','').removeClass("external");
        $("a[href^='/']").attr('target','').removeClass("external");
        $("a[href^='#']").attr('target','').removeClass("external");
        $("a[href='']").attr('target','').removeClass("external");

        /**
         * --------------------------------------------------------------------
         * lightbox
         * --------------------------------------------------------------------
         */
        $(function(){
            $("a[rel=lightbox], .lightbox a:has(img), .typography a:has(img)[href$='.png'], .typography a:has(img)[href$='.jpg']").lightBox({
                overlayOpacity: 0.6,
                containerResizeSpeed: 350,
                imageLoading: dirClientside+'/lib/jquery.lightbox/lightbox-ico-loading.gif',
                imageBtnClose: dirClientside+'/lib/jquery.lightbox/lightbox-btn-close.gif',
                imageBtnPrev: dirClientside+'/lib/jquery.lightbox/lightbox-btn-prev.gif',
                imageBtnNext: dirClientside+'/lib/jquery.lightbox/lightbox-btn-next.gif',
                imageBlank: dirClientside+'/lib/jquery.lightbox/lightbox-blank.gif'
           });
        });


      /**
       * --------------------------------------------------------------------
       * lightbox
       * --------------------------------------------------------------------
       */
      $('.preloaderWelcomeScreen img:last').load(function(){

        var target = $('.welcomeScreen');
        target.append('<div class="board top"></div>');
        var images = $('.preloaderWelcomeScreen img');
        var currentIndex = 0;

        function targetLoop()
        {
             // index of next image
             var nextIndex = (currentIndex + 1) % images.length;

             // create board with next image
             var nextBoard = $('<div class="board below"></div>')
             .css('background-image', 'url('+$(images[nextIndex]).attr('src')+')')
             .appendTo(target);

             // edit current board and plan fade out event
             $('.welcomeScreen .top')
             .delay(3000)
             .fadeOut('slow', function() {
                  $(this).remove();
                  $('.welcomeScreen .below').removeClass('below').addClass('top');
                  targetLoop();
             });

             currentIndex = nextIndex;
        }
        targetLoop();

      });
      
        

});

