Javascript functions

Javascript functions to support the drag