Javascript and widget code