﻿
function refreshCaptcha(updatecontainer) {
    new Request({
        url: '/SolarAcademy/components/forms/utils.ashx',
        method: 'post',
        headers: { 'X-Requested-With': 'XMLHttpRequest' },
        onRequest: function() {
            try { if ($(updatecontainer)) { $(updatecontainer).spin(); } } catch (e) { dbug.log(e); }
        },
        onComplete: function() {
            try { if ($(updatecontainer)) { $(updatecontainer).unspin(); } } catch (e) { dbug.log(e); }
        },
        onSuccess: function(result) {
            var captcha = JSON.decode(result);

            if (captcha != null && captcha.src != null) {
                $('captchacode').value = captcha.code;
                $('captchaimage').src = captcha.src;
            }
        },
        onFail: function() { }
    }).send("method=getnewcaptcha");
}