If the first loan is in good standing, but the second is behind and in default, the second lender has the right to foreclose regardless of the market value. No matter which lien forecloses, if the loan is not reinstated, a borrower will lose their property to the bank or third party at trustee sale.
If you are in foreclosure, please consult with not only a real estate attorney, but also consult your tax accountant.
As you can imagine, for a great number of reasons, I'm not a fan of HELOCs. It's only too bad that so many home owners used them like a credit card during the boom cycle.