extract a method to judge valid surrounding posision and get the div index position to display show after a click