var gazeta_pl = gazeta_pl || {};
gazeta_pl.gazetapraca = {
    Communication: {
        root:       'div#mod_statement',
        handle:     'div#mod_statement span.statement_toggle',
        masterList: 'div#mod_statement ul.communication',
        btnClose:   '.statement_close',
        rollTop:    'Zwiń szczegóły',
        rollDown:   'Rozwiń szczegóły',
        init: function() {
            var me = gazeta_pl.gazetapraca.Communication;
            me.onLoad();
            $( me.handle ).bind( 'click', me.onToggle );
            $( me.btnClose ).bind( 'click', me.onClose );
        },
        onToggle: function() {
            var 
                me  = gazeta_pl.gazetapraca.Communication,
                obj = $( this ).parents( 'li' ).find( 'ul' );
            if( obj.css( 'display' ) == 'none' ) {
                obj.show();
                $( this ).html( me.rollTop );
            } else {
                obj.hide();
                $( this ).html( me.rollDown );
            }
        },
        onClose: function() {
            $( gazeta_pl.gazetapraca.Communication.root ).hide();
        },
        onLoad: function() {
            var me = gazeta_pl.gazetapraca.Communication,
                elem = $(me.masterList).find('li ul');
                
            if (elem.length) {
              $( me.root ).css( 'height', $( me.masterList ).height() + 30 );
            }
        }
    }
}

$( gazeta_pl.gazetapraca.Communication.init );

function close_ann() {
		var close_announcemeny = document.getElementById("announcement_close_submit");
		close_announcemeny.click();		
}

