Add and modified the method of resize function
Restructure the coding, and fixed the next and previous button function