﻿
function OnContactFormSubmit(frm, sectionid) {
    // Disable submit button
    $("input[type='submit']", frm).attr('disabled', 'disabled');
    $("input[type='submit']", frm).val("Moment a.u.b.");

    var tdata = $(frm).serialize();

    $.ajaxSetup({ cache: false });
    $.ajax({
        type: 'POST',
        url:  "http://" + location.host + "/ContactForm/Send",
        data: tdata,
        datatype: "json",
        success: function (result) {
            if (result.success == false) {
                $("div[name='errorDiv']", frm).html(result.message);
                $("img[alt='CAPTCHA']", frm).attr('src', result.image);
                $("input[name='captcha-guid']", frm).attr('value', result.uniqueid);
            } else {
                location.href = result.redirectUrl;
                $("div[name='errorDiv']", frm).html(result.message);
            }
        }
    });

    $("input[type='submit']", frm).removeAttr("disabled");
    $("input[type='submit']", frm).val("Verzenden");

    return false;
}
