<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php $enableglocation = Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0); ?>
<?php //if ($this->isAjaxSearch): ?>
<div class="browse_members_head">
  <h3>
    <?php echo $this->translate(array('%s member found.', '%s members found.', $this->totalUsers),$this->locale()->toNumber($this->totalUsers)) ?>
  </h3>
  <div class="view_type">
    <a class="list active view-switcher" data-view="list" href="javascript:void(0);"><i>
      <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
        <rect width="30" height="30" rx="3.6" fill="none"/>
        <g clip-path="url(#clip0_2431_28914)">
        <path d="M10.7817 11H23.2261C23.4324 11 23.6302 10.8946 23.7761 10.7071C23.922 10.5196 24.0039 10.2652 24.0039 10C24.0039 9.73478 23.922 9.48043 23.7761 9.29289C23.6302 9.10536 23.4324 9 23.2261 9H10.7817C10.5754 9 10.3776 9.10536 10.2317 9.29289C10.0859 9.48043 10.0039 9.73478 10.0039 10C10.0039 10.2652 10.0859 10.5196 10.2317 10.7071C10.3776 10.8946 10.5754 11 10.7817 11Z" fill="currentColor"/>
        <path d="M23.2261 14H10.7817C10.5754 14 10.3776 14.1054 10.2317 14.2929C10.0859 14.4804 10.0039 14.7348 10.0039 15C10.0039 15.2652 10.0859 15.5196 10.2317 15.7071C10.3776 15.8946 10.5754 16 10.7817 16H23.2261C23.4324 16 23.6302 15.8946 23.7761 15.7071C23.922 15.5196 24.0039 15.2652 24.0039 15C24.0039 14.7348 23.922 14.4804 23.7761 14.2929C23.6302 14.1054 23.4324 14 23.2261 14Z" fill="currentColor"/>
        <path d="M23.2261 20H10.7817C10.5754 20 10.3776 20.1054 10.2317 20.2929C10.0859 20.4804 10.0039 20.7348 10.0039 21C10.0039 21.2652 10.0859 21.5196 10.2317 21.7071C10.3776 21.8946 10.5754 22 10.7817 22H23.2261C23.4324 22 23.6302 21.8946 23.7761 21.7071C23.922 21.5196 24.0039 21.2652 24.0039 21C24.0039 20.7348 23.922 20.4804 23.7761 20.2929C23.6302 20.1054 23.4324 20 23.2261 20Z" fill="currentColor"/>
        <path d="M7.11797 11.2281C7.73325 11.2281 8.23203 10.7293 8.23203 10.1141C8.23203 9.49878 7.73325 9 7.11797 9C6.50269 9 6.00391 9.49878 6.00391 10.1141C6.00391 10.7293 6.50269 11.2281 7.11797 11.2281Z" fill="currentColor"/>
        <path d="M7.11797 16.2281C7.73325 16.2281 8.23203 15.7293 8.23203 15.1141C8.23203 14.4988 7.73325 14 7.11797 14C6.50269 14 6.00391 14.4988 6.00391 15.1141C6.00391 15.7293 6.50269 16.2281 7.11797 16.2281Z" fill="currentColor"/>
        <path d="M7.11797 22.2281C7.73325 22.2281 8.23203 21.7293 8.23203 21.1141C8.23203 20.4988 7.73325 20 7.11797 20C6.50269 20 6.00391 20.4988 6.00391 21.1141C6.00391 21.7293 6.50269 22.2281 7.11797 22.2281Z" fill="currentColor"/>
        </g>
        <defs>
        <clipPath id="clip0_2431_28914">
        <rect width="18.4" height="18.4" fill="white" transform="translate(5.80078 5.80078)"/>
        </clipPath>
        </defs>
      </svg>
    </i></a>
    <a class="grid view-switcher" data-view="grid" href="javascript:void(0);"><i>
      <svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
        <rect width="30" height="30" rx="3.6" fill="none"/>
        <path d="M7.33203 19.5979C7.33203 18.4169 7.33203 17.8264 7.59786 17.3926C7.7466 17.1499 7.95068 16.9458 8.19341 16.7971C8.62719 16.5312 9.2177 16.5312 10.3987 16.5312C11.5797 16.5312 12.1702 16.5312 12.604 16.7971C12.8467 16.9458 13.0508 17.1499 13.1995 17.3926C13.4654 17.8264 13.4654 18.4169 13.4654 19.5979C13.4654 20.7789 13.4654 21.3694 13.1995 21.8032C13.0508 22.0459 12.8467 22.25 12.604 22.3988C12.1702 22.6646 11.5797 22.6646 10.3987 22.6646C9.2177 22.6646 8.62719 22.6646 8.19341 22.3988C7.95068 22.25 7.7466 22.0459 7.59786 21.8032C7.33203 21.3694 7.33203 20.7789 7.33203 19.5979Z" stroke="currentColor" stroke-width="1.5"/>
        <path d="M16.5312 19.5979C16.5312 18.4169 16.5312 17.8264 16.7971 17.3926C16.9458 17.1499 17.1499 16.9458 17.3926 16.7971C17.8264 16.5312 18.4169 16.5312 19.5979 16.5312C20.7789 16.5312 21.3694 16.5312 21.8032 16.7971C22.0459 16.9458 22.25 17.1499 22.3988 17.3926C22.6646 17.8264 22.6646 18.4169 22.6646 19.5979C22.6646 20.7789 22.6646 21.3694 22.3988 21.8032C22.25 22.0459 22.0459 22.25 21.8032 22.3988C21.3694 22.6646 20.7789 22.6646 19.5979 22.6646C18.4169 22.6646 17.8264 22.6646 17.3926 22.3988C17.1499 22.25 16.9458 22.0459 16.7971 21.8032C16.5312 21.3694 16.5312 20.7789 16.5312 19.5979Z" stroke="currentColor" stroke-width="1.5"/>
        <path d="M7.33203 10.3987C7.33203 9.2177 7.33203 8.62719 7.59786 8.19341C7.7466 7.95068 7.95068 7.7466 8.19341 7.59786C8.62719 7.33203 9.2177 7.33203 10.3987 7.33203C11.5797 7.33203 12.1702 7.33203 12.604 7.59786C12.8467 7.7466 13.0508 7.95068 13.1995 8.19341C13.4654 8.62719 13.4654 9.2177 13.4654 10.3987C13.4654 11.5797 13.4654 12.1702 13.1995 12.604C13.0508 12.8467 12.8467 13.0508 12.604 13.1995C12.1702 13.4654 11.5797 13.4654 10.3987 13.4654C9.2177 13.4654 8.62719 13.4654 8.19341 13.1995C7.95068 13.0508 7.7466 12.8467 7.59786 12.604C7.33203 12.1702 7.33203 11.5797 7.33203 10.3987Z" stroke="currentColor" stroke-width="1.5"/>
        <path d="M16.5312 10.3987C16.5312 9.2177 16.5312 8.62719 16.7971 8.19341C16.9458 7.95068 17.1499 7.7466 17.3926 7.59786C17.8264 7.33203 18.4169 7.33203 19.5979 7.33203C20.7789 7.33203 21.3694 7.33203 21.8032 7.59786C22.0459 7.7466 22.25 7.95068 22.3988 8.19341C22.6646 8.62719 22.6646 9.2177 22.6646 10.3987C22.6646 11.5797 22.6646 12.1702 22.3988 12.604C22.25 12.8467 22.0459 13.0508 21.8032 13.1995C21.3694 13.4654 20.7789 13.4654 19.5979 13.4654C18.4169 13.4654 17.8264 13.4654 17.3926 13.1995C17.1499 13.0508 16.9458 12.8467 16.7971 12.604C16.5312 12.1702 16.5312 11.5797 16.5312 10.3987Z" stroke="currentColor" stroke-width="1.5"/>
      </svg>
    </i></a>
		<?php if($enableglocation == 1) { ?>
			<a class="map view-switcher" data-view="map" href="javascript:void(0);">
				<i>
					<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
						<rect width="30" height="30" rx="3.6" fill="none"/>
						<path d="M17.25 10.5V21.75M17.25 10.5L21.75 8.25V19.5L17.25 21.75M17.25 10.5L12.75 8.25M17.25 21.75L12.75 19.5M12.75 19.5L8.25 21.75V10.5L12.75 8.25M12.75 19.5V8.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
					</svg>
				</i>
			</a>
		<?php } ?>
  </div>
