<?php
/*
  Template Name: Home
 */

get_header();

if (have_posts()) : while (have_posts()) : the_post();
        ?>
        <div id="body" class="page-row page-row-expanded">
            <div class="container">
                <div id="content">
                    <div class="entry">
                        <?php the_content(__('Read more', 'am')); ?>
                        <div class="clear clearfix"></div>
                        <?php wp_link_pages(array('before' => '<div class="page-link"><p><span>' . __('Pages:', 'am') . '</span>', 'after' => '</p></div>')); ?>
                        <?php edit_post_link(__('Edit', 'am'), '<br /><p>', '</p>'); ?>
                    </div>
                </div>
                <!-- / content -->
                <?php
                $sections = get_field('sections');
                if ($sections):
                    foreach ($sections as $con):

                        if ($con["acf_fc_layout"] == "intro"):
                            ?>
                            <section class="intro">
                                <div class="holder">
                                    <h2><?php echo $con["title"]; ?></h2>
                                    <?php
                                    echo $con["text"];
                                    if ($con["button_title"] !== "" && $con["button_url"] !== ""):
                                        echo '<a class="btn white" href="' . $con["button_url"] . '">' . $con["button_title"] . '</a>';
                                    endif;
                                    ?>
                                </div>
                            </section>
                            <?php
                        endif;


                        if ($con["acf_fc_layout"] == "featured"):
                            ?>
                            <section id="home-the-arts" class="featured">
                                <div class="holder">
                                    <ul class="grid bg-image">
                                        <?php
                                        $olnymobile_arr = array(1, 3, 5, 7, 9, 11);
                                        foreach ($con["items"] as $key => $item):
                                            ?>
                                            <li>
                                                <div class="image <?php
                                                if (in_array($key, $olnymobile_arr)):
                                                    echo 'olnymobile';
                                                endif;
                                                ?>" style="background-image:url(<?php echo $item["image"]["sizes"]["thumb-684x356"] ?>);">
                                                    <img src="<?php echo $item["image"]["sizes"]["thumb-684x356"] ?>" alt="">
                                                </div>
                                                <div class="text-box">
                                                    <div class="text-holder">
                                                        <h3><?php echo $item["title"] ?></h3>
                                                        <?php echo $item["text"] ?>
                                                        <a class="btn popup_link" href="#booking"><?php _e('Get started', 'am') ?></a>
                                                    </div>
                                                </div>
                                                <?php
                                                if (in_array($key, $olnymobile_arr)):
                                                    ?>
                                                    <div class="image olnydesktop" style="background-image:url(<?php echo $item["image"]["sizes"]["thumb-684x356"] ?>);">
                                                        <img src="<?php echo $item["image"]["sizes"]["thumb-684x356"] ?>" alt="">
                                                    </div>
                                                    <?php
                                                endif;
                                                ?>
                                            </li>
                                            <?php
                                        endforeach;
                                        ?>
                                    </ul>
                                    <div id="booking" class="popup contact_form two-column">
                                        <?php
                                        if ($con["popup_title"] !== ""):
                                            echo '<h2 class="popup_title">' . $con["popup_title"] . '</h2>';
                                        endif;
                                        echo do_shortcode('[contact-form-7 id="' . $con["form_id"] . '"]');
                                        if ($con["text_after_form"] !== ""):
                                            ?>
                                            <div class="popup_footer">
                                                <h3><?php echo $con["text_after_form"]; ?></h3>
                                            </div>
                                            <?php
                                        endif;
                                        ?>
                                    </div>
                                </div>
                            </section>
                            <?php
                        endif;


                        if ($con["acf_fc_layout"] == "for_kids"):
                            ?>
                            <section id="home-children" class="for-kids">
                                <div class="holder">
                                    <h2><?php echo $con["title"]; ?></h2>
                                    <?php echo $con["text"]; ?>
                                </div>
                                <ul class="grid">
                                    <?php
                                    foreach ($con["items"] as $key => $item):
                                        ?>
                                        <li>
                                            <div class="image <?php
                                            if (in_array($key, $olnymobile_arr)):
                                                echo 'olnymobile';
                                            endif;
                                            ?>">
                                                <img src="<?php echo $item["image"]["sizes"]["thumb-460x460"] ?>" alt="">
                                            </div>
                                            <div class="text-box">
                                                <div class="text-holder">
                                                    <h3><?php echo $item["title"]; ?></h3>
                                                    <?php echo $item["text"]; ?>
                                                    <a class="btn popup_link" href="#booking"><?php _e('Get started', 'am') ?></a>
                                                </div>
                                            </div>
                                            <?php
                                            if (in_array($key, $olnymobile_arr)):
                                                ?>
                                                <div class="image olnydesktop">
                                                    <img src="<?php echo $item["image"]["sizes"]["thumb-460x460"] ?>" alt="">
                                                </div>
                                                <?php
                                            endif;
                                            ?>
                                        </li>
                                        <?php
                                    endforeach;
                                    ?>
                                </ul>
                                <?php
                                if ($con["show_read_more"] == true):
                                    ?>
                                    <a class="btn white popup_link" href="#benefits"><?php echo $con["read_more_button_title"]; ?></a>
                                    <div id="benefits" class="popup message-box">
                                        <h2 class="popup_title"><?php echo $con["read_more_popup_title"]; ?></h2>
                                        <div class="holder"><?php echo $con["read_more_text"]; ?></div>
                                    </div>
                                    <?php
                                endif;
                                ?>
                            </section>
                            <?php
                        endif;


                    endforeach;
                endif;
                ?>



            </div>
            <!-- / container -->
            <?php
            if ($sections):
                foreach ($sections as $con):

                    if ($con["acf_fc_layout"] == "text_slider"):
                        ?>
                        <section class="text-slider">
                            <div class="container">
                                <ul>
                                    <?php
                                    foreach ($con["slider"] as $slide):
                                        ?>
                                        <li>
                                            <h3><?php echo $slide["title"] ?></h3>
                                            <a class="btn" href="<?php echo $slide["button_url"] ?>"><?php echo $slide["button_title"] ?></a>
                                        </li>
                                        <?php
                                    endforeach;
                                    ?>
                                </ul>
                            </div>
                        </section>
                        <?php
                    endif;


                    if ($con["acf_fc_layout"] == "team"):
                        ?>
                        <section id="home-team" class="team">
                            <div class="container">
                                <div class="holder">
                                    <h2><?php echo $con["title"]; ?></h2>
                                    <?php echo $con["text"]; ?>
                                </div>
                                <?php
                                foreach ($con["members"] as $group):
                                    ?>
                                    <ul class="members <?php
                                    if ($group["is_leaders"] == true) {
                                        echo 'leaders';
                                    }
                                    ?>">

                                        <?php
                                        foreach ($group["items"] as $item):
                                            ?>
                                            <li>
                                                <div class="holder" style="background-image:url(<?php echo $item["image"]["sizes"]["thumb-460x460"] ?>);">
                                                    <div class="info_holder">
                                                        <div class="info">
                                                            <h3><?php echo $item["title"] ?></h3>
                                                            <div class="text"><?php echo $item["text"] ?></div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php
                                        endforeach;
                                        ?>

                                    </ul>
                                    <?php
                                endforeach;
                                ?>
                            </div>
                        </section>
                        <?php
                    endif;

                endforeach;
            endif;
            ?>


        </div>
        <!-- / body -->
        <?php
    endwhile;
endif;
get_footer();
?>