--- wp-login.php.orig	2008-12-03 19:04:08.000000000 -0800
+++ wp-login.php	2009-02-20 10:39:37.000000000 -0800
@@ -11,6 +11,14 @@
 /** Make sure that the WordPress bootstrap has ran before continuing. */
 require( dirname(__FILE__) . '/wp-load.php' );
 
+// load login theme template if present
+if (function_exists('get_template_directory')){
+	$templatedir = get_template_directory();
+	if ( file_exists($templatedir.'/login.php') ){
+		include($templatedir.'/login.php');
+	}
+}
+
 // Redirect to https login if forced to use SSL
 if ( force_ssl_admin() && !is_ssl() ) {
 	if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
@@ -22,6 +30,7 @@
 	}
 }
 
+if (!function_exists('login_header')){
 /**
  * Outputs the header for the login page.
  *
@@ -38,7 +47,7 @@
  * @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) )
@@ -58,6 +67,22 @@
 
 <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()
+
+} // 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	
+	}
+}
+
+function login_error($message, $wp_error) {
 	if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
 
 	// Incase a plugin uses $error rather than the $errors object
@@ -83,7 +108,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 +322,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 +354,8 @@
 <script type="text/javascript">
 try{document.getElementById('user_login').focus();}catch(e){}
 </script>
-</body>
-</html>
 <?php
+login_footer();
 break;
 
 case 'resetpass' :
@@ -367,7 +392,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 +422,8 @@
 <script type="text/javascript">
 try{document.getElementById('user_login').focus();}catch(e){}
 </script>
-</body>
-</html>
 <?php
+login_footer();
 break;
 
 case 'login' :
@@ -456,7 +481,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 +534,9 @@
 try{document.getElementById('user_login').focus();}catch(e){}
 <?php } ?>
 </script>
-</body>
-</html>
 <?php
 
+login_footer();
 break;
 } // end action switch
 ?>
