converted PHP functions to JS, added Foundation 4, simplified