Changing the Login block HTML for D7
You dont need to do access the form elements directly like that. You can use some unobtrusive JavaScript with jQuery to do the same thing.

;(function ($){
    Drupal.behaviors.YOUR_FUNCTION = {
        attach: function (context, settings) {
                    // your script goes here...
               };   
    };
})(jQuery);


Create a scripts file and add the above. Add a reference to that file in your .info file.

Then add your script.

Some references if your not familiar with jQuery.


http://api.jquery.com/class-selector/ 
http://api.jquery.com/blur/ 
http://api.jquery.com/focus/
http://api.jquery.com/val/