changed posts_structure.js into a jquery plugin