</div>
<?php //endif; ?>
<?php $viewer = Engine_Api::_()->user()->getViewer();?>

<?php if( engine_count($this->users) ): ?>
  <?php
    $ulClass = '';
    $excludedLevels = array(1, 2, 3);
    $isAdmin = false;

    if( !$this->viewer()->getIdentity() ) {
      $ulClass = 'public_user';
    } else {
      $viewerId = $viewer->getIdentity();
      if( engine_in_array($viewer->level_id, $excludedLevels) ) {
        $isAdmin = true;
      } else {
        $registeredPrivacy = array('everyone', 'registered');
        $friendsIds = $viewer->membership()->getMembersIds();
      }
    }

?>

  <div class="browse_mambers view-container" id="list-view" style="display: block;">
    <div class="browse_members_list">
      <?php foreach( $this->users as $user ): ?>
        <div class="browse_mambers_list_item browse_member_list_view_item">
          <article>
          <?php
            $showPhoto = false;
            $viewPrivacy = $user->view_privacy;

            if( !isset($viewerId) ) {
              if( $viewPrivacy == 'everyone' ) {
                $showPhoto = true;
              }
            } elseif( $isAdmin
              || $viewerId == $user->getIdentity()
              || engine_in_array($viewPrivacy, $registeredPrivacy)
              || ($viewPrivacy == 'member' && engine_in_array($user->getIdentity(), $friendsIds))) {
              $showPhoto = true;
            } elseif($viewPrivacy == 'network' ) {
              $netMembershipTable = Engine_Api::_()->getDbtable('membership', 'network');
              $viewerNetwork = $netMembershipTable->getMembershipsOfIds($viewer);
              $userNetwork = $netMembershipTable->getMembershipsOfIds($user);

              if( engine_in_array($user->getIdentity(), $friendsIds)
                || !empty(array_intersect($userNetwork, $viewerNetwork)) ) {
                $showPhoto = true;
              }
            }

            if( $showPhoto ){
              $profileImg = $this->itemBackgroundPhoto($user, 'thumb.profile');
            } else {
              $profileImg = '<span class="bg_item_photo bg_thumb_profile bg_item_photo_user bg_item_nophoto bg_item_nophoto_private"></span>';
            }
          ?>
            <div class="browse_mambers_list_item_thumb">
              <?php echo $this->htmlLink($user->getHref(), $profileImg) ?>
            </div>
            <div class='browse_mambers_list_item_info'>
              <div class="browse_mambers_list_item_name"><?php echo $this->htmlLink($user->getHref(), $user->getTitle(), array('class' => 'font_color')) ?></div>
              <?php if(0 && $user->status != "" ): ?>
                <div class="font_small">
                  <?php echo $user->status; ?>
                </div>
                <div class="font_small font_color_light">
                  <?php echo $this->timestamp($user->status_date) ?>
                </div>
              <?php endif; ?>
              <?php if( isset($viewerId) && $viewerId != $user->getIdentity() ): ?>
                <div class='browse_mambers_list_item_links'>
                  <div class="_friend"><?php echo $this->userFriendship($user, $this->viewer(), 'text') ?></div>
                  <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('core.followenable',1)  && !Engine_Api::_()->user()->getViewer()->isSelf($user)) { ?>
                    <div class="_follow"><?php echo $this->partial('_followmembers.tpl', 'user', array('subject' => $user, 'iconType' => 'text')); ?> </div>
                  <?php } ?>
                  <!-- <?php if(Engine_Api::_()->authorization()->getPermission($user, 'user', 'canblock') && Engine_Api::_()->authorization()->getPermission($viewer, 'user', 'block') && !engine_in_array($user->getIdentity(), $this->blockedUserIds) ) :?>
                    <div class="_block">
                      <?php echo '<a href ="'. $this->url(array(
                      'controller' => 'block',
                      'action' => 'add',
                      'user_id' => $user->getIdentity()
                      ),'user_extended',true)
                      . '" class = "btn btn-alt smoothbox" data-bs-toggle="tooltip" title="'. $this->translate("Block Member") . '"><i class="icon_block"></i></a>'; ?>
                    </div>
                  <?php endif; ?> -->
                </div>
              <?php endif; ?>
            </div>
        </article>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
  <div class="browse_mambers view-container" id="grid-view" style="display: none;">
    <div class="browse_members_grid">
      <?php foreach( $this->users as $user ): ?>
        <div class="browse_mambers_grid_item">
          <article>
          <?php
            $showPhoto = false;
            $viewPrivacy = $user->view_privacy;

            if( !isset($viewerId) ) {
              if( $viewPrivacy == 'everyone' ) {
                $showPhoto = true;
              }
            } elseif( $isAdmin
              || $viewerId == $user->getIdentity()
              || engine_in_array($viewPrivacy, $registeredPrivacy)
              || ($viewPrivacy == 'member' && engine_in_array($user->getIdentity(), $friendsIds))) {
              $showPhoto = true;
            } elseif($viewPrivacy == 'network' ) {
              $netMembershipTable = Engine_Api::_()->getDbtable('membership', 'network');
              $viewerNetwork = $netMembershipTable->getMembershipsOfIds($viewer);
              $userNetwork = $netMembershipTable->getMembershipsOfIds($user);

              if( engine_in_array($user->getIdentity(), $friendsIds)
                || !empty(array_intersect($userNetwork, $viewerNetwork)) ) {
                $showPhoto = true;
              }
            }

            if( $showPhoto ){
              $profileImg = $this->itemBackgroundPhoto($user, 'thumb.profile');
            } else {
              $profileImg = '<span class="bg_item_photo bg_thumb_profile bg_item_photo_user bg_item_nophoto bg_item_nophoto_private"></span>';
            }
          ?>
            <div class="browse_mambers_grid_item_thumb">
              <?php echo $this->htmlLink($user->getHref(), $profileImg) ?>
            </div>
            <div class='browse_mambers_grid_item_info'>
              <div class="browse_mambers_grid_item_name"><?php echo $this->htmlLink($user->getHref(), $user->getTitle(), array('class' => 'font_color')) ?></div>
              <?php if(0 && $user->status != "" ): ?>
                <div class="font_small">
                  <?php echo $user->status; ?>
                </div>
                <div class="font_small font_color_light">
                  <?php echo $this->timestamp($user->status_date) ?>
                </div>
              <?php endif; ?>
              <?php if( isset($viewerId) && $viewerId != $user->getIdentity() ): ?>
                <div class='browse_mambers_grid_item_links'>
                  <div class="_friend"><?php echo $this->userFriendship($user, $this->viewer(), 'text') ?></div>
                  <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('core.followenable',1)  && !Engine_Api::_()->user()->getViewer()->isSelf($user)) { ?>
                    <div class="_follow"><?php echo $this->partial('_followmembers.tpl', 'user', array('subject' => $user, 'iconType' => 'text')); ?> </div>
                  <?php } ?>
                  <!-- <?php if(Engine_Api::_()->authorization()->getPermission($user, 'user', 'canblock') && Engine_Api::_()->authorization()->getPermission($viewer, 'user', 'block') && !engine_in_array($user->getIdentity(), $this->blockedUserIds) ) :?>
                    <div class="_block">
                      <?php echo '<a href ="'. $this->url(array(
                      'controller' => 'block',
                      'action' => 'add',
                      'user_id' => $user->getIdentity()
                      ),'user_extended',true)
                      . '" class = "btn btn-alt smoothbox" data-bs-toggle="tooltip" title="'. $this->translate("Block Member") . '"><i class="icon_block"></i></a>'; ?>
                    </div>
                  <?php endif; ?> -->
                </div>
              <?php endif; ?>
            </div>
        </article>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
	<?php if($enableglocation == 1) { ?>
		<!-- Map View Container -->
		<div class="view-container browse_map_view" id="map-view" style="display: none;">
			<div id="members-map" class="map user_large_map" style="height: 600px; width: 100%; border-radius: 8px; overflow: hidden;"></div>
		</div>
	<?php } ?>
