var verifyImage; var targetImage; var verifyTimer; var verifyTimer_value = 500; function validateComment(theForm) { if(theForm.commentContent) { if(theForm.commentContent.value=="") { alert("You must enter a comment!"); theForm.commentContent.focus(); return false; } if(theForm.commentContent.value.length>255) { alert("Your comment can not be longer than 255 characters!"); theForm.commentContent.focus(); return false; } if(theForm.verifyCode && theForm.verifyCode.value=="") { alert("Verify code is required!"); theForm.verifyCode.focus(); return false; } } return true; } function refreshVerifyCode(imageId) { var temp = Math.round(Math.random() * 100000); verifyImage = document.getElementById(imageId); if(!verifyImage) return; var url = verifyImage.src; var pos = url.indexOf("?"); if(pos>0) url = url.substr(0, pos); url = url + "?refresh=" + temp; targetImage = new Image; targetImage.src = url; verifyTimer = setTimeout("waitForImageLoad();", verifyTimer_value); } function waitForImageLoad() { clearTimeout(verifyTimer); if(!targetImage.complete) { verifyTimer = setTimeout("waitForImageLoad();", verifyTimer_value); } else { verifyImage.src = targetImage.src; } }