;jQuery.loadMyImages = function(imgUrls, callback, delay) { var allImgs = [], loaded = 0, needto = imgUrls.length, errorDelay = 999, errorTimer function onImgComplete() { if (++loaded == needto) callback() else loadImg() } function loadImg() { allImgs[loaded] = new Image() $(allImgs[loaded]).bind('error load', onImgComplete) allImgs[loaded].src = imgUrls[loaded] } loadImg() return 0 }; function Init() { $("a[@rel='captcha_refresh']").each( function() { this.href = 'javascript:void(0);' $(this).click( function() { src = 'captcha.html?' + String(Math.random()).substr(2) $.loadMyImages(new Array(src), function () { $("img[@rel='captcha']").each( function() { this.src = src } ) } ) } ) } ); } $(document).ready(Init)