    //how many scroll downs and fit_contents can be done automatically
    var news_automatic_max = 3;
    var news_automatic_count = 0;
    var news_last = false;
    var news_waiting = false;
    //needed for checking the last action made by user
    function show_more_loading(link){
        //            $('#start_col_middle .box div.next_photos').show();
        //            $('#start_col_middle .box div.area_more').block({css:{width:'50%'},message:'<div class="loader"><div class="message">'+proper_link_text(link)+'</div><div class="image"> </div></div>'});
        link.closest('.more').addClass('loading');
    }

    // gets photos from specified gallery
    function get_news(link){
        news_waiting = true;
        var more_link;
        var ml;
        var more_news_list;
        $.ajax({
            type: 'POST',
            async: true,
            url: "/h/ajax/newsb",
            processData: false,
            data: "area_id="+_config.area_id+"&news_last_action_id="+news_last_action_id,
            dataType: 'json',
            beforeSend: function(){ 
            },
            success: function(msg){
                more_news_list = link.closest('.jq_more_list');
                more_link = link.closest('.more');
                more_link.removeClass('loading');
                ml = more_link.remove();
                more_news_list.append(msg.html);
                more_news_list.append(more_link);
                news_last_action_id = msg.news_last_action_id;
                if(msg.last=='1'){
                    link.closest('.more').hide();
                    news_last=true;
                }
                rerfesh_date();
                news_waiting = false;
            }
        });
    }

    function more_news(link){
        if(!news_last && !news_waiting){
            show_more_loading(link);
            get_news(link);
            news_automatic_count++;
        }
    }
    //--------------------------------------------------------------------------
    //-----------------== DOCUMENT READY ==-------------------------------------
    $(document).ready(function(){
        //------------------------ MORE PHOTOS CLICKED--------------------------
        // area more clicked
        $('#start_col_left .jq_more_list .more a').live('click',function(eve){
            eve.preventDefault();
            more_news($(this));
        });
        //----------------------------- SCROLLED DOWN ------------------------------
        // scrolled down - show more photos
        $(window).scroll(function(){
            if(!news_waiting){
                if($(window).scrollTop() >= ($(document).height() - $(window).height() - 5) && news_automatic_count < news_automatic_max){
                    more_news($('#start_col_left .jq_more_list .more a'));
                }
            }
        });
        //--------------------------------== END ==---------------------------------
    });

