<?php
  $Position = "../../";
  require_once($Position.'config/config.php');
	require_once($Position.'config/conexion.php');
  $Pagina       = 1;
  $Menu         = 2;
  $UrlImgItems  = 'images/propiedades/galeriaitems';

?>
<!doctype html>
<html lang="en">
  <?php require_once($Position.'head.php'); ?>
  <!--<body class="pace-on pace-squares">-->
  <body>

    <?php require_once($Position.'whatsapp-globe.php'); ?>

    <!--<div class="pace-overlay"></div>-->
    <?php require_once($Position.'header.php'); ?>

    <!-- TopPad -->
    <section class="TopPad" style="background:#000;">
    </section>
    <!-- End TopPad -->

    <section
      class="section"
      style="
        background-color: #353535;
        padding-top: 10em;
      "
    >
      <div class="container">
        <div class="row">
          <div class="col-sm-1">

          </div>
          <div class="col-sm-10">
            <div class="row">
              <?php
                //Propiedad
                $Query = "
                  SELECT
                    des.Id, des.Nombre,
                    des.Ubicacion, des.Descripcion,
                    des.UrlTour
                  FROM Propiedades des
                  WHERE
                    des.Id != '0'
                    AND des.Fk_Tipo = '1'
                    AND des.Id = '$_GET[Id]'
                  ORDER BY des.Orden ASC
                ";
                $Pros = $mysqli->query($Query);
                mysqli_data_seek($Pros, 0);
                $Cont = 0;
                while($Pro = mysqli_fetch_array($Pros)) {
                  $Cont = $Cont + 1;
              ?>
                <div class="col-sm-12 col-md-12 col-lg-12">
                  <div class="DesarrolloA">
                    <div class="DesEqHe">
                      <div class="row">

                        <!-- Col -->
                        <div class="col-sm-12">

                          <!-- Titulo -->
                          <div class="row">
                            <div class="col-sm-6">
                              <h3>
                                <?php echo $Pro[Nombre]; ?>
                              </h3>

                              <?php if( $Pro[Ubicacion] ){ ?>
                                <p
                                  style="font-size: 1.25em;line-height:1.5em;"
                                >
                                  <?php echo $Pro[Ubicacion]; ?>
                                </p>
                              <?php } ?>
                            </div>

                            <div class="col-sm-6 text-right">
                              <!-- Btn Más Info -->
                              <a href="<?php echo $Position; ?>contacto" target="_blank">
                                <button
                                  onclick="<?php echo $Position; ?>contacto'"
                                  type="button"
                                  class="btn btn-success"
                                >
                                  Contacto
                                </button>
                              </a>
                              <!-- End Btn Más Info -->
                            </div>

                          </div>
                          <!-- End Titulo -->

                          <div
                            style="
                              margin-bottom:2em;
                              display: table;
                              width: 100%;
                            "
                          >
                            <hr
                              style="
                                width:50%;
                                <?php if($Cont % 2 == 0){?>
                                  float: right;
                                <?php }else{ ?>
                                  float: left;
                                <?php } ?>
                              "
                            >
                          </div>

                        </div>
                        <!-- End Col -->

                        <?php if($Cont % 2 == 0){ ?>
                          <!-- Col -->
                          <div class="col-sm-5">
                            <img
                              style="width:100%;"
                              src="<?php echo $Position; ?>images/propiedades/<?php echo $Pro[Id]; ?>.jpg"
                            />
                          </div>
                          <!-- End Col -->
                        <?php } ?>

                        <!-- Col -->
                        <div class="col-sm-7">
                          <table>
                            <?php
                              //AreaItems
                              $Query = "
                                SELECT
                                  ite.Id, ite.Fk_Item, ite.Texto, ite.Texto2
                                FROM PorpiedadesItems ite
                                WHERE ite.Fk_Propiedad = '$Pro[Id]'
                                ORDER BY ite.Orden ASC
                              ";
                              $Items = $mysqli->query($Query);
                              mysqli_data_seek($Items, 0);
                              while($Item = mysqli_fetch_array($Items)) {
                            ?>
                              <div class="Acordeon">
                                <div class="AcordeonBtn" style="position: relative;">
                                  <p style="display:block;">
                                    <?php echo $Item[Texto]; ?>
                                  </p>
                                  <p
                                    style="
                                      position: absolute;
                                      top: 0px;
                                      right: 0px;
                                      width: 30px;
                                    "
                                  >

                                    <img
                                      class="Plus"
                                      src="<?php echo $Position; ?>images/icons/plus-solid.svg"
                                      style="float:right;width: 16px;"
                                    />
                                    <img
                                      class="Less"
                                      src="<?php echo $Position; ?>images/icons/minus-solid.svg"
                                      style="float:right;width: 16px;"
                                    />
                                  </p>
                                </div>
                                <div class="AcordeonExpand">

                                  <?php
                                    $Image = $RootSite.'/'.$UrlImgItems.'/'.$Item['Id'].'.jpg';
                                    if (file_exists($Image)) {
                                  ?>
                                    <img
                                      class="img-responsive"
                                      src="<?php echo $Position; ?><?php echo $UrlImgItems; ?>/<?php echo $Item[Id]; ?>.jpg"
                                      style="max-width: 450px;"
                                    />
                                  <?php } ?>

                                  <?php if($Item[Texto2]){ ?>
                                    <p>
                                      <?php echo $Item[Texto2]; ?>
                                    </p>
                                  <?php } ?>

                                </div>
                                <hr style="border-color: #919191;">
                              </div>
                            <?php } ?>
                          </table>

                        </div>
                        <!-- End Col -->

                        <?php if($Cont % 2 == 0){}else{ ?>
                          <!-- Col -->
                          <div class="col-sm-5">
                            <img
                              style="width:100%;"
                              src="<?php echo $Position; ?>images/propiedades/<?php echo $Pro[Id]; ?>.jpg"
                            />
                          </div>
                          <!-- End Col -->
                        <?php } ?>

                      </div>
                    </div>
                  </div>
                </div>
              <?php } ?>

            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- End Desarrollos -->

    <?php require_once($Position.'footer.php'); ?>
    <?php require_once($Position.'scripts.php'); ?>

    <script>
      AnchoScreen = $( window ).width();
      if( AnchoScreen <= 991){
        $(document.body).on('click', '.BtnBlkInMobile' ,function(){
          console.log('test');
          $(this).parents('.DesImg').find('.BlkIn').toggle();
        });
        $(document.body).on('click', '.BlkIn' ,function(){
          $(this).toggle();
        });
      }

      $(document.body).on('click', '.AcordeonBtn' ,function(){

        $(this).removeClass('AcordeonBtn');
        $(this).addClass('AcordeonBtnActive');
        $('.AcordeonExpand').removeClass('AcordeonExpandActive');
        $('.Less').hide();
        $('.Plus').show();
        $('.Acordeon').removeClass('AcordeonActive');
        $(this).parents('.Acordeon').addClass('AcordeonActive');
        $(this).parents('.AcordeonActive');
        $(this).parents('.Acordeon').find('.AcordeonExpand').addClass('AcordeonExpandActive');
        $(this).parents('.Acordeon').find('.Plus').hide();
        $(this).parents('.Acordeon').find('.Less').show();

      });

      $(document.body).on('click', '.AcordeonBtnActive' ,function(){

        $(this).parents('.Acordeon').find('.Less').hide();
        $(this).parents('.Acordeon').find('.Plus').show();
        $(this).removeClass('AcordeonBtnActive');
        $(this).addClass('AcordeonBtn');
        $(this).parents('.Acordeon').removeClass('AcordeonActive');
        $(this).parents('.Acordeon').find('.AcordeonExpand').removeClass('AcordeonExpandActive');

        // $(this).parents('.AcordeonActive').find('.');

      });

    </script>

  </body>
</html>
