function TSpell_change_mce_settings( $init_array ) {
	if ( ! TSpell_is_allowed() )
		return $init_array;

	$user = wp_get_current_user();

	$init_array['atd_rpc_url']        = admin_url( 'admin-ajax.php?action=proxy_atd&_wpnonce=' . wp_create_nonce( 'proxy_atd' ) . '&url=' );
	$init_array['atd_ignore_rpc_url'] = admin_url( 'admin-ajax.php?action=atd_ignore&_wpnonce=' . wp_create_nonce( 'tspell_ignore' ) . '&phrase=' );
	$init_array['atd_rpc_id']         = 'WPORG-' . md5(get_bloginfo('wpurl'));
	$init_array['atd_theme']          = 'wordpress';
	$init_array['atd_ignore_enable']  = 'true';
	$init_array['atd_strip_on_get']   = 'true';
	$init_array['atd_ignore_strings'] = json_encode( explode( ',',  TSpell_get_setting( $user->ID, 'TSpell_ignored_phrases' ) ) );
	$init_array['atd_show_types']     = TSpell_get_setting( $user->ID, 'TSpell_options' );
	$init_array['gecko_spellcheck']   = 'false';

	return $init_array;
}
function TSpell_display_unignore_form() {

	if ( ! TSpell_is_allowed() )
		return;

	$user = wp_get_current_user();

	if ( ! $user || $user->ID == 0 )
		return;

	$ignores = TSpell_get_setting( $user->ID, 'TSpell_ignored_phrases' );
?>
<script>
function atd_show_phrases( ignored )
{
	var element = jQuery( '#atd_ignores' ),
	    items   = [],
	    delLink;

	ignored.sort();

	element.empty();
	for ( var i = 0; i < ignored.length; i++ ) {
		if ( ignored[i].length > 0 ) {
			delLink = jQuery( '<span id="atd_' + i + '">&nbsp;</span>' );
			delLink
				.text( delLink.text() + ignored[i] )
				.prepend( jQuery( '<a class="ntdelbutton">X</a>' ).data( 'ignored', ignored[i] ) );
			element.append( delLink ).append( '<br />' );
		}
	}
}

function atd_unignore( phrase ) {
	// get the ignored values and remove the unwanted phrase
	var ignored = jQuery( '#TSpell_ignored_phrases' ).val().split( /,/g );
        ignored = jQuery.map(ignored, function(value, index) { return value == phrase ? null : value; });
        jQuery( '#TSpell_ignored_phrases' ).val( ignored.join(',') );

	// update the UI
	atd_show_phrases( ignored );

	// show a nifty message to the user
    jQuery( '#TSpell_message' ).show();
}

function atd_ignore () {
	// get the ignored values and update the hidden field
	var ignored = jQuery( '#TSpell_ignored_phrases' ).val().split( /,/g );

    jQuery.map(jQuery( '#TSpell_add_ignore' ).val().split(/,\s*/g), function(value, index) { ignored.push(value); });

    jQuery( '#TSpell_ignored_phrases' ).val( ignored.join(',') );

	// update the UI
	atd_show_phrases( ignored );
	jQuery( '#TSpell_add_ignore' ).val('');

	// show that nifteroo messaroo to the useroo
    jQuery( '#TSpell_message' ).show();
}

function atd_ignore_init() {
	jQuery( '#TSpell_message' ).hide();
	jQuery( '#atd_ignores' ).delegate( 'a', 'click', function() {
		atd_unignore( jQuery(this).data( 'ignored' ) );
		return false;
	} );
	atd_show_phrases( jQuery( '#TSpell_ignored_phrases' ).val().split( /,/g ) );
}

// document.ready() does not execute in IE6 unless it's at the bottom of the page. oi!
if (navigator.appName == 'Microsoft Internet Explorer')
	setTimeout( atd_ignore_init, 2500 );
else
	jQuery( document ).ready( atd_ignore_init );
</script>
   <input type="hidden" name="TSpell_ignored_phrases" id="TSpell_ignored_phrases" value="<?php echo esc_attr( $ignores ); ?>">

          <p style="font-weight: bold"><?php _e( 'Ignored Phrases', 'tinymce-spellcheck' ); ?></font>

          <p><?php _e( 'Identify words and phrases to ignore while proofreading your posts and pages:', 'tinymce-spellcheck' ); ?></p>

          <p><input type="text" id="TSpell_add_ignore" name="TSpell_add_ignore"> <input type="button" value="<?php _e( 'Add', 'tinymce-spellcheck' ); ?>" onclick="javascript:atd_ignore()"></p>

          <div class="tagchecklist" id="atd_ignores"></div>

          <div class="plugin-update-tr" id="TSpell_message" style="display: none">
          <div class="update-message"><strong><?php _e( 'Be sure to click "Update Profile" at the bottom of the screen to save your changes.', 'tinymce-spellcheck' ); ?></strong></div>
          </div>

         </td>
      </tr>
   </table>

<?php
}