<div class="brown_box corner">
    <div class="small_box_padding">
        <h2><img src="/files/img/articles/nieruchomosci/sprzedaz_<?php echo strtolower($lang['shortname']); ?>.png" width="82" height="26"  alt="<?php echo strtolower($this->site['sprzedaz']); ?>"/></h2>
        <?php
            function countArrElements($arr,$building_type_id)
            {
                $result = 0;
                if(is_array($arr))
                {
                    foreach($arr as $k=>$v)
                        if($v['building_type_id'] == $building_type_id)
                            $result++;

                    return $result;
                }
                return $result;
            }


            $header_link = '/pl/'.$this->site['nieruchomosci'].'-mieszkania-sprzedaz.html';
            if(strtolower($lang["shortname"]) == "en")
                 $header_link = '/en/'.$this->site['nieruchomosci'].'-houses-sale.html';


        ?>
        
        <?php
            if(!empty($immovables) && is_array($immovables) && countArrElements($immovables,1) > 0)
            {
                echo '<h3><a href="'.$header_link.'">'.ucfirst($this->site['mieszkania']).'</a></h3>';
                echo '<ul class="gray_vert_list">';
                foreach($immovables as $k=>$v)
                {
                    if($v['building_type_id'] == 1)
                    {
                        $a_class= '';
                        if($selected_id == $v['id'])
                            $a_class = 'active';

                        echo '<li><a class="'.$a_class.'" href="/'.strtolower($lang['shortname']).'/'.url_title($this->site['nieruchomosc']).'/'.$v['id'].'.html'.'">'.$v['localization'].'</a></li>';
                    }
                }
                echo '</ul>';
            }
        ?>


        <?php
            $header_link = '/pl/'.$this->site['nieruchomosci'].'-lokale-sprzedaz.html';
            if(strtolower($lang["shortname"]) == "en")
                 $header_link = '/en/'.$this->site['nieruchomosci'].'-locals-sale.html';

            if(!empty($immovables) && is_array($immovables) && countArrElements($immovables,2) > 0)
            {
                echo '<h3><a href="'.$header_link.'">'.ucfirst($this->site['lokale_uzytkowe']).'</a></h3>';
                echo '<ul class="gray_vert_list">';
                foreach($immovables as $k=>$v)
                {
                    if($v['building_type_id'] == 2)
                    {
                        $a_class= '';
                        if($selected_id == $v['id'])
                            $a_class = 'active';

                        echo '<li><a class="'.$a_class.'" href="/'.strtolower($lang['shortname']).'/'.url_title($this->site['nieruchomosc']).'/'.$v['id'].'.html'.'">'.$v['localization'].'</a></li>';
                    }
                }
                echo '</ul>';
            }


            $header_link = '/pl/'.$this->site['nieruchomosci'].'-dzialki-sprzedaz.html';
            if(strtolower($lang["shortname"]) == "en")
                 $header_link = '/en/'.$this->site['nieruchomosci'].'-plots-sale.html';

            if(!empty($immovables) && is_array($immovables) && countArrElements($immovables,3) > 0)
            {
                echo '<h3><a href="'.$header_link.'">'.ucfirst($this->site['działki']).'</a></h3>';
                echo '<ul class="gray_vert_list">';
                foreach($immovables as $k=>$v)
                {
                    if($v['building_type_id'] == 3)
                    {
                        $a_class= '';
                        if($selected_id == $v['id'])
                            $a_class = 'active';

                        echo '<li><a class="'.$a_class.'" href="/'.strtolower($lang['shortname']).'/'.url_title($this->site['nieruchomosc']).'/'.$v['id'].'.html'.'">'.$v['localization'].'</a></li>';
                    }
                }
                echo '</ul>';
            }
        ?>
    </div>
</div>