JavaScript utililty functions