// Copyright 2010 Wevolve
// All Rights Reserved.

// No more errors if jQuery failed to load (IE 5.0)
if( window.jQuery ) {

  // Directly set flag for CSS to indicate JavaScript is enabled.
  // At this point "HTML" is the only accessable element.
  $(document.documentElement).addClass("jsEnabled");

  // Executed at DOM-ready event.
  $(document).ready( function()
  {
    // functions for flip label text
    var hideLabelFunction = function()
    {
      if( this.labelValue ) return;  // keep if not unset
      this.labelValue = this.value;  // store
      this.value      = "";          // reset field
      $(this).removeClass("label");
    };

    var showLabelFunction = function()
    {
      if( this.value != "" || ! this.labelValue ) return;  // keep if not empty, or set.
      this.value      = this.labelValue;  // restore
      this.labelValue = "";               // reset label flag
      $(this).addClass("label");
    }

    // Apply to form fields.
    $("#q")          .focus( hideLabelFunction ) .blur( showLabelFunction );

  } );

}