<?php endif ?>

<?php if( $this->users ):
    $pagination = $this->paginationControl($this->users, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
    ));
  ?>
  <?php if( trim($pagination) ): ?>
    <div class='browsemembers_viewmore' id="browsemembers_viewmore">
      <?php echo $pagination ?>
    </div>
  <?php endif ?>
<?php endif; ?>

<?php 
  $locationArray = array();
  $counter = 0;
  foreach( $this->users as $user ):
    $lat = null;
    $lng = null;
    
    if( isset($user->lat) && isset($user->lng) && $user->lat && $user->lng ) {
      $lat = $user->lat;
      $lng = $user->lng;
    }
    if( $lat && $lng && is_numeric($lat) && is_numeric($lng) ):
      $locationArray[$counter]['id'] = $user->getIdentity();
      $locationArray[$counter]['title'] = '<a href="'.$user->getHref().'">'.$user->getTitle().'</a>';
      $locationArray[$counter]['name'] = $user->getTitle();
      $locationArray[$counter]['href'] = $user->getHref();
      $locationArray[$counter]['image_url'] = $user->getPhotoUrl('thumb.profile');
      $locationArray[$counter]['lat'] = $lat;
      $locationArray[$counter]['lng'] = $lng;
      $counter++;
    endif;
  endforeach;
