class PhotosearchesController < ApplicationController
  
  def index
  end
  
  def bring_results
    # render :text => params[:photo_to_search].reverse
    
    if request.xhr?
            
      if params['photo_to_search'].strip.length > 0
        search_string = params['photo_to_search'].split.collect do |w|
          "#{w.downcase}%"
        end
        @photos = Photo.find(:all, 
                  :conditions => [ (["(name LIKE ?)"]*search_string.size).join(" AND "),
                  * search_string.flatten ] )
      end
      render :partial => "search"     
    else
      redirect_to :action => "index"                  
    end    

  end  
  
end  