better management of javascript while overlaying a page with ajax calls