<h2>Sprzedaż | Mieszkania</h2>
<div class="content">
    <div id="gallery">
        <div id="gallery_image" class="shadow"></div>
        <div id="gallery_bottom_panel">
            <table width="590">
                <tr>
                    <td width="150" align="left"><a id="prev_image" href=""><?php echo ucfirst($this->site['poprzednie_zdjecie']); ?></a></td>
                    <td><div id="gallery_counter">0/0</div></td>
                    <td width="150" align="right"><a id="next_image" href=""><?php echo ucfirst($this->site['nastepne_zdjecie']); ?></a></td>
                </tr>
            </table>
        </div>
        <div id="gallery_links">
            <?php
                if(!empty($immovable['images']) && is_array($immovable['images']))
                {
                    foreach($immovable['images'] as $k=>$v)
                    {
                            $imgPath = '/files/img/galleries/'.$immovable['gallery_id'].'/'.$v['path'];
                            list($width, $height, $type, $attr) = getimagesize(substr($imgPath, 1));                        
                        echo '<a href="'.$imgPath.'" alt="" alt="'.$width.'__'.$height.'" ></a>';
                    }
                }
            ?>
        </div>
        <div id="gallery_item_data">
        <?php
            echo '<p>'.$immovable['localization'].'</p>';
            echo '<p>'.$immovable['area'].'</p>';
            echo '<p>'.$immovable['floor'].'</p>';
            echo '<p>'.$immovable['rooms'].'</p>';
            echo '<p>'.$immovable['garage_area'].'</p><br/><br/>';
            echo '<p>'.$immovable['description'].'</p>';
        ?>
            <a href="/<?php echo strtolower($lang['shortname']).'/'.url_title(strtolower($this->site['nieruchomosci'])).'.html'; ?>" class="offer_details_link">wróć</a>
        </div>
        
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        var currentImageIndex =0;
        var imageNumber = $("#gallery_links a").size();

        $("#gallery_links a").click(function(){
            var href= $(this).attr('href');
            var alt = $(this).attr('alt');
            var tmp = alt.split("__");

               $('#gallery_image').fadeOut('slow', function() {
                $("#gallery_image").html('<img src="'+href+'" width="'+tmp[0]+'" height="'+tmp[1]+'"/>');
                $(this).fadeIn('slow',function(){
                    applyShadow();        
                })
            });
            
            
        });

        function changePhoto()
        {
            $("#gallery_links a").filter(function(index){
             return index == currentImageIndex;
            }).click();
            $("#gallery_counter").text((currentImageIndex+1)+"/"+imageNumber);
        }
        changePhoto();
        
        $("#prev_image").click(function(){
            if(currentImageIndex >= 1)
            {
                currentImageIndex--;
                changePhoto();
            }
           return false;
        });
        $("#next_image").click(function(){
            if(currentImageIndex < (imageNumber-1))
            {
                currentImageIndex++;
                changePhoto();
            }
           return false;
        });
    });
</script>