General Re-usuable Java Script functions for ease of implementation