javascript coding example for avoiding collisions in a calendar