added timespan javascript function