<?php
if (!isset($_SESSION['FirstName'])) {
	session_start();
} 
if ($_SESSION['FirstName'] == "") {
	echo 'You are not authorized to view this page. <br><br>You may <a href="index.php"><font color="blue">log in here.</font></a>';
	exit;
}
session_start();    
include ('includes/db1config.php');
include ('../includes/mysql_connect.php');
echo "</div><h4>User Folders</h4>";
?>

<?php include("admin_globals.php"); ?>

<div class="mainForm">
<!--<center><h5>page title goes here...</h5></center>-->
  <select name="searchName" id="searchName" class="s-box-jumpTo">
  <option value="ALL" <?php if('ALL'==trim($_SESSION['selectVal'])) { echo 'selected'; } ?> >SHOW ALL</option>
  <option value="A-J" <?php if('A-J'==trim($_SESSION['selectVal'])) { echo 'selected'; } ?>>A-J</option>
 	<option value="K-S" <?php if('K-S'==trim($_SESSION['selectVal'])) { echo 'selected'; } ?>>K-S</option>
 	<option value="T-Z" <?php if('T-Z'==trim($_SESSION['selectVal'])) { echo 'selected'; } ?>>T-Z</option>
  </select>
  OR
  <input type="text" id="searchField" name="searchField" placeholder="Search" 
  value="<?php if(trim($_SESSION['selectVal'])!='') { echo $_SESSION['selectField']; } ?>">
  <input value="Search" id="submit" type="button">
</div>
<div id="result"></div>
<script type="text/javascript">
  $(document).ready(function() {

      // setTimeout(function(){
      //       if( "$_SESSION['selectVal'] }}" != '' ){
      //         $('#searchName').val('$_SESSION["selectVal"] }}');
      //       }
      //       $('#searchName').trigger('change');
      //     },500);
      $("#submit").click(function(){
        ajaxCall();
      });

      $search=$('#searchName').val();
      
      if($search!='')
      {
        ajaxCall();
      }
      $('#searchName').on('change',function(){
         ajaxCall();
      });

      function ajaxCall()
      {
      $.ajax({

            url: "user_folder_detail.php",
            type: "POST",
            data: {
                searchName: $("#searchName").val(),
                searchField: $("#searchField").val(),
            },
            //dataType: 'json',
            success: function (data)
            {
                $('#result').html(data);
            }
        });
      }
});
</script>


<div style="clear: both;">&nbsp;</div>
			  <div style="text-align:center;"><?php echo $bottom_links; ?></div>