void SearchReplaceEngine::OpenDialog (bool replace) {
	static DialogSearchReplace *diag = nullptr;

	// already opened
	if (diag) {
		// it's the right type so give focus
		if(replace == hasReplace) {
			diag->FindEdit->SetFocus();
			diag->Show();
			OnDialogOpen();
			return;
		}
		// wrong type - destroy and create the right one
		diag->Destroy();
	}
	// create new one
	diag = new DialogSearchReplace(context, replace);
	diag->FindEdit->SetFocus();
	diag->Show();
	hasReplace = replace;
}
///////////////
// Open dialog
void SearchReplaceEngine::OpenDialog (bool replace) {
	static DialogSearchReplace *diag = NULL;
	wxString title = replace? _("Replace") : _("Find");

	// already opened
	if (diag) {
		// it's the right type so give focus
		if(replace == hasReplace) {
			diag->FindEdit->SetFocus();
			diag->Show();
			OnDialogOpen();
			return;
		}
		// wrong type - destroy and create the right one
		diag->Destroy();
	}
	// create new one
	diag = new DialogSearchReplace(((AegisubApp*)wxTheApp)->frame,replace,title);
	diag->FindEdit->SetFocus();
	diag->Show();
	hasReplace = replace;
}