jQuery.fn.labelOver = function(overClass)
{
  return this.each(function()
  {
    var label = jQuery(this);
    var f = label.attr('for');
    if (f)
    {
      var input = jQuery('#' + f);

      this.hide = function()
      {
         label.css({ textIndent: -10000 })
      }

      this.hidecheck = function()
      {
         if(input.val() != '')
           label.css({ textIndent: -10000 })
      }

      this.show = function()
      {
        if (input.val() == '') label.css({ textIndent: 0 })
      }

      // handlers
      input.focus(this.hide);
      input.change(this.hidecheck); // To support browser-remembered passwords/usernames. Does not work for IE
      input.bind('propertychange', this.hidecheck); // To support IE browser-remember password/usernames
      input.blur(this.show);
      label.addClass(overClass).click(function(){ input.focus() }); // When label is clicked, focus input instead

      if (input.val() != '') this.hide();
    }
  })
}

$(document).ready(function(){
  $('#login label').labelOver('over');
});

