function fancy_input (element, text) {
  var input = $(element);
  
  // Ignore element if it doesn't exsist or can't be found
  if(!element == '') {
    
    // Initialize the form field
    input.writeAttribute('value', text);

    // Clean frield on focus
    Event.observe(input, 'focus', function() {
      input.writeAttribute('value', '');
    });

    // Repopulate field if user doesn't enter any text
    Event.observe(input, 'blur', function() {
      if (input.readAttribute('value') == '') {
        input.writeAttribute('value', text);
      };
    });
    
  }
  
} // End fancy_input()


document.observe("dom:loaded", function() { 
    
    // Open external links in new window
    $$('a[rel="external"]').each(function(link){
        link.writeAttribute('target', '_blank');
    });    
    
    // Fancy search form
    fancy_input('s', 'Search...');
    
    // Fancy comment form
    if (comment_form = $('commentform') ) {
      
      $('commentform').getInputs().each(function(field) {
        fancy_input(field, field.readAttribute('value'));
      });
      
    };
    
});
