Index: search-behavior/lib/search_behavior.rb
===================================================================
--- search-behavior/lib/search_behavior.rb	(revision 3)
+++ search-behavior/lib/search_behavior.rb	(working copy)
@@ -1,7 +1,17 @@
 # SearchBehavior
 
+$KCODE = 'u'
+require 'jcode'
+
 class SearchBehavior < Behavior::Base
   
+  begin
+    require 'unicode'
+    UNICODE_PRESENT = true
+  rescue MissingSourceFile
+    UNICODE_PRESENT = false
+  end
+
   register 'Search'
   
   LOGGER = ActionController::Base.logger
@@ -143,7 +153,7 @@
         end
         content << %{<script type="text/javascript">
 //<![CDATA[
-new Form.Element.Observer('q', 1, function(element, value) {new Ajax.Updater('#{update_element}', '#{page.url}live', {asynchronous:true, evalScripts:true, parameters:'q=' + escape($F('q'))})})
+new Form.Element.Observer('q', 1, function(element, value) {new Ajax.Updater('#{update_element}', '#{page.url}live', {asynchronous:true, evalScripts:true, parameters:'q=' + encodeURIComponent($F('q'))})})
 //]]>
 </script>}
       end
@@ -185,7 +195,7 @@
     LOGGER.debug("Params: #{query.inspect}")
     if not query.to_s.strip.empty?
       @query = query.to_s.strip
-      tokens = query.split.collect { |c| "%#{c.downcase}%"}
+      tokens = query.split.collect { |c| "%#{downcase(c)}%"}
       pages = Page.find(:all, :include => [ :parts ],
           :conditions => [(["((LOWER(content) LIKE ?) OR (LOWER(title) LIKE ?))"] * tokens.size).join(" AND "), 
                          *tokens.collect { |token| [token] * 2 }.flatten])
@@ -214,4 +224,10 @@
   def cache_page?
     false
   end
+  
+  private
+  
+    def downcase(string)
+      UNICODE_PRESENT ? Unicode::downcase(string) : string.downcase        
+    end
 end
