public void removeDocument(Document doc) {
		openDocuments.remove(doc);
		
		// Fire Event
		fireDocumentRemovedEvent(doc);
		
		// Unregister the Document
		doc.setDocumentRepository(null);
		
		// Select the last non-iconified document in the window menu and 
		// change to it. Otherwise change to an iconified doc. Otherwise, change to null.
		if (mostRecentDocumentTouched == doc) {
			setMostRecentDocumentTouched(null);
			if (openDocumentCount() > 0) {
				for (int i = openDocumentCount() - 1; i >= 0; i--) {
					Document newDoc = getDocument(i);
					if (!newDoc.isIcon() || i == 0) {
						Outliner.menuBar.windowMenu.changeToWindow((OutlinerDocument) newDoc);
						return;
					}
				}
			}
			
			// We've closed the last document. We need to set focus 
			// somewhere, otherwise the ctrl-q, ctrl-n keys, etc. won't work correctly.
			Outliner.desktop.requestFocus();
		}
	}