(a) In an action to recover the possession of personal property, judgment for the plaintiff may be for the delivery of the property, or for the value thereof in case a delivery cannot be had, and damages for the detention.
(b) When the property has been delivered to the plaintiff and the defendant claims a return thereof, judgment for the defendant may be for the return of the property, or its value, in case a return cannot be had, and damages for the taking and withholding of the property.