$(function () {
    $('#nextNewsButton').click(function(){
        if($('#nextNews').is(':visible')){
            $('#nextNews').slideUp(200,function(){ $('#nextNewsButton').attr('src',WEBROOT + '/public/themes/images/btn-more-news.png') });
        } else {
            $('#nextNews').slideDown(200,function(){ $('#nextNewsButton').attr('src',WEBROOT + '/public/themes/images/btn-more-news-up.png') });
        }
    });
    
    var pageWidth = $('body').width();
    var pageHeight = ($('body').height() > $(window).height()) ? $('body').height() : $(window).height();
    
    if($('body').has('#akciaPopup').length){
        $('select').css('opacity',0);
        $('#akciaPopupOverlay').css({
            'width' : pageWidth + 'px'
           ,'height' : pageHeight + 'px'
           ,'z-index' : 100
           ,'opacity' : 0.6
        }).click(function(){
            $('#akciaPopupOverlay').remove();
            $('#akciaPopup').remove();
            $('select').css('opacity',1);
        }).show();
        
        var pWidth = $('#akciaPopup').width();
        $('#akciaPopup').css({
            'top' : $(window).scrollTop() + 110 + 'px'
           ,'left' : ((pageWidth - pWidth - 30) / 2) + 'px'
           ,'z-index' : 100
        }).show();
        
        $('#akciaPopup button').click(function(){
            $('#akciaPopupOverlay').remove();
            $('#akciaPopup').remove();
            $('select').css('opacity',1);
        });
    }
    
});



