A nonconforming structure may not be enlarged or extended unless a variance for such has been granted by the planning and zoning commission. A legal nonconforming structure may be maintained or repaired, under permit, in accordance with all pertinent building codes and ordinances. Change of ownership, tenancy, or management of a nonconforming structure shall not affect its legal, nonconforming status. Whenever a nonconforming structure is damaged, it may be restored subject to the following: (1) For principal buildings, the structure may be restored if the extent of the damage is 40 percent or less of the floor area of the structure or 40 percent or less of the replacement value of the structure, as determined by the building inspector. (2) For accessory buildings, the structure may be restored if the extent of the damage is 25 percent or less of the floor area of the structure or 25 percent or less of the replacement value of the structure, as determined by the building inspector. (3) Restoration must be completed within six months of the date of damage. (4) If the damage exceeds 40 percent of the floor area or replacement value of the principal structure or 25 percent of the floor area or replacement value of the accessory structure, as determined by the building inspector, the structure may only be restored in conformity with this chapter.