<?php
  require("php/common_begin.php");

  $lst = Listopia::getInstance();
  // -------------------------------
  if (!$lst->isLoggedIn())
  {
    $lst->unloggedInPage();
    return;
  }
  // -------------------------------


  $lst->pageBegin(LS_SEARCH_DOCUMENT_TITLE, "Man, I feel like a woman");
  
  $lst->contentsBeginSinglePage(LS_SEARCH_TITLE, LS_SEARCH_DESC);
?>

Go see <a href="everything.php">All the lists</a>.

<br>

  <div id="SearchBox" style="margin:1em auto; padding:2em; width:80%; background:#f8f8f8; border:1px solid #e0e0e0 ">

  Searching is back, of sorts. It's hardly Google but it's better than nothing.<br><br>

    <form id="Search" action="" style="margin-bottom:0.25em">
      <label for="fmTextContent">Type Text In Here</label>
      <textarea 
          style='width:50%; min-height: 0 !important;' 
          id='fmTextContent' 
           rows='1' ></textarea>
    </form>
    <button id="SearchYeahGo" style="width:250px">Press And Wait</button>


    <div style="font-size:0.8em">
    If you type multiple words, it will search for any combination of all of them. So if you search "Spanking Teats", it will search for anything with "Spanking" OR "Teats".<br>
    You can use "+Spanking +Teats" to find things with both those terms in.<br>
    Also, plug in terms like "boob*" to find 'boobs', 'boobular', 'boobosity' and so on. "+Boob -Lube" to find things mentioning boobs but not lube. Shit like that. You only get 100 results returned, tops. Good luck.
    </div>
  </div>

  <div id="SearchResultsPOSTS" style="margin:0px auto; padding:0px; width:85%; background:#fbfbfb;" >
  </div>
  <div id="SearchResultsCOMMENTS" style="margin:0px auto; padding:0px; width:85%; background:#fbfbfb;" >
  </div>


<?php
  $lst->contentsEnd();

  // default script loading
  $lst->pageEndScripts();
?>

<!-- Local JS -->
<script type="text/javascript">

$(function() {

  var searchGoButton = $('#SearchYeahGo');
  if (searchGoButton.get() != undefined)
  {
    searchGoButton.click(function()
    {
      var inputState = UIInputButton_disableForAjax(searchGoButton);

      if (inputState != undefined)
      {
        $('#SearchResultsPOSTS').html( "<strong>Searching Posts...</strong>" );
        $('#SearchResultsCOMMENTS').html( "<strong>Searching Comments...</strong>" );

        $.post(
          "php/ajax_listogoogle.php", 
          { 
            query: inputState.MessageText,
            mode: 0
          },
          function(data) 
          { 
            $('#SearchResultsPOSTS').html( data );
          },
          "html" );

        $.post(
          "php/ajax_listogoogle.php", 
          { 
            query: inputState.MessageText,
            mode: 1
          },
          function(data) 
          { 
            $('#SearchResultsCOMMENTS').html( data );


            $(searchGoButton).fadeTo('fast', 1.0);

            var restoreButton = function() {
                $(searchGoButton).html(inputState.PrevHTMLContents);
            }
            setTimeout(restoreButton, 4000);

            // re-enable button + text area
            $(inputState.DomTextWindow).removeAttr('readonly');
            $(searchGoButton).attr('onclick', inputState.PrevOnclick);
          },
          "html" );
      }

    });
  }


});

</script>

<?php
  $lst->pageEnd();

  require("php/common_end.php");
?>
