step-by-step guide to javascript pagination (1)