Any person who violates or is accessory to the violation of any provisions or requirements of this chapter, or who erects, constructs, alters, enlarges, converts, or moves any use of land, water or structure in violation of a detailed statement or plan submitted and approved under the provisions of the chapter, or who fails to obey and/or comply with any order, decree, or decision of either the Planning Board, Zoning Board of Appeals, Zoning Administrator or the Town Board, shall be guilty of an offense and shall be liable to a fine not exceeding $350 or imprisonment for a period not to exceed 15 days, or both. For conviction of a second offense which was committed within a period of five years of the first offense, such person shall be punishable by a fine not less than $350 nor more than $700 or imprisonment for a period not to exceed 15 days, or both; and, upon conviction for a third or subsequent offense committed within a period of five years of the first offense, such person shall be punishable by a fine not less than $700 nor more than $1,000 or imprisonment for a period not to exceed 15 days, or both. However, for the purpose of conferring jurisdiction upon courts and judicial officers generally, violations of this chapter shall be deemed misdemeanors, and for such purpose only all provisions of law relating to misdemeanors shall apply to such violations.