Adding animation using javascript