?>
<!-- Map Data -->
<?php if( $enableglocation == 1 && count($locationArray) > 0 ): ?>
  <div id="map-data" style="display:none;"><?php echo json_encode($locationArray, JSON_HEX_QUOT | JSON_HEX_TAG); ?></div>
<?php endif; ?>

<script type="text/javascript">
  page = '<?php echo sprintf('%d', $this->page) ?>';
  totalUsers = '<?php echo sprintf('%d', $this->totalUsers) ?>';
  userCount = '<?php echo sprintf('%d', $this->userCount) ?>';

  // View Switcher Functionality
  (function() {
    var currentView = 'list';
    var map = null;
    var oms = null;
    var markers = [];
    var countMarker = 0;
    var useRichMarker = false;
    var mapData = [];

		<?php if($enableglocation == 1) { ?>
			function loadMapData() {
				var mapDataElement = document.getElementById('map-data');
				if (mapDataElement) {
					try {
						mapData = JSON.parse(mapDataElement.innerHTML);
					} catch(e) {
						//console.error('Error parsing map data:', e);
						mapData = [];
					}
				}
			}
		<?php } ?>

    function initViewSwitcher() {
			<?php if($enableglocation == 1) { ?>
	      loadMapData();
			<?php } ?>
      
      var viewSwitchers = document.querySelectorAll('.view-switcher');
      for (var i = 0; i < viewSwitchers.length; i++) {
        viewSwitchers[i].addEventListener('click', function(e) {
          e.preventDefault();
          e.stopPropagation();
          var viewType = this.getAttribute('data-view');
          switchView(viewType);
          return false;
        });
      }
    }

    function switchView(viewType) {
      currentView = viewType;

	    var containers = document.querySelectorAll('.view-container');
      for (var i = 0; i < containers.length; i++) {
        containers[i].style.display = 'none';
      }

      var selectedContainer = document.getElementById(viewType + '-view');
      if (selectedContainer) {
        selectedContainer.style.display = 'block';
      }

      var switchers = document.querySelectorAll('.view-switcher');
      for (var j = 0; j < switchers.length; j++) {
        switchers[j].classList.remove('active');
        if (switchers[j].getAttribute('data-view') === viewType) {
          switchers[j].classList.add('active');
        }
      }

			<?php if($enableglocation == 1) { ?>
				if (viewType === 'map') {
					setTimeout(function() {
						initializeMap();
					}, 100);
				}
			<?php } ?>
    }

		<?php if($enableglocation == 1) { ?>
			function initializeMap() {
				if (map !== null) {
					google.maps.event.trigger(map, "resize");
					return;
				}
				if (typeof google === 'undefined' || typeof google.maps === 'undefined') {
					console.warn('Google Maps is not loaded.');
					return;
				}
				loadRichMarker();
			}

			function loadRichMarker() {
				useRichMarker = (typeof RichMarker !== 'undefined');
				if (!useRichMarker) {
					console.log('RichMarker not available; using native Google Maps markers.');
				}
				loadOMS();
			}

			function loadOMS() {
				if (typeof OverlappingMarkerSpiderfier === 'undefined') {
					console.warn('OverlappingMarkerSpiderfier is not loaded; overlapping marker spiderfying will be disabled.');
					oms = null;
					createMap();
				} else {
					createMap();
				}
			}

			function createMap() {
				var mapContainer = document.getElementById('members-map');
				if (!mapContainer) return;

				//Initialize map centered on world
				map = new google.maps.Map(mapContainer, {
					zoom: 2,
					scrollwheel: true,
					center: new google.maps.LatLng(20, 0),
				});

				if (typeof OverlappingMarkerSpiderfier !== 'undefined') {
					oms = new OverlappingMarkerSpiderfier(map, {nearbyDistance:40, circleSpiralSwitchover:0});
				} else {
					oms = null;
				}

				//Add members to map
				addMembersToMap();
			}

			function createMarkerClickListener(marker, infoWindow) {
				marker.addListener('click', function() {
					//Close all other info windows
					for (var m = 0; m < markers.length; m++) {
						if (markers[m].infoWindow) {
							markers[m].infoWindow.close();
						}
					}
					infoWindow.open(map, marker);
				});
			}

			function addMembersToMap() {
				if (!map) return;

				if (!mapData || mapData.length === 0) {
					map.setCenter(new google.maps.LatLng(26.9110600, 75.7373560));
					map.setZoom(5);
					return;
				}

				var bounds = new google.maps.LatLngBounds();
				var hasMarkers = false;

				var RichMarkerPosition = {
					TOP_LEFT: 1,
					TOP: 2,
					TOP_RIGHT: 3,
					LEFT: 4,
					MIDDLE: 5,
					RIGHT: 6,
					BOTTOM_LEFT: 7,
					BOTTOM: 8,
					BOTTOM_RIGHT: 9
				};

				// Loop through mapData array (members with location data)
				for (var u = 0; u < mapData.length; u++) {
					var memberData = mapData[u];
					
					if (!memberData.lat || !memberData.lng) {
						continue; // Skip if no coordinates
					}

					var lat = parseFloat(memberData.lat);
					var lng = parseFloat(memberData.lng);
					var name = memberData.name;
					var href = memberData.href;
					var imageUrl = memberData.image_url ? memberData.image_url : '';

					var markerData = null;

					markerData = new google.maps.Marker({
						position: new google.maps.LatLng(lat, lng),
						map: map,
						title: name,
					});

					var infoContent = '<div class="user_map_info_tip">' +
						'<div class="user_map_info_thumb"><img src="' + imageUrl + '" style="" alt="" /></div>' +
            '<div class="user_map_info"><div class="user_map_title text-center"><a href="' + href + '">' + name + '</a></div>' +
						
						'<div class="mt-2"><a href="' + href + '" class="user_map_btn btn btn-primary">View Profile</a></div></div></div>';

					var infoWindow = new google.maps.InfoWindow({
						content: infoContent,
						maxWidth: 300,
					});
					markerData.infoWindow = infoWindow;
					markerData.markerid = countMarker;
					createMarkerClickListener(markerData, infoWindow);

					markers.push(markerData);
					markerData.setMap(map);
					bounds.extend(markerData.getPosition());
					
					if (oms && useRichMarker) {
						oms.addMarker(markerData);
					}
					countMarker++;
					hasMarkers = true;
				}
				if (oms && useRichMarker) {
					oms.addListener('click', function(marker) {
						var id = marker.markerid;
						var previousIndex = scriptJquery('.marker_' + id).parent().parent().css('z-index');
						scriptJquery('.marker_' + id).parent().parent().css('z-index', '9999');
						scriptJquery('.pin').removeClass('active').css('z-index', 10);
						scriptJquery('.marker_' + id).addClass('active').css('z-index', 200);
						scriptJquery('.marker_' + id + ' .large .close').click(function() {
							scriptJquery(this).parent().parent().parent().parent().parent().css('z-index', previousIndex);
							scriptJquery('.pin').removeClass('active');
							return false;
						});
					});
				}

				if (hasMarkers) {
					map.fitBounds(bounds);
				} else {
					map.setCenter(new google.maps.LatLng(26.9110600, 75.7373560));
					map.setZoom(5);
				}
			}
		<?php } ?>

    // Initialize when DOM is ready
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', initViewSwitcher);
    } else {
      initViewSwitcher();
    }
  })();
</script>
