move gallery function inside ajaxify