<?php
$this->placeholder("banner")->captureStart();

$this->template('/public/placeholder/main-menu.php');

$bannerImg = $this->document->getProperty('bannerImg');

if($this->displaySearchForm == '')
    if ($this->document->getProperty('showSearch') == '')
        $showSearch = false;
    else
        $showSearch = $this->document->getProperty('showSearch');
else
    $showSearch   = $this->displaySearchForm ;

if($this->displayLastComments == '')
    if ($this->document->getProperty('showComments') == '')
        $showComments = false;
    else
        $showComments = $this->document->getProperty('showComments');
else
    $showComments   = $this->displayLastComments ;


if ($bannerImg instanceof Pimcore\Model\Asset\Image)
    $this->bannerImg = $bannerImg;

?>


<header  class="<?= $showSearch ? "" : "no-search" ?>">
    <?php
        while($this->block("header-backgrounds")->loop()){
            if ($this->editmode)
                echo $this->image('header-background');
            else
                echo '<div class="banner-bg" style="background-image:url(' . $this->image('header-background')->getSrc() . ')"></div>';

        }
    ?>

    <?= $this->placeholder('main-menu') ?>

    <div id="inner-header" class="container">


        <div class="title">
            <h1><?= $this->input('RealAdvice') ?></h1>
            <p><?= $this->input('Phrase intro') ?></p>
        </div>

        <?php if(1) { echo $this->inc('/snippets/last-comments'); } ?>

        <?php if($showSearch) { ?>

            <form id="search" class="container" action="/<?= $this->lang ?>/search/results" method="get">
                <h2><?= $this->input('titre-formulaire') ?></h2>

                <?php
                if($this->editmode){
                    echo $this->input('nom-de-lagence');
                    echo $this->input('region-search');
                    echo $this->input('search');
                }else {
                    ?>

                    <input type="text" placeholder="<?= $this->input('nom-de-lagence') ?>" id="q_name" name="n" value="<?= $this->name ?>"/><input type="text" placeholder="<?= $this->input('region-search') ?>" id="q_location" name="l"  value="<?= $this->loc ?>"/><input class="icon-search" id="search_submit" type="submit" value="<?= $this->input('search') ?>"/>

                <?php } ?>
            </form>

            <script type="text/javascript">
                $('form#search').submit(function(event){
                    if( document.getElementById("q_name").value == "" && document.getElementById("q_location").value == ""  ){
                        $('form#search').addClass('hasError');
                        event.preventDefault();
                        return false;
                    }
                })
            </script>


        <?php } ?>

    </div>

</header>


<?php $this->placeholder("banner")->captureEnd(); ?>
