added document click events and giveup click event