Can anyone find any bugs or performance improvements here?
<a href='#' id='from_arrow_down' onclick="timeOffset(-1,'from_time');">Click me</a>
function timeOffset(offset,time_id)
{
// javascipt utility that increments/decrements to the next 15 minute interval.
// When user pushes a button, program will get time from input box,
// increment (offset=1) or decrement (offset=-1) to next (or previous)
// quarter hour and out value back to input box.
// This is used on handheld devices where keyboard is very small and input is
// difficult and time consuming.
var pass_time = document.getElementById(time_id).value;
var tempDate;
// break in to hours and minutes
var HH = pass_time.substr(0,2);
var MM = pass_time.substr(2,4);
// dummy date
try{
tempDate = new Date("2000", "01", "01", HH, MM, "00", "0000");
}
catch(err)
{
alert("invalid time (HHMM)");
return;
}
// dummy minutes
var minutes = 999;
// iterate until we have reached an inter
while (minutes != 0 && minutes != 15 && minutes != 30 && minutes != 45){
tempDate.setMinutes( tempDate.getMinutes() + offset );
minutes = tempDate.getMinutes();
document.getElementById(time_id).value = cleanUp(tempDate.getHours()) + "" + cleanUp(tempDate.getMinutes());
}
}
function cleanUp(d)
{
if (d < 10){
d = "0" + d;
}
return d;
}