// Copyright 2007 Siteseeing Internet Services.
// 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()
  {
    // Define actions only once
    var addHover    = function() { $(this).addClass("hover") };
    var removeHover = function() { $(this).removeClass("hover") };

    // Add hover effect for IE 6.0
    if( jQuery.browser.msie )
    {
      // Apply hover effects
      var menu1 = $("#shortcuts > ul > li");
      var menu2 = $("#contents > div.docnav > ul > li");
      menu1.mouseover( addHover ).mouseout( removeHover );
      menu2.mouseover( addHover ).mouseout( removeHover );
    }
    // 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 );

  } );

}
