Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 6562)
+++ wp-includes/general-template.php	(working copy)
@@ -907,6 +907,15 @@
 	return apply_filters('user_can_richedit', $wp_rich_edit);
 }
 
+function wp_default_editor() {
+	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
+	if ( $user = wp_get_current_user() ) { // look for cookie
+		if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) )
+			$r = $_COOKIE['wordpress_editor_' . $user->ID];
+	}
+	return apply_filters( 'wp_default_editor', $r ); // filter
+}
+
 function the_editor($content, $id = 'content', $prev_id = 'title') {
 	$rows = get_option('default_post_edit_rows');
 	if (($rows < 3) || ($rows > 100))
@@ -915,6 +924,10 @@
 	$rows = "rows='$rows'";
 
 	if ( user_can_richedit() ) :
+		$wp_default_editor = wp_default_editor();
+		$active = " class='active'";
+		$inactive = " onclick='switchEditors(\"$id\");'";
+
 		add_filter('the_editor_content', 'wp_richedit_pre');
 
 		//	The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
@@ -925,13 +938,15 @@
 	</style>
 	<div id='editor-toolbar' style='display:none;'>
 		<div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
-		<a id='edButtonHTML' class='' onclick='switchEditors("<?php echo $id; ?>")'><?php _e('HTML'); ?></a>
-        <a id='edButtonPreview' class='active'><?php _e('Visual'); ?></a>
-        <div id="media-buttons">
-        <?php _e('Add media:'); ?>
-        <?php do_action( 'media_buttons'); ?>
-        </div>
+		<a id='edButtonHTML'<?php echo 'html' == $wp_default_editor ? $active : $inactive; ?>><?php _e('HTML'); ?></a>
+	        <a id='edButtonPreview'<?php echo 'tinymce' == $wp_default_editor ? $active : $inactive; ?>><?php _e('Visual'); ?></a>
+
+	        <div id="media-buttons">
+	        <?php _e('Add media:'); ?>
+	        <?php do_action( 'media_buttons'); ?>
+	        </div>
 	</div>
+
 	<script type="text/javascript">
 	// <![CDATA[
 		if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 )
@@ -939,20 +954,23 @@
 	// ]]>
 	</script>
 
-	<?php endif; ?>
+	<?php endif; // user_can_richedit() ?>
+
 	<div id="quicktags">
 	<?php wp_print_scripts( 'quicktags' ); ?>
 	<script type="text/javascript">edToolbar()</script>
 	</div>
+
+	<?php if ( 'html' != $wp_default_editor ) : ?>
 	<script type="text/javascript">
 	// <![CDATA[
 		if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 )
 			document.getElementById("quicktags").style.display="none";
 	// ]]>
 	</script>
-	<?php
+	<?php endif; // 'html' != $wp_default_editor
 
-	$the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
+	$the_editor = apply_filters('the_editor', "<div><textarea class='' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
 	$the_editor_content = apply_filters('the_editor_content', $content);
 
 	printf($the_editor, $the_editor_content);
Index: wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
===================================================================
--- wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js	(revision 6562)
+++ wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js	(working copy)
@@ -523,6 +523,7 @@
 			pdr.style.height = 'auto';
 			pdr.style.overflow = 'display';
 		}
+		wpSetDefaultEditor( 'html' );
 	} else {
 		edToggle(P, H);
 		edCloseAllTags(); // :-(
@@ -557,6 +558,7 @@
 			pdr.style.height = 'auto';
 			pdr.style.overflow = 'display';
 		}
+		wpSetDefaultEditor( 'tinymce' );
 	}
 }
 
@@ -568,6 +570,19 @@
 	A.onclick = null;
 }
 
+function wpSetDefaultEditor( editor ) {
+	try {
+		editor = escape( editor.toString() );
+	} catch(err) {
+		editor = 'tinymce';
+	}
+
+	var userID = document.getElementById('user-id');
+	var date = new Date();
+	date.setTime(date.getTime()+(10*365*24*60*60*1000));
+	document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString();
+}
+
 function wpautop(pee) {
 	pee = pee + "\n\n";
 	pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
Index: wp-includes/js/tinymce/tiny_mce_config.php
===================================================================
--- wp-includes/js/tinymce/tiny_mce_config.php	(revision 6562)
+++ wp-includes/js/tinymce/tiny_mce_config.php	(working copy)
@@ -54,9 +54,16 @@
 	$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale());
 ?>
 
+wpEditorInit = function() {
+	// Activate tinyMCE if it's the user's default editor
+	if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor )
+		tinyMCE.execCommand("mceAddControl", true, 'content');
+};
+
 initArray = {
 	mode : "specific_textareas",
 	editor_selector : "mceEditor",
+	oninit : "wpEditorInit",
 	width : "100%",
 	theme : "advanced",
 	theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>",
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 6562)
+++ wp-includes/script-loader.php	(working copy)
@@ -31,10 +31,11 @@
 		$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
 
 		// Modify this version when tinyMCE plugins are changed
-		$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080103' );
+		$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080105' );
 
 		$mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
-		$this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070528' );
+		$this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20080105' );
+		$this->localize( 'wp_tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );
 
 		$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
 
Index: wp-admin/wp-admin.css
===================================================================
--- wp-admin/wp-admin.css	(revision 6562)
+++ wp-admin/wp-admin.css	(working copy)
@@ -402,10 +402,6 @@
 	padding-right: 6px;
 }
 
-#postdivrich #quicktags {
-	display: none;
-}
-
 #quicktags #ed_toolbar {
 	padding: 0 2px;
 }
Index: wp-admin/edit-page-form.php
===================================================================
--- wp-admin/edit-page-form.php	(revision 6562)
+++ wp-admin/edit-page-form.php	(working copy)
@@ -33,7 +33,7 @@
 	echo '<input type="hidden" name="mode" value="bookmarklet" />';
 }
 ?>
-<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
+<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
 <input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
 <?php echo $form_extra ?>
Index: wp-admin/edit-form.php
===================================================================
--- wp-admin/edit-form.php	(revision 6562)
+++ wp-admin/edit-form.php	(working copy)
@@ -6,7 +6,7 @@
 <?php if (isset($mode) && 'bookmarklet' == $mode) : ?>
 <input type="hidden" name="mode" value="bookmarklet" />
 <?php endif; ?>
-<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
+<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
 <input type="hidden" name="action" value='post' />
 
 <script type="text/javascript">
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(revision 6562)
+++ wp-admin/edit-form-advanced.php	(working copy)
@@ -50,7 +50,7 @@
 
 ?>
 
-<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
+<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
 <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
 <input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
