var osi_interval = 6000;

var int_ctx = null;

    function ReloadResponse(id, transport, ile, immediate) {
        if (!immediate) {
            $(id+'Box').setStyle({'height': $(id+'Box').getStyle('height')});
            
            Effect.Fade(id);
            setTimeout(function() {
                $(id).innerHTML = transport.responseText;
                Effect.Appear(id);
                setTimeout(function() {
                    $(id+'Box').setStyle({'height': $(id+'Box').getStyle('height')});
                }, 1000);
            },1000);
        } else {
            $(id+'Box').setStyle({'height': 'auto'});
            $(id).innerHTML = transport.responseText;
        }
    }
    
    function RelaodOfertyInwestycyjne(ile, immediate) {
        woj = $$('.lstWojewodztwa')[0].options[$$('.lstWojewodztwa')[0].selectedIndex].value;
        new Ajax.Request("ofertyinwestycyjne.aspx?ile="+ile, {
          method: 'get',
          onSuccess: function(transport) {
                ReloadResponse('sOfertyInwestycyjne', transport, ile, immediate);
           }
        });
    }
   
    
    function Powrot() {
        $('oi_wiecej').show();
        $('oi_powrot').hide();

        
        $('dvOfertyInwestycyjne').show();
        $('dvOfertyInwestycyjneAlt').hide();

        clearInterval(int_ctx);
        
        OSI_Counter(2);
    }
    
    function OSI_Run(count, immediate) {
        RelaodOfertyInwestycyjne(count, immediate);
    }
    
    function OSI_Counter(count) {
        OSI_Run(count, true);
        int_ctx = setInterval(function(){OSI_Run(count, false);}, osi_interval);
    }
    
    function osi_start() {
        OSI_Counter(1);
    }

