This paper proposes and solves an optimal dividend problem in which a two-state regime- switching environment affects the dynamics of the companys 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 companys optimal dividend payout is therefore influenced by four factors simul- taneously: 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 models 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 theoret- ical results by a detailed numerical study, where also a thorough analysis of the sensitivities of the optimal dividend policy with respect to the problems parameters is performed.