var options = {};
      jQuery(function(){
        reset_highlight();
        jQuery("input:not(:text)").click(reset_highlight)
        .filter("[@name=keys_enabled]").click(function(){
          var disable = !jQuery(this).is(":checked");
          jQuery("input[@name=keys],input[@name=keys_button]").each(function(){
            this.disabled = disable;
          });
        });
        jQuery("input:text").change(reset_highlight);
      });
      function reset_highlight() {
        var disable = !jQuery("input[@name=keys_enabled]").is(":checked");
        jQuery("input[@name=keys],input[@name=keys_button]").each(function(){
          this.disabled = disable;
        });
        jQuery("span[@class^=hilite]").each(function(){
          var hilite = jQuery(this);
          var txt_el = hilite[0].previousSibling;
          if(txt_el && txt_el.nodeType==3)
            txt_el.data += hilite.text();
          else {
            hilite.before(hilite.text());
            txt_el = hilite[0].previousSibling;
          }
          if(hilite[0].nextSibling && hilite[0].nextSibling.nodeType==3) {
            txt_el.data += hilite[0].nextSibling.data;
            $(hilite[0].nextSibling).remove();
          }
          hilite.remove();
        });
        jQuery("#code").text(build_options());
        jQuery(document).SearchHighlight(options);
        
      }
      function build_options() {
        var code = "\tjQuery(function(){\r\n\t\tvar options = {\r\n\t\t\t";
 
        options.debug_referrer = jQuery("input[@name=referrer]").val();
        
        options.exact = jQuery("input[@name=exact]:checked").val();
        code += 'exact:"'+options.exact+'"';
        options.style_name_suffix = jQuery("input[@name=suffix]").is(":checked");
        if(!options.style_name_suffix)
          code += ',\r\n\t\t\tstyle_name_suffix:'+options.style_name_suffix;
        if(jQuery("input[@name=Highlight]").is(":checked")) {
          options.highlight = ".highlightable";
          code += ',\r\n\t\t\thighlight:".highlightable"';
        } else {
          delete(options.highlight);
        }
        if(jQuery("input[@name=NoHighlight]").is(":checked")) {
          options.nohighlight = ".not_highlightable";
          code += ',\r\n\t\t\thighlight:".not_highlightable"';
        } else {
          delete(options.nohighlight);
        }        
        if(jQuery("input[@name=keys_enabled]").is(":checked")) {
          options.keys = jQuery("input[@name=keys]").val();
          code += ',\r\n\t\t\tkeys:"'+options.keys+'"';
        } else {
          delete(options.keys);
        }
        
        code += "\r\n\t\t}\r\n\t\tjQuery(document).SearchHighlight(options);\r\n\t});";
        return code;
      }
