Creating client editmode javascript function, refactoring page edit-mode javascript function