Refactoring friends javascript. Broke the script up into logical sections.