var delay = 1000var timerId, flash = true, i = 0, clockDisp, amPmfunction clock() {   if (i <= 500) {      i++      var now = new Date()      var theHour = now.getHours()      var theMin = now.getMinutes()      amPm = ((theHour < 12) ? " AM" : " PM")      theHour = ((theHour >= 12) ? theHour-12 : theHour)      clockDisp = " " + ((theHour < 10)? " " : "") + theHour      clockDisp += ((flash) ? ":" : " ")      clockDisp += ((theMin <10) ? "0" : "")      clockDisp += theMin + amPm      document.clock.elements[0].value = clockDisp      flash = !flash      timerId = setTimeout("clock()", delay)   } else {       clearTimeout(timerId)      document.clock.elements[0].value = ""   }}