Adding caption JS functionality