$(document).ready(function() {
    $('#infrastruktura').css({'display' : 'none'});
    $('#zgradbe').css({'display' : 'none'});
    
    $('#menuMiddle').mouseleave(function () {
        /*if(!$("#referencniProjekti").is(":hidden")) {
            $('#referencniProjekti').slideToggle('fast');
        }
        */

        if(!$("#infrastruktura").is(":hidden")) {
            $('#infrastruktura').slideToggle('fast');
        }

        if(!$("#zgradbe").is(":hidden")) {
            $('#zgradbe').slideToggle('fast');
        }
    });

    //menu referenčni projekti
    /*$('#menuMiddle #menuItem_referencniProjekti').hover(function () {
        if($("#referencniProjekti").is(":hidden")) {
            $('#referencniProjekti').slideToggle('fast');
        }
    });
    */
    //menu infrastruktura
    $('#menuMiddle #menuItem_infrastruktura').hover(function () {
        if($("#infrastruktura").is(":hidden")) {
            $('#infrastruktura').slideToggle('fast');
        }
    });

    //menu zgradbe
    $('#menuMiddle #menuItem_zgradbe').hover(function () {
        if($("#zgradbe").is(":hidden")) {
            $('#zgradbe').slideToggle('fast');
        }
    });
    
    $('#menuMiddle #menuItem_referencniProjekti').click(function (evt) {
        evt.preventDefault();
    });
    $('#menuMiddle #menuItem_infrastruktura').click(function (evt) {
        evt.preventDefault();
    });
    $('#menuMiddle #menuItem_zgradbe').click(function (evt) {
        evt.preventDefault();
    });
    
    $('#menuMiddle #menuItem_referencniProjekti').css({'cursor' : 'default'});
    $('#menuMiddle #menuItem_infrastruktura').css({'cursor' : 'default'});
    $('#menuMiddle #menuItem_zgradbe').css({'cursor' : 'default'});
});

function adjustPositions() {
    var windowHeight = $(window).height();
    var imgHeight = 937;
    
    if(windowHeight < imgHeight) {
        //console.log(1);
        //console.log("window height: " + windowHeight);
        $("#footerWrap").css({top: windowHeight - 24 + 'px', position: 'fixed'});
        $("#creditsWrap").css({top: windowHeight - 24 - 30 + 'px', position: 'fixed'});
    } else if(windowHeight > imgHeight && $('.contentWrap').height() < 775) {
        //console.log(2);
        $("#footerWrap").css({'bottom': windowHeight-imgHeight-24 + 'px', position: 'absolute'});
        $("#creditsWrap").css({'bottom': windowHeight-imgHeight-24+30 + 'px', position: 'absolute'});
    } else {
        //console.log(3);
        $("#footerWrap").css({'top' : windowHeight-24 + 'px'});
        $("#creditsWrap").css({'top' : windowHeight-24-30 + 'px'});
    }
    
    var contentHeight = $('#content').height();
    if(contentHeight == 372) {
        $(".galleryWrap").css({'position' : 'absolute', 'left' : '10px', 'bottom': '10px'});
    }
    
    
}
