Index: wp-login.php
===================================================================
--- wp-login.php	(revision 10618)
+++ wp-login.php	(working copy)
@@ -11,6 +11,9 @@
 /** Make sure that the WordPress bootstrap has ran before continuing. */
 require( dirname(__FILE__) . '/wp-load.php' );
 
+// load login theme template if present
+locate_template(array('login.php'), true);
+
 // Redirect to https login if forced to use SSL
 if ( force_ssl_admin() && !is_ssl() ) {
 	if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
@@ -22,6 +25,7 @@
 	}
 }
 
+if ( !function_exists('login_header') ) :
 /**
  * Outputs the header for the login page.
  *
@@ -38,11 +42,8 @@
  * @param string $message Optional. Message to display in header.
  * @param WP_Error $wp_error Optional. WordPress Error Object
  */
-function login_header($title = 'Log In', $message = '', $wp_error = '') {
+function login_header($title = 'Log In') {
 	global $error;
-
-	if ( empty($wp_error) )
-		$wp_error = new WP_Error();
 	?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
@@ -58,8 +59,29 @@
 
 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
 <?php
+	login_error($message = '', $wp_error = '');
+} // End of login_header()
+
+endif; // End of login_header function check
+
+// Default login_footer if not defined by the Theme
+if ( !function_exists('login_footer') ) :
+function login_footer() {
+?>
+</body>
+</html>
+<?php	
+}
+endif;
+
+function login_error($message, $wp_error) {
+	global $error;
+
 	if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
 
+	if ( empty($wp_error) )
+		$wp_error = new WP_Error();
+
 	// Incase a plugin uses $error rather than the $errors object
 	if ( !empty( $error ) ) {
 		$wp_error->add('error', $error);
@@ -83,7 +105,7 @@
 		if ( !empty($messages) )
 			echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
 	}
-} // End of login_header()
+} // End of login_header_error()
 
 /**
  * Handles sending password retrieval email to user.
@@ -297,7 +319,8 @@
 	if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
 
 	do_action('lost_password');
-	login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
+	login_header(__('Lost Password'));
+	login_error('<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
 
 	$user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
 
@@ -328,9 +351,8 @@
 <script type="text/javascript">
 try{document.getElementById('user_login').focus();}catch(e){}
 </script>
-</body>
-</html>
 <?php
+login_footer();
 break;
 
 case 'resetpass' :
@@ -367,7 +389,8 @@
 		}
 	}
 
-	login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
+	login_header(__('Registration Form'));
+	login_error('<p class="message register">' . __('Register For This Site') . '</p>', $errors);
 ?>
 
 <form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
@@ -396,9 +419,8 @@
 <script type="text/javascript">
 try{document.getElementById('user_login').focus();}catch(e){}
 </script>
-</body>
-</html>
 <?php
+login_footer();
 break;
 
 case 'login' :
@@ -456,7 +478,8 @@
 	elseif	( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )	$errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
 	elseif	( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )	$errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
 
-	login_header(__('Log In'), '', $errors);
+	login_header(__('Log In'));
+	login_error('', $errors);
 
 	if ( isset($_POST['log']) )
 		$user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
@@ -508,10 +531,9 @@
 try{document.getElementById('user_login').focus();}catch(e){}
 <?php } ?>
 </script>
-</body>
-</html>
 <?php
 
+login_footer();
 break;
 } // end action switch
 ?>
