When bail has been posted by cash deposit and remains on deposit at the time of the judgment or order withholding judgment, the clerk of the court shall, under the direction of the court, apply the money in satisfaction of fines, fees, costs and restitution imposed in the case and fines, fees, costs and restitution that have been imposed against the defendant in any other criminal or infraction action, and after satisfying the fines, fees, costs and restitution, shall refund the surplus, if any, to the person posting the cash deposit.
Idaho Code § 19-2908