

$(document).ready(function() {


    var exhW = $('#exhibit').width();
    var winH = $(window).height();
    var navW = $('#navigation').width();

    
    
    
    $('.page-10 #page-about').width(500 + exhW);




    $('#navigation').width(navW + 30);







    $('#container').height(winH - 157);

    $('#filtering-nav a').click(function(){
        $('#filtering-nav').children('li').each(function() {
            $(this).removeAttr('id');
        });
        $(this).parent('li').attr('id','active');
    });


    if ( $(".news-post").length ) {
        $('li.page-item-4').addClass('current_page_item');
    }



    var PageWorkW = 0;

    $('#page-work').children('img').each(function() {
        PageWorkW += $(this).width() + 15;
    });

    $('#page-work').width(PageWorkW);




});




$(window).load(
    function() {

        var PageWorkW = 0;

        $('#page-work').children('img').each(function() {
            PageWorkW += $(this).width() + 15;
        });

        $('#page-work').width(PageWorkW);






    });





$(document).ready(function() {
    
    
    
    $('.work-container').each(function() {

        var tempIndex = new Array;

        $(this).children('.thumb').each(function(index) {
            
            
            tempIndex[index] = index;
            
        });
        
        
        
        
        tempIndex.reverse();
        
        
        
        
       $(this).children('.thumb').each(function(index) {
            
            
            $(this).css('z-index', tempIndex[index]);
            
            
        });    
        
        
        
        
    });
    
    

});





$(window).load(
    function() { 
    
    
    
        $('.work-container').each(function() {
            $(this).children('.thumb').each(function() {
            
            
                var widthT = $(this).width();
                var heightT = $(this).height();
            
            
                var posLeft = Math.floor( (Math.random()) * ( $('.work-container').width() - widthT ) );
                var posTop = Math.floor( Math.random() * ( $('.work-container').height() - heightT ) );
            
            
            
                $(this).css('left', posLeft + 'px');
                $(this).css('top', posTop + 'px');
                
                $(this).css('visibility', 'visible');
            
            
            
            
            
            });
        }); 




    });













var over = false;

var temp = 0;
var aktualSTR = '';
var sum = 0;
var layers = new Array();


$(function() {
  
  
    $(".work-container").hover(function() {
        
       
        over = true;
        
        
            
                        
            
        
        $(this).children('.thumb').each( function(index) {
            layers[index] = parseInt($(this).css('z-index'));
            sum = index + 1;
        });
        
        
        layers.splice(sum,(layers.length-1)-sum+1);
        
        
        
        var aktualID = $(this).attr('id');
        
        rotuj(aktualID);
        
    }, function() {
        over = false;
    });
  
  
});



$(function() {


    $('.work-container').mouseleave(function() {
        
        over = false;
        $('#timer').stop(true,true);
        aktualSTR = '';
        
    });


});



function rotuj(aktual) {
  
  
    if (over) {
    
        $('#timer').show( 1, function() {
            
            rotuj_rew(aktual);
            
            
            
            aktualSTR = '#' + aktual;
            
            
            
            
            var lastEl = layers[layers.length-1];
            layers.pop();
            layers.unshift(lastEl);
            
            
            
            $(aktualSTR).children('.thumb').each(function(index) {
                $(this).css('z-index', layers[index]);
               
            });
            
            
            
             
            
            
        } );
    
    }
}




function rotuj_rew(aktual) {
  
    if (over) {
        $('#timer').hide( 400 , function() {
        
            rotuj(aktual);
        
        
        } );
    }
    
}



var resizeTimer = null;
$(window).bind('resize', function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(doSomething, 100);
});





function doSomething() {

    var winH = $(window).height();
    $('#container').height(winH - 157);

}


