You already have code in your showPrevious()
and showNext()
JS functions to apply and remove the active class to the appropriate div.
But now, this is a JS subject and you should really open a new thread in the JS section of Sitepoint as you may get quicker / more comprehensive responses.