Refactoring javascript into functions.  Stabilizing product selections.