This paper proposes and solves an optimal dividend problem in which a two-state regimeswitching environment affects the dynamics of the company's cash surplus and, as a novel feature, also the bankruptcy level. The aim is to maximize the total expected profits from dividends until bankruptcy. The company's optimal dividend payout is therefore influenced by four factors simultaneously: Brownian fluctuations in the cash surplus, as well as regime changes in drift, volatility and bankruptcy levels. In particular, the average profitability can assume different signs in the two regimes. We find a rich structure of the optimal strategy, which, depending on the interaction of the model's parameters, is either of barrier-type or of liquidation-barrier type. Furthermore, we provide explicit expressions of the optimal policies and value functions. Finally, we complement our theoretical results by a detailed numerical study, where also a thorough analysis of the sensitivities of the optimal dividend policy with respect to the problem's parameters is performed.