move javascript to external files which are included on demand
refactored templates