I started by writing a function to pick a random number between two numbers given as arguments.
function get_random( $max, $min)
// return a random number between $min and $max
return (Math.floor((Math.random() % 1) * $diff) + $min);
Then I simply called this function with appropriate arguments (120 and 30) in my do_alarm function where I had previously just defined a number to use as seconds to wait.
// mark alarm as set
// determine time to wait in seconds
// wait for time to be up & sound alarm
setTimeout("sound_alarm()", (wait_secs * 1000))
Now the program alarm is set to a random interval, although it otherwise works exactly the same as my last revision. You can view all the code and try out a working example here.