(function() {

window.show_search_bar = function() {
  $('#searchbar').show();
  return $('#searchbar > input').focus();
};

$(document).ready(function() {
  return $('#searchbar > input').change(function() {
    var anchor, text;
    text = $('#searchbar > input')[0].value;
    $('#searchbar').hide();
    $('#searchbar > input')[0].value = "";
    console.log("Searching " + text);
    if (window.find(text, 0, 0, 1)) {
      console.log("Found " + text);
      anchor = window.getSelection().anchorNode;
      if (anchor.nodeType !== 1) {
        anchor = anchor.parentNode;
      }
      anchor.focus();
      return anchor.scrollIntoView();
    } else {
      return alert("Cannot find " + text);
    }
  });
});

}).call(this);