(a) Where a lien is recorded under AS 34.35.050 - 34.35.120 for work done or materials furnished to a prime contractor, the prime contractor shall defend an action at the expense of the prime contractor, and during the pendency of the action the owner may withhold from the prime contractor the amount of money for which the lien is recorded.
(b) If judgment is given against the owner or the property of the owner upon the liens, the owner may deduct from the amount due or to become due by the owner to the prime contractor the amount of the judgment and costs.
(c) If the amount of the judgment and costs exceeds the amount due by the owner to the prime contractor, or if the owner settles with that contractor in full, the owner may recover back from the prime contractor an amount paid by the owner in excess of the contract price, and for which the prime contractor was originally liable.