move javascript to $().click