// Declare short form elements in this page 
// Add as many form id's as you need to the array
var $j = jQuery.noConflict();
var shortForms = new Array(
  "#search_form"
);
 
// When the document's loaded, initialize short forms
$j("document").ready(function() {
  handleShortFormEvent(shortForms);
});
 
/**
 * Handle initialization of all short forms
 *
 * @param array shortForms Array of short form IDs
 */
function handleShortFormEvent(shortForms) {
  for (var i in shortForms) {      
    shortFormInit(shortForms[i]);
  }
}
 
/**
 * Initialize a short form. Short forms may contain only one text input.
 *
 * @param string formID The form's ID, including #
 */
function shortFormInit(formID) {
  // Get the input ID and it's label text
  var labelValue = $j(formID + " input[type='text']:first").siblings("label").html();
  var inputID = "#" + $j(formID + " input[type='text']:first").attr("id");
 
  // Set the input value equal to label text
  $j(inputID).val(labelValue);
 
  // Attach event listeners to the input
  $j(inputID).bind("focus blur", function(e){
    var eLabelVal = $j(this).siblings("label").html();
    var eInputVal = $j(this).val();
 
    // Empty input value if it equals it's label
    if (eLabelVal == eInputVal) {
        $j(this).val("");
    // Reset the input value if it's empty
    } else if ($j(this).val() == "") {
      $j(this).val(eLabelVal);
    }
  });
}