var active_element = null;
var sidebar_scroll_pos = null;

function isScrolledIntoView(e) {
    if (!e || typeof e.scrollTop !== 'function') {
        return false; // Handle the case when 'e' is not a valid element
    }
    var t = e.scrollTop(),
        i = t + $(e).height(),
        a = $(e).offset().top;
    return a + $(e).height() >= t && a <= i;
}



function is_support_html5_uploader() {
    return !!(window.File && window.FileList && window.Blob && (window.FileReader || window.FormData))
}

function save_form() {
    $("#bottom_bar_msg").text("Please wait... Saving...");
    var e = $("#form_header").data("form_properties").id,
        t = $("#form_header").data("form_properties");
    t.frame_height = $("#form_container").outerHeight();
    var i = $("#li_lastpage").data("field_properties"),
        a = $("#form_builder_sortable > li.dblive").not(".synched").not(".li_pagination");
    if (a.length >= 1) {
        var l = [];
        a.each(function(e) {
            l[e] = $(this).data("field_properties")
        })
    }
    var o = $("#form_builder_sortable").sortable("serialize", {
        key: "el_pos[]"
    });
    $.ajax({
        type: "POST",
        async: !0,
        url: "http://192.168.1.193:8124/save_form",
        data: {
            form_id: e,
            fp: t,
            ep: l,
            el_pos: o,
            lp: i
        },
        cache: !1,
        global: !1,
        dataType: "json",
        error: function(e, t, i) {
            alert("Error while saving. Error Message:\n" + e.responseText)
        },
        success: function(e) {
            "FormCorruption" == e.status && $("#form-corruption-fix-config").length && 1 == $("#form-corruption-fix-config").val() ? $("#dialog-form-corruption").dialog("open") : "ok" == e.status ? ($("#bottom_bar_loader").remove(), $("#bottom_bar_msg").hide(), $(".form_editor").data("form_saved", !0), $("#dialog-form-saved").dialog("open")) : alert("Error while saving. Error Message:\n" + e)
        }
    })
}

function select_form_header(e) {
    var t = $("#form_header").data("form_properties");
    if ($("#" + active_element).removeClass("highlighted"), active_element = null, $("#form_header .highlighted").removeClass("highlighted"), $("#pagination_header").removeClass("highlighted"), $("#" + e).addClass("highlighted"), $("#selected_field_image").css("visibility", "hidden"), $("#bottom_bar_field_action").fadeOut("fast", function() {
            $("#bottom_bar_content").animate({
                "margin-left": "225px"
            }, {
                duration: 200,
                queue: !1
            })
        }), 2 != $("#builder_tabs").tabs("option", "selected") && $("#builder_tabs").tabs("select", 2), 1 == $("#form_header").data("coming_from_click")) {
        var i = $("#content").position().top - 2;
        $("#sidebar").position().top > i && $("#sidebar").css("top", i)
    }
    if ($("#form_header").data("coming_from_click", 0), $("#all_form_properties > li").hide(), "pagination_header" == e) {
        "steps" == t.pagination_type ? $("#pagination_style_steps").prop("checked", !0) : "percentage" == t.pagination_type ? $("#pagination_style_percentage").prop("checked", !0) : $("#pagination_style_disabled").prop("checked", !0), "disabled" == t.pagination_type ? ($("#prop_pagination_style legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_pagination_style fieldset").css("border-color", "#DC6666")) : ($("#prop_pagination_style legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_pagination_style fieldset").css("border-color", "#3D6C10")), $("#prop_pagination_style").show(), $("#pagination_title_list > li").remove();
        var a = $("#form_builder_sortable > li.page_break"),
            l = "",
            o = 1;
        a.each(function(e) {
            var t = $(this);
            l += '<li><label for="pagetitleinput_' + o + '">' + o + '.</label><input type="text" value="' + t.data("field_properties").page_title + '" autocomplete="off" class="text" id="pagetitleinput_' + o + '" /></li>', o++
        }), $("#pagination_title_list").append(l), "disabled" == t.pagination_type ? $("#prop_pagination_titles").hide() : $("#prop_pagination_titles").show()
    } else {
        if ($("#all_form_properties .form_prop").show(), 1 == $("#form_prop_toggle_a").data("expand") ? ($("#form_prop_toggle_a").text("show less options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_up.gif"), $("#all_form_properties .advanced_prop").show()) : ($("#form_prop_toggle_a").text("show more options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_next.gif"), $("#all_form_properties .advanced_prop").hide()), 1 == $("#form_review").prop("checked") && 1 == $("#form_prop_toggle_a").data("expand") ? $("#form_prop_review").show() : $("#form_prop_review").hide(), 1 == $("#form_resume").prop("checked") && 1 == $("#form_prop_toggle_a").data("expand") ? $("#form_prop_resume").show() : $("#form_prop_resume").hide(), $("#form_title").val(t.name), $("#form_description").val(t.description), $("#form_label_alignment").val(t.label_alignment), $("#form_language").val(t.language), "form_header_title" == e ? $("#form_title").focus().select() : $("#form_description").focus().select(), $("#form_success_message").val(t.success_message), $("#form_redirect_url").val(t.redirect), 1 == t.redirect_enable ? ($("#form_redirect_option").prop("checked", !0), $("#form_success_message_option").prop("checked", !1), $("#form_success_message").hide(), $("#form_redirect_url").show()) : ($("#form_redirect_option").prop("checked", !1), $("#form_success_message_option").prop("checked", !0), $("#form_success_message").show(), $("#form_redirect_url").hide()), 1 == t.review ? $("#form_review").prop("checked", !0) : $("#form_review").prop("checked", !1), $("#pagination_header").length > 0 ? 1 == t.resume_enable ? $("#form_resume").prop("checked", !0) : $("#form_resume").prop("checked", !1) : (t.resume_enable = 0, $("#form_resume").prop("checked", !1), $("#form_resume").prop("disabled", !0)), $("#form_review_title").val(t.review_title), $("#form_review_description").val(t.review_description), $("#review_primary_text").val(t.review_primary_text), $("#review_secondary_text").val(t.review_secondary_text), $("#review_primary_img").val(t.review_primary_img), $("#review_secondary_img").val(t.review_secondary_img), 1 == t.review_use_image ? ($("#form_review_use_text").prop("checked", !1), $("#form_review_use_image").prop("checked", !0), $("#div_review_use_image").show(), $("#div_review_use_text").hide()) : ($("#form_review_use_text").prop("checked", !0), $("#form_review_use_image").prop("checked", !1), $("#div_review_use_image").hide(), $("#div_review_use_text").show()), $("#form_resume_subject").val(t.resume_subject), $("#form_resume_content").val(t.resume_content), $("#form_resume_from_name").val(t.resume_from_name), $("#form_resume_from_email_address").val(t.resume_from_email_address), t.password.length > 0 ? ($("#form_password_option").prop("checked", !0), $("#form_password").show(), $("#form_password_data").val(t.password)) : ($("#form_password_option").prop("checked", !1), $("#form_password").hide(), $("#form_password_data").val("")), $("#form_limit").val(t.limit), 1 == t.limit_enable ? ($("#form_limit_option").prop("checked", !0), $("#form_limit_div").show()) : ($("#form_limit_option").prop("checked", !1), $("#form_limit_div").hide()), 1 == t.encryption_enable ? $("#form_encryption_enable").prop("checked", !0) : $("#form_encryption_enable").prop("checked", !1), $("#form_captcha_type").val(t.captcha_type), 1 == t.captcha ? ($("#form_captcha").prop("checked", !0), $("#form_captcha_type_option").show(), "t" == t.captcha_type ? $("#form_prop_captcha508").hide() : $("#form_prop_captcha508").show()) : ($("#form_captcha").prop("checked", !1), $("#form_captcha_type_option").hide()), $("#form_unique_ip_maxcount").val(t.unique_ip_maxcount), $("#form_unique_ip_period").val(t.unique_ip_period), 1 == t.unique_ip ? ($("#form_unique_ip").prop("checked", !0), $("#form_unique_ip_div").show()) : ($("#form_unique_ip").prop("checked", !1), $("#form_unique_ip_div").hide()), 1 == t.name_hide ? $("#form_name_hide").prop("checked", !0) : $("#form_name_hide").prop("checked", !1), 1 == t.schedule_enable ? ($("#form_schedule_enable").prop("checked", !0), $("#form_prop_scheduling_start").show(), $("#form_prop_scheduling_end").show()) : ($("#form_schedule_enable").prop("checked", !1), $("#form_prop_scheduling_start").hide(), $("#form_prop_scheduling_end").hide()), null != t.schedule_start_date && "0000-00-00" != t.schedule_start_date) {
            var n = t.schedule_start_date.split("-");
            $("#scheduling_start_yyyy").val(n[0]), $("#scheduling_start_mm").val(parseInt(n[1], 10)), $("#scheduling_start_dd").val(parseInt(n[2], 10)), $("#linked_picker_scheduling_start").datepick("setDate", new Date(parseInt(n[0], 10), parseInt(n[1], 10) - 1, parseInt(n[2], 10)))
        } else $("#scheduling_start_yyyy").val(""), $("#scheduling_start_mm").val(""), $("#scheduling_start_dd").val("");
        if ("" != t.schedule_start_hour && "0000-00-00" != t.schedule_start_hour) {
            var r = t.schedule_start_hour.split(":");
            $("#scheduling_start_hour").val(r[0]), $("#scheduling_start_minute").val(r[1]), $("#scheduling_start_ampm").val(r[2])
        }
        if (null != t.schedule_end_date && "0000-00-00" != t.schedule_end_date) {
            var s = t.schedule_end_date.split("-");
            $("#scheduling_end_yyyy").val(s[0]), $("#scheduling_end_mm").val(parseInt(s[1], 10)), $("#scheduling_end_dd").val(parseInt(s[2], 10)), $("#linked_picker_scheduling_end").datepick("setDate", new Date(parseInt(s[0], 10), parseInt(s[1], 10) - 1, parseInt(s[2], 10)))
        } else $("#scheduling_end_yyyy").val(""), $("#scheduling_end_mm").val(""), $("#scheduling_end_dd").val("");
        if ("" != t.schedule_end_hour && "0000-00-00" != t.schedule_end_hour) {
            var d = t.schedule_end_hour.split(":");
            $("#scheduling_end_hour").val(d[0]), $("#scheduling_end_minute").val(d[1]), $("#scheduling_end_ampm").val(d[2])
        }
        $("#form_custom_script_url").val(t.custom_script_url), 1 == t.custom_script_enable ? ($("#form_custom_script_enable").prop("checked", !0), $("#form_custom_script_div").show()) : ($("#form_custom_script_enable").prop("checked", !1), $("#form_custom_script_div").hide()), 1 == t.approval_enable ? $("#form_approval_enable").prop("checked", !0) : $("#form_approval_enable").prop("checked", !1)
    }
    adjust_main_height(), check_synch_fields()
}

function check_synch_fields() {
    var e = $("#form_header").data("form_properties").id,
        t = $("#form_builder_sortable > li").not(".dblive").not(".synched").not(".highlighted").not(".li_pagination").not("#li_lastpage");
    if (t.length >= 10) {
        var i = [];
        t.each(function(e) {
            i[e] = $(this).data("field_properties")
        }), $.ajax({
            type: "POST",
            async: !0,
            url: "http://192.168.1.193:8124/synch_fields",
            data: {
                form_id: e,
                fp: i
            },
            cache: !1,
            global: !1,
            dataType: "json",
            error: function(e, t, i) {},
            success: function(e) {
                "ok" == e.status && $(e.updated_element_id).addClass("synched")
            }
        })
    }
}

function select_element(e) {
    var t = $(e);
    null != active_element && active_element != t.attr("id") && $("#" + active_element).removeClass("highlighted"), $("#form_header .highlighted").removeClass("highlighted"), $("#pagination_header").removeClass("highlighted"), active_element = t.attr("id"), t.addClass("highlighted"), t.removeClass("synched"), t.data("field_properties").position = t.index(), check_synch_fields(), $("#element_inactive_msg").hide(), $("#element_properties_form").show();
    var i = 40,
        a = 110,
        l = 75;
    $.browser.msie && (i = 80, a = 65, l = -10);
    var o = t.offset().top - i;
    Math.abs(o - $("#sidebar").offset().top) < $(window).height() ? $("#sidebar").animate({
        top: o
    }, {
        duration: 200,
        queue: !1
    }) : $("#sidebar").css("top", o), $("#selected_field_image").css("visibility", "visible").animate({
        top: o - a
    }, {
        duration: 200,
        queue: !1
    }), "lastpage" != t.data("field_properties").id ? $("#bottom_bar_content").animate({
        "margin-left": "90px"
    }, {
        duration: 200,
        queue: !1,
        complete: function() {
            $("#bottom_bar_field_action").fadeIn()
        }
    }) : $("#bottom_bar_field_action").fadeOut("fast", function() {
        $("#bottom_bar_content").animate({
            "margin-left": "225px"
        }, {
            duration: 200,
            queue: !1
        })
    }), load_properties("#" + active_element);
    var n = o + $("#sidebar").outerHeight() - l,
        r = $("#header").outerHeight() + $("#navigation").outerHeight() + $("#content").outerHeight();
    n > r && $("#main").animate({
        "padding-bottom": n - r + "px"
    }, {
        duration: 200,
        queue: !1
    })
}

function load_properties(e) {
    var t, i = $(e).data("field_properties");
    if ($("#all_properties li").hide(), $("#element_label").val(i.title), $("#prop_element_label").show(), t = "matrix" == i.type ? {
            matrix: "Matrix Choice"
        } : "radio" == i.type || "checkbox" == i.type || "select" == i.type ? {
            radio: "Multiple Choice",
            checkbox: "Checkboxes",
            select: "Drop Down"
        } : {
            text: "Single Line Text",
            textarea: "Paragraph Text",
            number: "Number",
            simple_name: "Name",
            date: "Date",
            time: "Time",
            phone: "Phone",
            money: "Price",
            url: "Web Site",
            email: "Email",
            address: "Address",
            file: "File Upload",
            section: "Section Break",
            signature: "Signature",
            media: "Media"
        }, $("#element_type > option").remove(), $.each(t, function(e, t) {
            $("#element_type").append($("<option></option>").val(e).html(t))
        }), "name" == i.type || "simple_name" == i.type || "name_wmiddle" == i.type || "simple_name_wmiddle" == i.type ? $("#element_type").val("simple_name") : "date" == i.type || "europe_date" == i.type ? $("#element_type").val("date") : "phone" == i.type || "simple_phone" == i.type ? $("#element_type").val("phone") : $("#element_type").val(i.type), 1 == i.is_db_live ? $("#element_type").prop("disabled", !0) : $("#element_type").prop("disabled", !1), $("#prop_element_type").show(), $("#pagination_header").length > 0 ? $("#element_position").text(i.position) : $("#element_position").text(i.position + 1), "1" == i.is_required ? $("#element_required").prop("checked", !0) : $("#element_required").prop("checked", !1), "1" == i.is_unique ? $("#element_unique").prop("checked", !0) : $("#element_unique").prop("checked", !1), "1" == i.is_readonly ? $("#element_readonly").prop("checked", !0) : $("#element_readonly").prop("checked", !1), "1" == i.is_required || "1" == i.is_unique || "1" == i.is_readonly ? ($("#prop_options legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_options fieldset").css("border-color", "#DC6666")) : ($("#prop_options legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_options fieldset").css("border-color", "#3D6C10")), $("#element_unique_span,#element_readonly_span").show(), $("#prop_options").show(), $("#prop_breaker").show(), $("#element_public,#element_private,#element_hidden").prop("checked", !1), "1" == i.is_private ? $("#element_private").prop("checked", !0) : "2" == i.is_private ? $("#element_hidden").prop("checked", !0) : $("#element_public").prop("checked", !0), "1" == i.is_private ? ($("#prop_access_control legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_access_control fieldset").css("border-color", "#DC6666")) : ($("#prop_access_control legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_access_control fieldset").css("border-color", "#3D6C10")), $("#prop_access_control").show(), $("#element_instructions").val(i.guidelines), $("#prop_instructions").show(), $("#element_custom_css").val(i.css_class), $("#prop_custom_css").show(), 1 == i.enable_placeholder ? $("#element_enable_placeholder,#element_enable_placeholder_text").prop("checked", !0) : $("#element_enable_placeholder,#element_enable_placeholder_text").prop("checked", !1), "text" == i.type) $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_default_value_text").val(i.default_value), $("#prop_default_value_text").show(), $("#element_text_default_length").val(i.text_default_length), $("#element_text_default_prefix").val(i.text_default_prefix), $("#element_text_default_random_type").val(i.text_default_random_type), $("#element_text_default_case").val(i.text_default_case), $("#default_value_text_random_div,#default_value_text_static_div").hide(), "random" == i.text_default_type ? ($("#element_default_value_text_random").prop("checked", !0), $("#default_value_text_random_div").show()) : ($("#element_default_value_text_static").prop("checked", !0), $("#default_value_text_static_div").show()), $("#element_range_min").val(i.range_min), $("#element_range_max").val(i.range_max), $("#element_range_limit_by").val(i.range_limit_by), parseInt(i.range_min) + parseInt(i.range_max) >= 1 ? ($("#prop_range legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_range fieldset").css("border-color", "#DC6666")) : ($("#prop_range legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_range fieldset").css("border-color", "#3D6C10")), "password" == i.constraint ? $("#prop_text_as_password").prop("checked", !0) : $("#prop_text_as_password").prop("checked", !1), $("#prop_text_options").show(), $("#prop_encrypt_data").prop("disabled", !1), $("#tooltip_is_encrypted").hide(), 1 == i.is_encrypted ? $("#prop_encrypt_data").prop("checked", !0) : $("#prop_encrypt_data").prop("checked", !1), 0 == $("#form_header").data("form_properties").encryption_enable && (i.is_encrypted = 0, $("#prop_encrypt_data").prop("checked", !1), $("#prop_encrypt_data").prop("disabled", !0), $("#tooltip_is_encrypted").show()), $("#prop_data_encryption").show(), $("#element_range_number_limit_by").hide(), $("#element_range_limit_by").show(), $("#prop_range").show();
    else if ("number" == i.type) $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_default_value").val(i.default_value), $("#prop_default_value").show(), $("#prop_placeholder").show(), $("#element_range_min").val(i.range_min), $("#element_range_max").val(i.range_max), $("#element_range_number_limit_by").val(i.range_limit_by), $("#prop_number_advance_options").show(), 1 == i.number_enable_quantity ? (rebuild_quantity_link_dropdown(), $("#prop_number_quantity_link").val(i.number_quantity_link), $("#prop_number_enable_quantity").prop("checked", !0), $("#prop_number_quantity_link_div").show()) : ($("#prop_number_enable_quantity").prop("checked", !1), $("#prop_number_quantity_link_div").hide()), parseInt(i.range_min) + parseInt(i.range_max) >= 1 ? ($("#prop_range legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_range fieldset").css("border-color", "#DC6666")) : ($("#prop_range legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_range fieldset").css("border-color", "#3D6C10")), $("#element_range_limit_by").hide(), $("#element_range_number_limit_by").show(), $("#prop_range").show();
    else if ("url" == i.type) $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_default_value").val(i.default_value), $("#prop_default_value").show(), $("#prop_placeholder").show();
    else if ("email" == i.type) {
        $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_default_value").val(i.default_value), $("#prop_default_value").show(), $("#prop_placeholder").show(), 1 == i.email_enable_confirmation ? ($("#prop_enable_email_confirmation").prop("checked", !0), $("#prop_enable_email_confirmation_div").show()) : ($("#prop_enable_email_confirmation").prop("checked", !1), $("#prop_enable_email_confirmation_div").hide());
        var a = "Confirm Email Address";
        null != i.email_confirm_field_label && null != i.email_confirm_field_label ? a = i.email_confirm_field_label : i.email_confirm_field_label = a, $("#prop_confirmation_field_label").val(a), $("#prop_email_options").show()
    } else if ("signature" == i.type) $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_unique_span").hide(), $("#element_readonly_span").hide(), $("#prop_section508_note").show();
    else if ("file" == i.type) $("#prop_file_options").show(), $("#prop_file_block_or_allow").val(i.file_block_or_allow), $("#file_type_list").val(i.file_type_list), 1 == i.file_enable_type_limit ? ($("#prop_file_enable_type_limit").prop("checked", !0), $("#form_file_limit_type").show()) : ($("#prop_file_enable_type_limit").prop("checked", !1), $("#form_file_limit_type").hide()), 1 == i.file_as_attachment ? $("#prop_file_as_attachment").prop("checked", !0) : $("#prop_file_as_attachment").prop("checked", !1), 1 == i.file_auto_upload ? $("#prop_file_auto_upload").prop("checked", !0) : $("#prop_file_auto_upload").prop("checked", !1), 1 == i.file_show_inline ? $("#prop_file_show_inline").prop("checked", !0) : $("#prop_file_show_inline").prop("checked", !1), $("#file_max_selection").val(i.file_max_selection), 1 == i.file_enable_multi_upload ? ($("#prop_file_multi_upload").prop("checked", !0), $("#form_file_max_selection").show()) : ($("#prop_file_multi_upload").prop("checked", !1), $("#form_file_max_selection").hide()), $("#file_size_max").val(i.file_size_max), 1 == i.file_enable_size_limit ? ($("#prop_file_limit_size").prop("checked", !0), $("#form_file_limit_size").show()) : ($("#prop_file_limit_size").prop("checked", !1), $("#form_file_limit_size").hide()), 1 == i.file_enable_advance ? ($("#prop_file_enable_advance").prop("checked", !0), $("#prop_file_advance_options").show()) : ($("#prop_file_enable_advance").prop("checked", !1), $("#prop_file_advance_options").hide()), $("#element_unique_span").hide(), $("#element_readonly_span").hide();
    else if ("textarea" == i.type) $("#element_size").val(i.size), $("#prop_element_size").show(), $("#element_default_value_textarea").val(i.default_value), $("#prop_default_value_textarea").show(), $("#prop_placeholder").show(), $("#prop_encrypt_data").prop("disabled", !1), $("#tooltip_is_encrypted").hide(), 1 == i.is_encrypted ? $("#prop_encrypt_data").prop("checked", !0) : $("#prop_encrypt_data").prop("checked", !1), 0 == $("#form_header").data("form_properties").encryption_enable && (i.is_encrypted = 0, $("#prop_encrypt_data").prop("checked", !1), $("#prop_encrypt_data").prop("disabled", !0), $("#tooltip_is_encrypted").show()), $("#prop_data_encryption").show(), $("#element_range_min").val(i.range_min), $("#element_range_max").val(i.range_max), $("#element_range_limit_by").val(i.range_limit_by), parseInt(i.range_min) + parseInt(i.range_max) >= 1 ? ($("#prop_range legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_range fieldset").css("border-color", "#DC6666")) : ($("#prop_range legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_range fieldset").css("border-color", "#3D6C10")), $("#element_range_number_limit_by").hide(), $("#element_range_limit_by").show(), $("#prop_range").show();
    else if ("name" == i.type || "simple_name" == i.type || "name_wmiddle" == i.type || "simple_name_wmiddle" == i.type) $("#name_format").val(i.type), 1 == i.is_db_live ? $("#name_format").prop("disabled", !0) : $("#name_format").prop("disabled", !1), $("#prop_name_format").show(), $("#element_unique_span").hide();
    else if ("time" == i.type) 1 == i.time_showsecond ? $("#prop_time_showsecond").prop("checked", !0) : $("#prop_time_showsecond").prop("checked", !1), 1 == i.time_24hour ? $("#prop_time_24hour").prop("checked", !0) : $("#prop_time_24hour").prop("checked", !1), $("#element_default_time").val(i.default_value), $("#prop_default_time").show(), $("#prop_time_options").show();
    else if ("address" == i.type) $("#element_countries").val(i.default_value), $("#prop_default_country").show(), 1 == i.address_hideline2 ? $("#prop_address_hideline2").prop("checked", !0) : $("#prop_address_hideline2").prop("checked", !1), 1 == i.address_us_only ? ($("#prop_address_us_only").prop("checked", !0), $("#element_countries").prop("disabled", !0)) : ($("#prop_address_us_only").prop("checked", !1), $("#element_countries").prop("disabled", !1)), $("#prop_address_options").show(), $("#element_unique_span").hide();
    else if ("money" == i.type) $("#element_default_value").val(i.default_value), $("#prop_default_value").show(), "" == i.constraint || "dollar" == i.constraint ? $("#money_format").val("dollar") : $("#money_format").val(i.constraint), $("#prop_currency_format").show();
    else if ("phone" == i.type) $("#element_default_phone1").val(i.default_value.substr(0, 3)), $("#element_default_phone2").val(i.default_value.substr(3, 3)), $("#element_default_phone3").val(i.default_value.substr(6, 4)), $("#prop_default_phone").show(), $("#phone_format").val(i.type), $("#prop_phone_format").show();
    else if ("simple_phone" == i.type) $("#element_default_value").val(i.default_value), $("#prop_default_value").show(), $("#phone_format").val(i.type), $("#prop_phone_format").show();
    else if ("date" == i.type || "europe_date" == i.type) {
        $("#date_type").val(i.type), $("#prop_date_format").show(), $("#element_default_date").val(i.default_value), $("#prop_default_date").show(), $("#prop_date_options").show(), 1 == i.date_enable_range || 1 == i.date_enable_selection_limit || 1 == i.date_disable_past_future || 1 == i.date_disable_dayofweek || 1 == i.date_disable_specific ? ($("#prop_date_options legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
        var l = !1;
        if (null != i.date_range_min && "0000-00-00" != i.date_range_min && (i.date_range_min.indexOf("-00-00") > -1 && (l = !0), i.date_range_min.indexOf("-00-01") > -1 && (l = !0)), null != i.date_range_max && "0000-00-00" != i.date_range_max && (i.date_range_max.indexOf("-00-00") > -1 && (l = !0), i.date_range_max.indexOf("-00-01") > -1 && (l = !0)), 1 == i.date_enable_range ? ($("#prop_date_range").prop("checked", !0), $("#prop_date_range_details").show(), $("#prop_date_range_fixed,#prop_date_range_relative").hide(), 1 == l ? ($("#prop_date_range_format_switcher").val("relative"), $("#prop_date_range_relative").show()) : ($("#prop_date_range_format_switcher").val("fixed"), $("#prop_date_range_fixed").show())) : ($("#prop_date_range").prop("checked", !1), $("#prop_date_range_details").hide()), 1 == l) null != i.date_range_min && "0000-00-00" != i.date_range_min ? "01" == (o = i.date_range_min.split("-"))[2] ? $("#date_range_min_relative").val(-parseInt(o[0])) : $("#date_range_min_relative").val(parseInt(o[0])) : $("#date_range_min_relative").val(0), null != i.date_range_max && "0000-00-00" != i.date_range_max ? "01" == (n = i.date_range_max.split("-"))[2] ? $("#date_range_max_relative").val(-parseInt(n[0])) : $("#date_range_max_relative").val(parseInt(n[0])) : $("#date_range_max_relative").val(0);
        else {
            if (null != i.date_range_min && "0000-00-00" != i.date_range_min) {
                var o = i.date_range_min.split("-");
                $("#date_range_min_yyyy").val(o[0]), $("#date_range_min_mm").val(parseInt(o[1], 10)), $("#date_range_min_dd").val(parseInt(o[2], 10)), $("#linked_picker_range_min").datepick("setDate", new Date(parseInt(o[0], 10), parseInt(o[1], 10) - 1, parseInt(o[2], 10)))
            } else $("#date_range_min_yyyy").val(""), $("#date_range_min_mm").val(""), $("#date_range_min_dd").val("");
            if (null != i.date_range_max && "0000-00-00" != i.date_range_max) {
                var n = i.date_range_max.split("-");
                $("#date_range_max_yyyy").val(n[0]), $("#date_range_max_mm").val(parseInt(n[1], 10)), $("#date_range_max_dd").val(parseInt(n[2], 10)), $("#linked_picker_range_max").datepick("setDate", new Date(parseInt(n[0], 10), parseInt(n[1], 10) - 1, parseInt(n[2], 10)))
            } else $("#date_range_max_yyyy").val(""), $("#date_range_max_mm").val(""), $("#date_range_max_dd").val("")
        }
        if (1 == i.date_enable_selection_limit ? ($("#prop_date_selection_limit").prop("checked", !0), $("#form_date_selection_limit").show(), $("#date_selection_max").val(i.date_selection_max)) : ($("#prop_date_selection_limit").prop("checked", !1), $("#form_date_selection_limit").hide(), $("#date_selection_max").val(i.date_selection_max)), 1 == i.date_disable_past_future ? ($("#prop_date_past_future_selection").prop("checked", !0), $("#prop_date_past_future").val(i.date_past_future).prop("disabled", !1)) : ($("#prop_date_past_future_selection").prop("checked", !1), $("#prop_date_past_future").val(i.date_past_future).prop("disabled", !0)), 1 == i.date_disable_dayofweek ? ($("#prop_date_disable_dayofweek").prop("checked", !0), $("#div_disable_dayofweek_list").show()) : ($("#prop_date_disable_dayofweek").prop("checked", !1), $("#div_disable_dayofweek_list").hide()), $("#div_disable_dayofweek_list input.dayofweek").prop("checked", !1), null != i.date_disabled_dayofweek_list && "" != i.date_disabled_dayofweek_list) {
            var r = i.date_disabled_dayofweek_list.split(",");
            $.each(r, function(e, t) {
                $("#dayofweek_" + t).prop("checked", !0)
            })
        } else $("#div_disable_dayofweek_list").hide(), $("#prop_date_disable_dayofweek").prop("checked", !1);
        if (1 == i.date_disable_specific ? ($("#prop_date_disable_specific").prop("checked", !0), $("#form_date_disable_specific").show()) : ($("#prop_date_disable_specific").prop("checked", !1), $("#form_date_disable_specific").hide()), null != i.date_disabled_list && "" != i.date_disabled_list) {
            var s = i.date_disabled_list.split(", ");
            $("#date_disabled_list").datepick("setDate", s)
        }
        $("#date_disabled_list").val(i.date_disabled_list)
    } else if ("section" == i.type) $("#prop_options").hide(), 1 == i.section_display_in_email ? $("#prop_section_email_display").prop("checked", !0) : $("#prop_section_email_display").prop("checked", !1), $("#prop_section_size").val(i.size), 1 == i.section_enable_scroll ? ($("#prop_section_enable_scroll").prop("checked", !0), $("#div_section_size").show()) : ($("#prop_section_enable_scroll").prop("checked", !1), $("#div_section_size").hide()), $("#prop_section_options").show();
    else if ("radio" == i.type || "checkbox" == i.type || "select" == i.type) {
        var d = "",
            p = 0,
            c = "",
            m = "",
            u = 0,
            f = i.options,
            h = [];
        $.each(f, function(e, t) {
            h[t.position] = e
        }), "radio" == i.type || "select" == i.type ? m = "radio" : "checkbox" == i.type && (m = "checkbox"), "select" == i.type && ($("#element_size").val(i.size), $("#prop_element_size").show()), $.each(h, function(e, t) {
            e > 0 && ("1" == i.options[t].is_hidden ? u++ : (p = t, d = i.options[t].option, c += '<li><input type="' + m + '" ' + ("1" == i.options[t].is_default ? ' checked="checked" ' : "") + ' title="Select this choice as the default." class="choices_default" name="choices_default" id="choicedef_' + p + '" /><input type="text" value="' + d.replace(/\"/g, "&quot;") + '" autocomplete="off" class="text" id="choice_' + p + '" /> <a href="#" class="add_choice" title="Add Choice" id="choiceadd_' + p + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Hide Choice" id="choicedel_' + p + '"><span class="icon-cancel-circle"></span></a></li>'))
        }), $("#element_choices li").remove(), $("#element_choices").append(c), $("#prop_choices").show(), $("#toggle_hidden_choices").hide(), $("#hidden_choices_counter").text("0"), u > 0 && ($("#hidden_choices_counter").text(u), $("#toggle_hidden_choices").show()), "radio" != i.type && "checkbox" != i.type || ($("#element_choice_columns").val(i.choice_columns), $("#prop_choice_columns").show()), "radio" != i.type && "checkbox" != i.type || ($("#prop_other_choices_label").val(i.choice_other_label), 1 == i.choice_has_other ? ($("#prop_choices_other_checkbox").prop("checked", !0), $("#prop_other_choices_label").prop("disabled", !1)) : ($("#prop_choices_other_checkbox").prop("checked", !1), $("#prop_other_choices_label").prop("disabled", !0)), "radio" == i.type ? ("random" == i.constraint ? $("#prop_choices_randomize").prop("checked", !0) : $("#prop_choices_randomize").prop("checked", !1), $("#prop_choices_randomize_span").show()) : $("#prop_choices_randomize_span").hide(), $("#prop_choices_other").show()), "radio" != i.type && "select" != i.type || ($("#choice_max_entry").val(i.choice_max_entry), i.choice_max_entry > 0 ? ($("#prop_choice_max_entry_enable").prop("checked", !0), $("#form_choice_max_entry").show()) : ($("#prop_choice_max_entry_enable").prop("checked", !1), $("#form_choice_max_entry").hide()), $("#prop_choice_max_entry").show()), "checkbox" == i.type && ($("#prop_choice_limit_rule").val(i.choice_limit_rule), $("#prop_choice_limit_qty").val(i.choice_limit_qty), $("#prop_choice_limit_range_min").val(i.choice_limit_range_min), $("#prop_choice_limit_range_max").val(i.choice_limit_range_max), $("#prop_choice_limit_range_span,#prop_choice_limit_qty_span").hide(), "between" == i.choice_limit_rule ? $("#prop_choice_limit_range_span").show() : $("#prop_choice_limit_qty_span").show(), "1" == i.is_required && $("#prop_choice_limit").show()), $("#element_unique_span").hide(), $("#element_readonly_span").hide()
    } else if ("matrix" == i.type) {
        d = "", p = 0, c = "";
        var g = i.options;
        h = [], $.each(g, function(e, t) {
            h[t.position] = e
        });
        var b = "";
        $.each(h, function(e, t) {
            e > 0 && (choice_element_id = t, d = i.options[t].row_title, e > 1 && (b = '<a href="#" class="del_choice" title="Remove Permanently" id="matrixrowdel_' + choice_element_id + '"><span class="icon-remove"></span></a>'), c += '<li><input type="text" value="' + d.replace(/\"/g, "&quot;") + '" autocomplete="off" class="text" id="matrixrow_' + choice_element_id + '" /> <a href="#" class="add_choice" title="Add" id="matrixrowadd_' + choice_element_id + '"><span class="icon-plus-circle"></span></a>' + b + "</li>")
        }), $("#element_matrix_row li").remove(), $("#element_matrix_row").append(c), $("#prop_matrix_row").show(), c = "";
        var y = parseInt($("#" + active_element).data("field_properties").id),
            x = i.options[y].column_data,
            _ = [];
        $.each(x, function(e, t) {
            _[t.position] = e
        }), $.each(_, function(e, t) {
            e > 0 && (p = t, c += '<li><input type="text" value="' + (d = x[t].column_title).replace(/\"/g, "&quot;") + '" autocomplete="off" class="text" id="matrixcol_' + p + '" /> <a href="#" class="add_choice" title="Add" id="matrixcoladd_' + p + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Remove Permanently" id="matrixcoldel_' + p + '"><span class="icon-remove"></span></a></li>')
        }), $("#element_matrix_column li").remove(), $("#element_matrix_column").append(c), $("#prop_matrix_column").show(), 1 == i.matrix_allow_multiselect ? $("#prop_matrix_allow_multiselect").prop("checked", !0) : $("#prop_matrix_allow_multiselect").prop("checked", !1), $("#" + active_element).hasClass("dblive") ? $("#prop_matrix_allow_multiselect").prop("disabled", !0) : $("#prop_matrix_allow_multiselect").prop("disabled", !1), $("#prop_matrix_options").show(), $("#prop_instructions").hide(), $("#element_unique_span").hide(), $("#element_label").val(i.guidelines), $("#element_readonly_span").hide()
    } else "page_break" == i.type ? ($("#all_properties li").hide(), $("#prop_page_break_button").show(), 1 == i.submit_use_image ? ($("#prop_submit_use_image").prop("checked", !0), $("#prop_submit_use_text").prop("checked", !1), "" == i.submit_primary_img || null == i.submit_primary_img ? $("#submit_primary_img").val("http://") : $("#submit_primary_img").val(i.submit_primary_img), "" == i.submit_secondary_img || null == i.submit_secondary_img ? $("#submit_secondary_img").val("http://") : $("#submit_secondary_img").val(i.submit_secondary_img), $("#" + active_element).hasClass("firstpage") ? ($("#lbl_submit_secondary_img").hide(), $("#submit_secondary_img").hide()) : ($("#lbl_submit_secondary_img").show(), $("#submit_secondary_img").show()), $("#div_submit_use_image").show(), $("#div_submit_use_text").hide()) : ($("#prop_submit_use_image").prop("checked", !1), $("#prop_submit_use_text").prop("checked", !0), $("#submit_primary_text").val(i.submit_primary_text), $("#submit_secondary_text").val(i.submit_secondary_text), $("#" + active_element).hasClass("firstpage") ? ($("#lbl_submit_secondary_text").hide(), $("#submit_secondary_text").hide()) : ($("#lbl_submit_secondary_text").show(), $("#submit_secondary_text").show()), $("#div_submit_use_image").hide(), $("#div_submit_use_text").show())) : "media" == i.type && ($("#prop_options").hide(), $("#prop_media_type").show(), $("#element_media_" + i.media_type).prop("checked", !0), $("#div_image_src,#div_image_upload_file").hide(), null == i.media_image_src || 0 == i.media_image_src.length ? ($("#element_image_upload_file").prop("checked", !0), $("#div_image_upload_file").show()) : ($("#element_image_set_url").prop("checked", !0), $("#div_image_src").show()), $("#element_image_src").val(i.media_image_src), $("#element_image_width").val(i.media_image_width), $("#element_image_height").val(i.media_image_height), $("#element_image_width").data("original-image-width", i.media_image_width), $("#element_image_height").data("original-image-height", i.media_image_height), $("#element_media_image_alt").val(i.media_image_alt), $("#element_media_image_href").val(i.media_image_href), "l" == i.media_image_alignment ? $("#element_image_alignment_left").prop("checked", !0) : "c" == i.media_image_alignment ? $("#element_image_alignment_center").prop("checked", !0) : "r" == i.media_image_alignment && $("#element_image_alignment_right").prop("checked", !0), "1" == i.media_display_in_email ? $("#element_media_display_in_email").prop("checked", !0) : $("#element_media_display_in_email").prop("checked", !1), $("#element_media_video_src").val(i.media_video_src), "small" == i.media_video_size ? $("#element_media_video_size_small").prop("checked", !0) : "medium" == i.media_video_size ? $("#element_media_video_size_medium").prop("checked", !0) : "large" == i.media_video_size && $("#element_media_video_size_large").prop("checked", !0), "1" == i.media_video_muted ? $("#element_media_video_muted").prop("checked", !0) : $("#element_media_video_muted").prop("checked", !1), $("#element_media_video_caption_file").val(i.media_video_caption_file), null == i.media_video_caption_file || 0 == i.media_video_caption_file.length ? ($("#element_media_video_enable_caption").prop("checked", !1), $("#div_video_caption_file").hide()) : ($("#element_media_video_enable_caption").prop("checked", !0), $("#div_video_caption_file").show()), "image" == i.media_type ? $("#prop_image_options").show() : "video" == i.media_type && $("#prop_video_options").show());
    $("#element_label").focus().select()
}

function set_properties(e, t) {
    var i = $("#" + active_element),
        a = i.data("field_properties"),
        l = ' <span class="required">*</span>',
        o = active_element.split("_")[1];
    if ("element_label" == e) "section" == a.type || "media" == a.type ? ($("#" + active_element + " > h3").html(t.replace(/\n/g, "<br />")), a.title = t) : "matrix" == a.type ? ("0" === a.is_required && (l = ""), $("#" + active_element + " caption").html(t.replace(/\n/g, "<br />") + l), a.guidelines = t) : "name" == a.type || "name_wmiddle" == a.type || "simple_name" == a.type || "simple_name_wmiddle" == a.type || "time" == a.type || "address" == a.type || "date" == a.type || "europe_date" == a.type || "phone" == a.type ? ("0" === a.is_required && (l = ""), $("#" + active_element + " > fieldset > span.description").html(t.replace(/\n/g, "<br />") + l), a.title = t) : "email" == a.type ? ("0" === a.is_required && (l = ""), $("#" + active_element + " > label:not(.confirm_email_label)").html(t.replace(/\n/g, "<br />") + l), a.title = t) : ("0" === a.is_required && (l = ""), $("#" + active_element + " > label").html(t.replace(/\n/g, "<br />") + l), $("#" + active_element + " > span.description").html(t.replace(/\n/g, "<br />") + l), a.title = t);
    else if ("element_encrypted" == e) a.is_encrypted = t;
    else if ("element_media_type" == e) {
        $("#" + active_element + " .media_icon > span").removeClass("icon-image2 icon-play2"), $("#prop_image_options,#prop_video_options").hide();
        var n = "";
        if ($("#" + active_element).removeClass("media_image media_video"), "image" == t) {
            n = "icon-image2", $("#" + active_element).addClass("media_image"), $("#prop_image_options").show();
            var r = videojs("video_" + a.id);
            void 0 !== r && (r.dispose(), $("#" + active_element + " .media_video_container").remove(), $("#element_image_src").keyup())
        } else "video" == t && (n = "icon-play2", $("#" + active_element).addClass("media_video"), $("#prop_video_options").show(), $("#" + active_element + " .media_image_container").remove(), $("#element_media_video_src").keyup(), a.media_display_in_email = 0);
        $("#" + active_element + " .media_icon > span").addClass(n), a.media_type = t
    } else if ("element_required" == e) "1" == t ? ("matrix" == a.type ? $("#" + active_element + " caption").append(l) : ($("#" + active_element + " > label").append(l), $("#" + active_element + " > span.description").append(l), $("#" + active_element + " fieldset > span.description").append(l)), "checkbox" == a.type && $("#prop_choice_limit").fadeIn()) : ("checkbox" == a.type && $("#prop_choice_limit").hide(), $("#" + active_element + " span.required").remove()), a.is_required = t, "1" == a.is_required || "1" == a.is_unique || "1" == a.is_readonly ? ($("#prop_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_options fieldset").css("border-color", "#DC6666")) : ($("#prop_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_unique" == e) a.is_unique = t, "1" == a.is_required || "1" == a.is_unique || "1" == a.is_readonly ? ($("#prop_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_options fieldset").css("border-color", "#DC6666")) : ($("#prop_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_readonly" == e) a.is_readonly = t, "1" == a.is_required || "1" == a.is_unique || "1" == a.is_readonly ? ($("#prop_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_options fieldset").css("border-color", "#DC6666")) : ($("#prop_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_visibility" == e) "1" == t ? ($("#" + active_element).addClass("private"), $("#prop_access_control legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_access_control fieldset").css("border-color", "#DC6666")) : ($("#" + active_element).removeClass("private"), $("#prop_access_control legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_access_control fieldset").css("border-color", "#3D6C10")), a.is_private = t;
    else if ("element_text_default_type" == e) $("#default_value_text_static_div,#default_value_text_random_div").hide(), "static" == t ? ($("#default_value_text_static_div").show(), $("#" + active_element + " :input").val(a.default_value)) : ($("#default_value_text_random_div").show(), rebuild_default_text_random_preview()), a.text_default_type = t;
    else if ("element_guidelines" == e) {
        if ("section" == a.type) $("#" + active_element + " > p").html(t.replace(/\n/g, "<br />"));
        else if ("media" == a.type) $("#" + active_element + " > p.media_guidelines").html(t.replace(/\n/g, "<br />"));
        else if ($("#" + active_element + " > p.guidelines").length) $("#" + active_element + " > p.guidelines").html(t.replace(/\n/g, "<br />")), $("#" + active_element + " > p.guidelines").text().length < 1 && ($("#" + active_element + " > p.guidelines").remove(), 0 == $("#form_builder_sortable p.guidelines").length && (50 >= $("#form_builder_sortable > li").size() ? $("#form_builder_sortable > li").not(".li_pagination").animate({
            width: "97%"
        }, {
            duration: 250,
            queue: !0,
            complete: function() {
                $("#main_body").addClass("no_guidelines")
            }
        }) : $("#form_builder_sortable > li").not(".li_pagination").css("width", "97%"), $("#main_body").addClass("no_guidelines")));
        else if ("" != t) {
            if ($("#main_body").hasClass("no_guidelines")) {
                var s = "61%";
                "top_label" != $("#form_header").data("form_properties").label_alignment && (s = "76%"), 50 >= $("#form_builder_sortable > li").size() ? $("#form_builder_sortable > li").not(".li_pagination").animate({
                    width: s
                }, {
                    duration: 250,
                    queue: !0,
                    complete: function() {
                        $("#main_body").removeClass("no_guidelines")
                    }
                }) : $("#form_builder_sortable > li").not(".li_pagination").css("width", s), $("#main_body").removeClass("no_guidelines")
            }
            $("#" + active_element).append('<p class="guidelines">' + t.replace(/\n/g, "<br />") + "</p>")
        }
        a.guidelines = t
    } else if ("element_custom_css" == e) a.css_class = t;
    else if ("element_email_confirm_field_label" == e) a.email_confirm_field_label = t, "0" === a.is_required && (l = ""), $("#" + active_element + " > label.confirm_email_label").html(t.replace(/\n/g, "<br />") + l);
    else if ("element_section_display_in_email" == e) a.section_display_in_email = t;
    else if ("element_enable_placeholder" == e) a.enable_placeholder = t;
    else if ("element_email_enable_confirmation" == e) {
        if (a.email_enable_confirmation = t, 1 == t) {
            $("#prop_enable_email_confirmation_div").show(), "0" === a.is_required && (l = "");
            var d = '<label class="description confirm_email_label" for="element_' + active_element + '_confirm">' + a.email_confirm_field_label + " " + l + '</label><div><input id="element_' + active_element + '_confirm" name="element_' + active_element + '_confirm" class="element text ' + a.size + ' confirm_email_input" type="text" maxlength="255" value="" /></div>';
            $("#" + active_element).append(d)
        } else $("#prop_enable_email_confirmation_div").hide(), $("#" + active_element + " > label.confirm_email_label").remove(), $("#" + active_element + " input.confirm_email_input").parent().remove()
    } else if ("element_date_enable_range" == e) 1 == t ? ($("#prop_date_range_details").slideDown(), $("#prop_date_past_future").prop("disabled", !0), $("#prop_date_past_future_selection").prop("checked", !1), a.date_disable_past_future = 0) : $("#prop_date_range_details").hide(), a.date_enable_range = t, 1 == a.date_enable_range || 1 == a.date_enable_selection_limit || 1 == a.date_disable_past_future || 1 == a.date_disable_dayofweek || 1 == a.date_disable_specific ? ($("#prop_date_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_date_range_format" == e) {
        if ($("#prop_date_range_fixed,#prop_date_range_relative").hide(), $("#date_range_min_yyyy,#date_range_min_mm,#date_range_min_dd").val(""), $("#date_range_max_yyyy,#date_range_max_mm,#date_range_max_dd").val(""), $("#date_range_min_relative,#date_range_max_relative").val(0), "relative" == t) {
            $("#prop_date_range_relative").fadeIn();
            var p = ("0000" + parseInt($("#date_range_min_relative").val())).slice(-4),
                c = ("0000" + parseInt($("#date_range_max_relative").val())).slice(-4);
            a.date_range_min = p + "-00-00", a.date_range_max = c + "-00-00"
        } else "fixed" == t && ($("#prop_date_range_fixed").fadeIn(), a.date_range_min = $("#date_range_min_yyyy").val() + "-" + $("#date_range_min_mm").val() + "-" + $("#date_range_min_dd").val(), a.date_range_max = $("#date_range_max_yyyy").val() + "-" + $("#date_range_max_mm").val() + "-" + $("#date_range_max_dd").val())
    } else if ("element_date_range_min" == e) a.date_range_min = t;
    else if ("element_date_range_max" == e) a.date_range_max = t;
    else if ("element_date_enable_selection_limit" == e) 1 == t ? $("#form_date_selection_limit").slideDown() : $("#form_date_selection_limit").hide(), a.date_enable_selection_limit = t, 1 == a.date_enable_range || 1 == a.date_enable_selection_limit || 1 == a.date_disable_past_future || 1 == a.date_disable_dayofweek || 1 == a.date_disable_specific ? ($("#prop_date_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_section_enable_scroll" == e) 1 == t ? ($("#" + active_element).removeClass("section_scroll_small section_scroll_medium section_scroll_large").addClass("section_scroll_" + a.size), $("#div_section_size").slideDown()) : ($("#" + active_element).removeClass("section_scroll_small section_scroll_medium section_scroll_large"), $("#div_section_size").fadeOut("fast")), a.section_enable_scroll = t;
    else if ("element_date_selection_max" == e) a.date_selection_max = parseInt(t);
    else if ("element_date_disable_specific" == e) 1 == t ? $("#form_date_disable_specific").slideDown() : $("#form_date_disable_specific").hide(), a.date_disable_specific = t, 1 == a.date_enable_range || 1 == a.date_enable_selection_limit || 1 == a.date_disable_past_future || 1 == a.date_disable_dayofweek || 1 == a.date_disable_specific ? ($("#prop_date_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_date_disabled_list" == e) a.date_disabled_list = t;
    else if ("element_date_disable_past_future" == e) 1 == t ? ($("#prop_date_past_future").prop("disabled", !1), $("#prop_date_range_details").hide(), $("#prop_date_range").prop("checked", !1), a.date_enable_range = 0) : $("#prop_date_past_future").prop("disabled", !0), a.date_disable_past_future = t, 1 == a.date_enable_range || 1 == a.date_enable_selection_limit || 1 == a.date_disable_past_future || 1 == a.date_disable_dayofweek || 1 == a.date_disable_specific ? ($("#prop_date_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_date_disable_dayofweek" == e) a.date_disable_dayofweek = t, 1 == t ? $("#div_disable_dayofweek_list").slideDown() : $("#div_disable_dayofweek_list").hide(), 1 == a.date_enable_range || 1 == a.date_enable_selection_limit || 1 == a.date_disable_past_future || 1 == a.date_disable_dayofweek || 1 == a.date_disable_specific ? ($("#prop_date_options legend").css({
        "background-color": "#DC6666",
        "border-color": "#DC6666"
    }), $("#prop_date_options fieldset").css("border-color", "#DC6666")) : ($("#prop_date_options legend").css({
        "background-color": "#3D6C10",
        "border-color": "#3D6C10"
    }), $("#prop_date_options fieldset").css("border-color", "#3D6C10"));
    else if ("element_date_disabled_dayofweek_list" == e) a.date_disabled_dayofweek_list = t;
    else if ("date_past_future" == e) a.date_past_future = t;
    else if ("element_file_enable_type_limit" == e) 1 == t ? $("#form_file_limit_type").slideDown() : $("#form_file_limit_type").fadeOut("slow"), a.file_enable_type_limit = t;
    else if ("element_file_block_or_allow" == e) a.file_block_or_allow = t, a.file_type_list = "", $("#file_type_list").val("");
    else if ("element_file_type_list" == e) a.file_type_list = t;
    else if ("element_file_as_attachment" == e) a.file_as_attachment = t;
    else if ("element_file_auto_upload" == e) a.file_auto_upload = t;
    else if ("element_file_show_inline" == e) a.file_show_inline = t;
    else if ("element_file_enable_multi_upload" == e) 1 == t ? $("#form_file_max_selection").slideDown() : $("#form_file_max_selection").fadeOut("slow"), a.file_enable_multi_upload = t;
    else if ("element_file_max_selection" == e) a.file_max_selection = parseInt(t);
    else if ("element_file_enable_size_limit" == e) 1 == t ? $("#form_file_limit_size").slideDown() : $("#form_file_limit_size").fadeOut("slow"), a.file_enable_size_limit = t;
    else if ("element_file_size_max" == e) a.file_size_max = parseInt(t);
    else if ("element_file_enable_advance" == e) 1 == t ? $("#prop_file_advance_options").slideDown() : $("#prop_file_advance_options").fadeOut("slow"), a.file_enable_advance = t;
    else if ("element_number_enable_quantity" == e) 1 == t ? (rebuild_quantity_link_dropdown(), $("#prop_number_quantity_link_div").slideDown()) : $("#prop_number_quantity_link_div").fadeOut("slow"), a.number_enable_quantity = t;
    else if ("element_number_quantity_link" == e) a.number_quantity_link = t;
    else if ("element_choice_columns" == e) {
        var m = "";
        1 == t ? m = "" : 2 == t ? m = "two_columns" : 3 == t ? m = "three_columns" : 9 == t && (m = "inline_columns"), $("#" + active_element).removeClass("two_columns three_columns inline_columns").addClass(m), a.choice_columns = t
    } else if ("element_range_min" == e) {
        var u = parseInt(t);
        isNaN(u) ? a.range_min = 0 : a.range_min = u, parseInt(a.range_min) + parseInt(a.range_max) >= 1 ? ($("#prop_range legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_range fieldset").css("border-color", "#DC6666")) : ($("#prop_range legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_range fieldset").css("border-color", "#3D6C10")), $("#" + active_element + " div > label").remove();
        var f = "";
        "c" == a.range_limit_by ? f = "characters" : "w" == a.range_limit_by ? f = "words" : "d" == a.range_limit_by && (f = "digits"), "c" == a.range_limit_by || "w" == a.range_limit_by || "d" == a.range_limit_by ? a.range_min > 0 && a.range_max > 0 && a.range_min == a.range_max ? $("#element_" + o).after('<label for="element_' + o + '">Must be <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Maximum of <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var> allowed.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Minimum of <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var> required.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : "v" == a.range_limit_by && (a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number less than or equal to <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Must be a number greater than or equal to <var id="range_min_' + o + '">' + a.range_min + "</var>.</label>"))
    } else if ("element_range_max" == e) {
        var h = parseInt(t);
        isNaN(h) ? a.range_max = 0 : a.range_max = h, parseInt(a.range_min) + parseInt(a.range_max) >= 1 ? ($("#prop_range legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_range fieldset").css("border-color", "#DC6666")) : ($("#prop_range legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_range fieldset").css("border-color", "#3D6C10")), $("#" + active_element + " div > label").remove(), f = "", "c" == a.range_limit_by ? f = "characters" : "w" == a.range_limit_by ? f = "words" : "d" == a.range_limit_by && (f = "digits"), "c" == a.range_limit_by || "w" == a.range_limit_by || "d" == a.range_limit_by ? a.range_min > 0 && a.range_max > 0 && a.range_min == a.range_max ? $("#element_" + o).after('<label for="element_' + o + '">Must be <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Maximum of <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var> allowed.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Minimum of <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var> required.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : "v" == a.range_limit_by && (a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number less than or equal to <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Must be a number greater than or equal to <var id="range_min_' + o + '">' + a.range_min + "</var>.</label>"))
    } else if ("element_range_limit_by" == e) "c" == t ? $("#" + active_element + " var.range_limit_by").text("characters") : "w" == t && $("#" + active_element + " var.range_limit_by").text("words"), "number" == a.type && ($("#" + active_element + " div > label").remove(), "d" == t ? (f = "digits", a.range_min > 0 && a.range_max > 0 && a.range_min == a.range_max ? $("#element_" + o).after('<label for="element_' + o + '">Must be <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var>.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Maximum of <var id="range_max_' + o + '">' + a.range_max + '</var> <var class="range_limit_by">' + f + '</var> allowed.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Minimum of <var id="range_min_' + o + '">' + a.range_min + '</var> <var class="range_limit_by">' + f + '</var> required.&nbsp;&nbsp; <em class="currently_entered">Currently Entered: <var id="currently_entered_' + o + '">0</var> <var class="range_limit_by">' + f + "</var>.</em></label>")) : "v" == t && (a.range_min > 0 && a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number between <var id="range_min_' + o + '">' + a.range_min + '</var> and <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_max > 0 ? $("#element_" + o).after('<label for="element_' + o + '">Must be a number less than or equal to <var id="range_max_' + o + '">' + a.range_max + "</var>.</label>") : a.range_min > 0 && $("#element_" + o).after('<label for="element_' + o + '">Must be a number greater than or equal to <var id="range_min_' + o + '">' + a.range_min + "</var>.</label>"))), a.range_limit_by = t;
    else if ("element_size" == e) a.size = t, "section" == i.data("field_properties").type ? $("#" + active_element).removeClass("section_scroll_small section_scroll_medium section_scroll_large").addClass("section_scroll_" + t) : "signature" == i.data("field_properties").type ? $("#" + active_element + " .signature_pad").removeClass("small medium large").addClass(t) : $("#" + active_element + " :input").removeClass("small medium large").addClass(t);
    else if ("element_type_change" == e) {
        var g = a.position,
            b = i.html(),
            y = $("#form_header").data("form_properties").id,
            x = $("#authTokenTrackActivity").val();
        v = $("#" + active_element).data("field_properties"), 0 == i.data("field_properties").is_db_live && (i.html('<img src="images/loader_small.gif" style="vertical-align: middle"/> changing field type ...').addClass("delete_processing"), $.ajax({
            type: "POST",
            async: !0,
            url: "delete_draft_field.php",
            data: {
                form_id: y,
                element_id: i.data("field_properties").id,
                element_type: i.data("field_properties").type
            },
            cache: !1,
            headers: {
                "Authentication-Token": x
            },
            global: !0,
            dataType: "json",
            error: function(e, t, a) {
                i.html(b).removeClass("delete_processing")
            },
            success: function(e) {
                "ok" == e.status ? (v.type = t, $.ajax({
                    type: "POST",
                    async: !0,
                    url: "http://192.168.1.193:8124/add_field",
                    data: {
                        element_type: t,
                        form_id: y,
                        holder_id: "li_" + a.id,
                        position: g,
                        action: "duplicate",
                        field_properties: v
                    },
                    headers: {
                        "Authentication-Token": x
                    },
                    cache: !1,
                    global: !0,
                    dataType: "json",
                    error: function(e, t, a) {
                        i.html(b).removeClass("delete_processing"), $("#dialog-message").dialog("open")
                    },
                    success: function(e) {
                        if ("ok" == e.status) {
                            var a = $(e.markup);
                            a.data("field_properties", i.data("field_properties")), a.data("field_properties").id = e.element_id, a.data("field_properties").type = t, $("#" + e.holder_id).replaceWith(a), $("#li_" + e.element_id).hide().fadeIn(), reorganize_page_break(), $("#form_builder_sortable").sortable("refreshPositions"), select_element("#li_" + e.element_id)
                        } else $("#dialog-message").dialog("open"), $("#form_builder_sortable .click_processing").remove()
                    }
                })) : (i.html(b).removeClass("delete_processing"), $("#dialog-message").dialog("open"))
            }
        }))
    } else if ("element_default_value" == e) {
        if (a.default_value = t, "address" == a.type) $("#element_" + a.id + "_6").val(t);
        else if ("date" == a.type || "europe_date" == a.type || "time" == a.type);
        else if ("phone" == a.type) $("#element_" + a.id + "_1").val($("#element_default_phone1").val()), $("#element_" + a.id + "_2").val($("#element_default_phone2").val()), $("#element_" + a.id + "_3").val($("#element_default_phone3").val());
        else if ("money" == a.type) {
            if ("yen" == a.constraint) $("#" + active_element + " :input").val(t);
            else {
                var _ = t.split(".");
                $("#" + active_element + " :input").eq(0).val(_[0]), $("#" + active_element + " :input").eq(1).val(_[1])
            }
        } else "email" == a.type ? $("#" + active_element + " :input:not(.confirm_email_input)").val(t) : $("#" + active_element + " :input").val(t)
    } else if ("element_choice_other_label" == e) a.choice_other_label = t, $("#" + active_element + " label.other").html(t);
    else if ("element_choice_has_other" == e) {
        if (a.choice_has_other = t, 1 == t) {
            var k = "";
            k += '<input id="element_' + a.id + '_0" name="element_' + a.id + '" class="element radio" type="' + a.type + '" value="0" />', k += '<label class="choice other" for="element_' + a.id + '_0">' + a.choice_other_label + "</label>", k = "<span>" + (k += '<input type="text" value="" class="element text other" name="element_' + a.id + '_other" id="element_' + a.id + '_other" />') + "</span>", $("#" + active_element + "  div").append(k), $("#" + active_element + "  div span").last().hide().slideDown(), $("#prop_other_choices_label").prop("disabled", !1).select().focus()
        } else $("#" + active_element + " div span").last().slideUp("slow", function() {
            $(this).remove()
        }), $("#prop_other_choices_label").prop("disabled", !0)
    } else if ("element_choice_limit_rule" == e) a.choice_limit_rule = t, $("#prop_choice_limit_range_span,#prop_choice_limit_qty_span").hide(), "between" == t ? $("#prop_choice_limit_range_span").show() : $("#prop_choice_limit_qty_span").show();
    else if ("element_choice_limit_qty" == e) a.choice_limit_qty = t;
    else if ("element_choice_limit_range_min" == e) a.choice_limit_range_min = t;
    else if ("element_choice_limit_range_max" == e) a.choice_limit_range_max = t;
    else if ("element_choice_max_entry" == e) a.choice_max_entry = t;
    else if ("element_text_default_length" == e) a.text_default_length = t, rebuild_default_text_random_preview();
    else if ("element_text_default_prefix" == e) a.text_default_prefix = t, rebuild_default_text_random_preview();
    else if ("element_text_default_random_type" == e) a.text_default_random_type = t, rebuild_default_text_random_preview();
    else if ("element_text_default_case" == e) a.text_default_case = t, rebuild_default_text_random_preview();
    else if ("constraint" == e) {
        if ("money" == a.type) {
            var w = "",
                C = "",
                D = "";
            "dollar" == t || "" == t ? (w = "&#36;", C = "Dollars", D = "Cents") : "euro" == t ? (w = "&#8364;", C = "Euros", D = "Cents") : "pound" == t ? (w = "&#163;", C = "Pounds", D = "Pence") : "baht" == t ? (w = "&#3647;", C = "Baht", D = "Satang") : "rupees" == t ? (w = "Rs", C = "Rupees", D = "Paise") : "rand" == t ? (w = "R", C = "Rand", D = "Cents") : "reais" == t ? (w = "R&#36;", C = "Reais", D = "Centavos") : "forint" == t ? (w = "&#70;&#116;", C = "Forint", D = "Filler") : "franc" == t ? (w = "CHF", C = "Francs", D = "Rappen") : "koruna" == t ? (w = "&#75;&#269;", C = "Koruna", D = "Hal\xe9řů") : "krona" == t ? (w = "kr", C = "Kroner", D = "\xd8re") : "pesos" == t ? (w = "&#36;", C = "Pesos", D = "Cents") : "ringgit" == t ? (w = "RM", C = "Ringgit", D = "Sen") : "zloty" == t ? (w = "&#122;&#322;", C = "Złoty", D = "Grosz") : "riyals" == t ? (w = "&#65020;", C = "Riyals", D = "Halalah") : "yen" == t && (w = "&#165;", C = "Yen"), $("#" + active_element + " > span.symbol").html(w), "yen" == t && "yen" != a.constraint ? ($("#" + active_element + " > span").last().remove(), $("#" + active_element + " > span").last().contents().filter(function() {
                return 3 == this.nodeType
            }).remove(), $("#element_" + a.id + "_1").attr("size", 15), $("#" + active_element + " > span label").first().text(C)) : "yen" != t && "yen" == a.constraint ? ($("#element_" + a.id + "_1").attr("size", 10), $("#" + active_element + " > span").first().next().children().first().after(" . "), $("#" + active_element).append('<span><input type="text" size="2" class="text" readonly="readonly"><label>' + D + "</label></span>"), $("#" + active_element + " > span label").first().text(C)) : "yen" != t && "yen" != a.constraint && $("#" + active_element + " > span label").first().text(C).end().last().text(D)
        } else if ("text" == a.type) {
            var q = '<input type="' + ("password" == t ? "password" : "text") + '" title="" value="' + $("#element_" + a.id).val() + '" class="element text ' + a.size + '" name="element_' + a.id + '" id="element_' + a.id + '">';
            $("#element_" + a.id).remove(), $("#" + active_element + " > div").append(q)
        }
        a.constraint = t
    } else if ("element_type" == e) {
        if (1 != a.is_db_live && ("simple_name" == t || "name" == t || "simple_name_wmiddle" == t || "name_wmiddle" == t)) {
            $("#" + active_element + " > fieldset > span:not(.description)").remove();
            var T = "",
                z = "",
                S = "",
                O = "",
                P = "";
            "simple_name" == t ? (z = '<span><input value="" size="8" maxlength="255" class="element text" name="element_' + a.id + '_1" id="element_' + a.id + '_1"><label>First</label></span>', O = '<span><input value="" size="14" maxlength="255" class="element text" name="element_' + a.id + '_2" id="element_' + a.id + '_2"><label>Last</label></span>', $("#" + active_element + " > fieldset > span.description").after(z + O)) : "name" == t ? (T = '<span><input value="" size="2" maxlength="255" class="element text" name="element_' + a.id + '_1" id="element_' + a.id + '_1"><label>Title</label></span>', z = '<span><input value="" size="8" maxlength="255" class="element text" name="element_' + a.id + '_2" id="element_' + a.id + '_2"><label>First</label></span>', O = '<span><input value="" size="14" maxlength="255" class="element text" name="element_' + a.id + '_3" id="element_' + a.id + '_3"><label>Last</label></span>', P = '<span><input value="" size="3" maxlength="255" class="element text" name="element_' + a.id + '_4" id="element_' + a.id + '_4"><label>Suffix</label></span>', $("#" + active_element + " > fieldset > span.description").after(T + z + O + P)) : "simple_name_wmiddle" == t ? (z = '<span><input value="" size="8" maxlength="255" class="element text" name="element_' + a.id + '_1" id="element_' + a.id + '_1"><label>First</label></span>', S = '<span><input value="" size="8" maxlength="255" class="element text" name="element_' + a.id + '_2" id="element_' + a.id + '_2"><label>Middle</label></span>', O = '<span><input value="" size="14" maxlength="255" class="element text" name="element_' + a.id + '_3" id="element_' + a.id + '_3"><label>Last</label></span>', $("#" + active_element + " > fieldset > span.description").after(z + S + O)) : "name_wmiddle" == t && (T = '<span class="namewm_ext"><input value="" maxlength="255" class="element text large" name="element_' + a.id + '_1" id="element_' + a.id + '_1"><label>Title</label></span>', z = '<span class="namewm_first"><input value="" maxlength="255" class="element text large" name="element_' + a.id + '_2" id="element_' + a.id + '_2"><label>First</label></span>', S = '<span class="namewm_middle"><input value="" maxlength="255" class="element text large" name="element_' + a.id + '_3" id="element_' + a.id + '_3"><label>Middle</label></span>', O = '<span class="namewm_last"><input value="" maxlength="255" class="element text large" name="element_' + a.id + '_4" id="element_' + a.id + '_4"><label>Last</label></span>', P = '<span class="namewm_ext"><input value="" maxlength="255" class="element text large" name="element_' + a.id + '_5" id="element_' + a.id + '_5"><label>Suffix</label></span>', $("#" + active_element + " > fieldset > span.description").after(T + z + S + O + P))
        }
        if ("date" == t ? ($("#" + active_element + " > fieldset > span > label").eq(0).text("MM").end().eq(1).text("DD"), $("#element_" + a.id + "_1").val(""), $("#element_" + a.id + "_2").val(""), $("#element_" + a.id + "_3").val(""), $("#element_default_date").val(""), a.default_value = "") : "europe_date" == t && ($("#" + active_element + " > fieldset > span > label").eq(0).text("DD").end().eq(1).text("MM"), $("#element_" + a.id + "_1").val(""), $("#element_" + a.id + "_2").val(""), $("#element_" + a.id + "_3").val(""), $("#element_default_date").val(""), a.default_value = ""), "simple_phone" == t) {
            $("#" + active_element + " > fieldset").remove();
            var j = '<label class="description" for="element_' + a.id + '">' + a.title.replace(/\n/g, "<br />") + '</label><div><input id="element_' + a.id + '" name="element_' + a.id + '" class="element text medium" type="text" maxlength="255" value=""/></div>';
            $("#" + active_element).append(j), $("#element_default_value").val(""), a.default_value = "", $("#prop_default_phone").hide(), $("#prop_default_value").show()
        } else if ("phone" == t) {
            var M = "element_" + a.id + "_1",
                A = "element_" + a.id + "_2",
                E = "element_" + a.id + "_3",
                U = '<fieldset><span class="description">' + a.title.replace(/\n/g, "<br />") + '</span><span><input id="' + M + '" name="' + M + '" class="element text" size="3" maxlength="3" value="" type="text" /> -<label for="' + M + '">###</label></span><span><input id="' + A + '" name="' + A + '" class="element text" size="3" maxlength="3" value="" type="text" /> -<label for="' + A + '">###</label></span><span><input id="' + E + '" name="' + E + '" class="element text" size="4" maxlength="4" value="" type="text" /><label for="' + E + '">####</label></span></fieldset>';
            $("#" + active_element + " > div").remove(), $("#" + active_element + " > label").remove(), $("#" + active_element).append(U), a.default_value = "", $("#element_default_phone1").val(""), $("#element_default_phone2").val(""), $("#element_default_phone3").val(""), $("#prop_default_value").hide(), $("#prop_default_phone").show()
        }
        a.type = t
    } else if ("element_time_showsecond" == e) 1 == t ? $("#" + active_element + " > fieldset > span:not('.description')").first().next().replaceWith('<span><input type="text" size="2" class="text" readonly="readonly"> : <label>MM</label></span><span><input type="text" size="2" class="text" readonly="readonly"><label>SS</label></span>') : $("#" + active_element + " > fieldset > span:not('.description')").first().next().next().remove().end().prev().next().replaceWith('<span><input type="text" size="2" class="text" readonly="readonly"><label>MM</label></span>'), a.time_showsecond = t;
    else if ("element_time_24hour" == e) {
        if (1 == t) $("#" + active_element + " > fieldset > span").last().remove();
        else {
            var I = '<span><select name="element_' + a.id + '_4" id="element_' + a.id + '_4" style="width: 4em;" class="element select"><option value="AM">AM</option><option value="PM">PM</option></select><label>AM/PM</label></span>';
            $("#" + active_element + " > fieldset").append(I)
        }
        a.time_24hour = t
    } else if ("submit_use_image" == e) $("#" + active_element + " input").removeClass("hide"), 1 == t ? ($("#" + active_element + " input.btn_submit").addClass("hide"), "" == a.submit_primary_img || null == a.submit_primary_img ? $("#submit_primary_img").val("http://") : $("#submit_primary_img").val(a.submit_primary_img), "" == a.submit_secondary_img || null == a.submit_secondary_img ? $("#submit_secondary_img").val("http://") : $("#submit_secondary_img").val(a.submit_secondary_img), $("#" + active_element).hasClass("firstpage") ? ($("#lbl_submit_secondary_img").hide(), $("#submit_secondary_img").hide()) : ($("#lbl_submit_secondary_img").show(), $("#submit_secondary_img").show()), $("#div_submit_use_text").hide(), $("#div_submit_use_image").show()) : ($("#" + active_element + " input.img_submit").addClass("hide"), $("#submit_primary_text").val(a.submit_primary_text), $("#submit_secondary_text").val(a.submit_secondary_text), $("#" + active_element).hasClass("firstpage") ? ($("#lbl_submit_secondary_text").hide(), $("#submit_secondary_text").hide()) : ($("#lbl_submit_secondary_text").show(), $("#submit_secondary_text").show()), $("#div_submit_use_image").hide(), $("#div_submit_use_text").show()), a.submit_use_image = t;
    else if ("submit_primary_text" == e) $("#btn_submit_" + a.id).val(t), a.submit_primary_text = t;
    else if ("submit_secondary_text" == e) $("#btn_prev_" + a.id).val(t), a.submit_secondary_text = t;
    else if ("submit_primary_img" == e) $("#img_submit_" + a.id).attr("src", t), a.submit_primary_img = t;
    else if ("submit_secondary_img" == e) $("#img_prev_" + a.id).attr("src", t), a.submit_secondary_img = t;
    else if ("element_matrix_allow_multiselect" == e) {
        var F = "",
            N = "";
        1 == t ? (F = "checkbox", N = "radio") : (F = "radio", N = "checkbox");
        var H = "",
            W = "",
            R = "";
        $("#" + active_element + " table tbody").find("tr").each(function() {
            $(this).find("td input[type=" + N + "]").each(function() {
                H = $(this).attr("id"), W = $(this).attr("name"), R = $(this).val(), $(this).replaceWith($('<input type="' + F + '" id="' + H + '" name="' + W + '" value="' + R + '" />'))
            })
        }), a.matrix_allow_multiselect = t
    } else if ("element_address_hideline2" == e) 1 == t ? $("#" + active_element + "_span_2").slideUp() : $("#" + active_element + "_span_2").slideDown(), a.address_hideline2 = t;
    else if ("element_address_us_only" == e) {
        if (1 == t) {
            $("#element_" + a.id + "_6").val("United States").prop("disabled", !0), $("#element_countries").val("United States").prop("disabled", !0);
            var Y = '<select class="element select large" id="element_' + a.id + '_4" name="element_' + a.id + '_4"><option value="">Select a State</option><option value="Alabama" >Alabama</option><option value="Alaska" >Alaska</option><option value="Arizona" >Arizona</option><option value="Arkansas" >Arkansas</option><option value="California" >California</option><option value="Colorado" >Colorado</option><option value="Connecticut" >Connecticut</option><option value="Delaware" >Delaware</option><option value="Delaware" >District of Columbia</option><option value="Florida" >Florida</option><option value="Georgia" >Georgia</option><option value="Hawaii" >Hawaii</option><option value="Idaho" >Idaho</option><option value="Illinois" >Illinois</option><option value="Indiana" >Indiana</option><option value="Iowa" >Iowa</option><option value="Kansas" >Kansas</option><option value="Kentucky" >Kentucky</option><option value="Louisiana" >Louisiana</option><option value="Maine" >Maine</option><option value="Maryland" >Maryland</option><option value="Massachusetts" >Massachusetts</option><option value="Michigan" >Michigan</option><option value="Minnesota" >Minnesota</option><option value="Mississippi" >Mississippi</option><option value="Missouri" >Missouri</option><option value="Montana" >Montana</option><option value="Nebraska" >Nebraska</option><option value="Nevada" >Nevada</option><option value="New Hampshire" >New Hampshire</option><option value="New Jersey" >New Jersey</option><option value="New Mexico" >New Mexico</option><option value="New York" >New York</option><option value="North Carolina" >North Carolina</option><option value="North Dakota" >North Dakota</option><option value="Ohio" >Ohio</option><option value="Oklahoma" >Oklahoma</option><option value="Oregon" >Oregon</option><option value="Pennsylvania" >Pennsylvania</option><option value="Rhode Island" >Rhode Island</option><option value="South Carolina" >South Carolina</option><option value="South Dakota" >South Dakota</option><option value="Tennessee" >Tennessee</option><option value="Texas" >Texas</option><option value="Utah" >Utah</option><option value="Vermont" >Vermont</option><option value="Virginia" >Virginia</option><option value="Washington" >Washington</option><option value="West Virginia" >West Virginia</option><option value="Wisconsin" >Wisconsin</option><option value="Wyoming" >Wyoming</option></select>';
            $("#element_" + a.id + "_4").replaceWith(Y)
        } else {
            $("#element_" + a.id + "_6").val("United States").prop("disabled", !1), $("#element_countries").val("United States").prop("disabled", !1);
            var V = '<input type="text" value="" class="element text large" name="element_' + a.id + '_4" id="element_' + a.id + '_4">';
            $("#element_" + a.id + "_4").replaceWith(V)
        }
        a.address_us_only = t, a.default_value = "United States"
    }
}

function add_element(e) {
    var t = $("#form_header").data("form_properties").id;
    $("#li_dummy").length && ($("#li_dummy").remove(), $("#no_fields_notice").remove());
    var i = $("#form_builder_sortable > li").not(".li_pagination").size() + 1,
        a = i,
        l = $("#authTokenTrackActivity").length && "" != $("#authTokenTrackActivity").val() ? $("#authTokenTrackActivity").val() : "";
    0 == $("#li_lastpage").length ? 
        $('<li id="li_temp_' + a + '" class="click_processing"><img src="images/loader_small.gif" style="vertical-align: middle"/> creating field ...</li>').appendTo("#form_builder_sortable").hide().fadeIn() : 
        $('<li id="li_temp_' + a + '" class="click_processing"><img src="images/loader_small.gif" style="vertical-align: middle"/> creating field ...</li>').insertBefore("#li_lastpage").hide().fadeIn();
    
    $.ajax({
        type: "POST",
        async: true,
        url: "http://192.168.1.193:8124/add_field",
        data: {
            element_type: e,
            form_id: t,
            holder_id: "li_temp_" + a,
            position: i,
            action: "click_new"
        },
        headers: {
            "Authentication-Token": l
        },
        cache: false,
        global: true,
        dataType: "json",
        error: function(e, t, i) {
            console.error("AJAX Error:", t, i); // Log the error
            $("#form_builder_sortable .click_processing").remove();
        },
        success: function(e) {
            console.log("AJAX Success:", e); // Log the success
            if ("ok" == e.status) {
                var t = $(e.markup);
                t.data("field_properties", e.field_properties).addClass("synched");
                $("#" + e.holder_id).replaceWith(t);
                $("#li_" + e.element_id).hide().fadeIn();
                reorganize_page_break();
                $("#form_builder_sortable").sortable("refreshPositions");
            } else {
                $("#dialog-message").dialog("open");
                $("#form_builder_sortable .click_processing").remove();
            }
        }
    });
}

function add_matrix_row(e) {
    var t = $("#form_header").data("form_properties").id,
        i = $("#" + active_element),
        a = $("#form_builder_sortable > li").not(".li_pagination").size() + 1 + $("#form_builder_sortable li.matrix table tr").length,
        l = (e.attr("id").split("_")[1], $("#" + active_element + " table th").length),
        o = $("#element_matrix_row li").index(e.parent()) + 1;
    $("#" + active_element + " table tr:eq(" + o + ")").after('<tr id="mr_temp_' + a + '" class="matrix_row_processing"><td colspan="' + l + '"><img src="images/loader_small.gif" style="vertical-align: middle"/> creating new row ...</td></tr>'), e.parent().after('<li id="li_mr_temp_' + a + '" class="li_mr_temp_holder"><input type="text" disabled="disabled" value="creating new row ..." autocomplete="off" class="text" id="matrixrow_' + a + '" /> <a href="#" class="add_choice" title="Add" id="matrixrowadd_' + a + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Remove Permanently" id="matrixrowdel_' + a + '"><span class="icon-remove"></span></a></li>'), $.ajax({
        type: "POST",
        async: !0,
        url: "add_matrix_row.php",
        data: {
            form_id: t,
            row_holder_id: "mr_temp_" + a,
            prop_holder_id: "li_mr_temp_" + a,
            allow_multiselect: i.data("field_properties").matrix_allow_multiselect,
            matrix_parent_id: i.data("field_properties").id,
            position: o + 1,
            column_data: i.data("field_properties").options[i.data("field_properties").id].column_data,
            total_column: l - 1
        },
        cache: !1,
        global: !0,
        dataType: "json",
        error: function(e, t, i) {
            $("#mr_temp_" + a).remove(), $("#li_mr_temp_" + a).remove()
        },
        success: function(e) {
            if ("ok" == e.status) {
                var t = e.element_id,
                    l = i.data("field_properties").options;
                l[t] = e.new_row_data, i.data("field_properties").options = l, $("#" + e.row_holder_id).replaceWith(e.new_row_markup), $("#" + e.prop_holder_id).replaceWith(e.new_prop_markup), $("#matrixrow_" + t).focus();
                var o = $("#matrixrow_" + t).parent().nextAll().children().filter("input.text");
                $.each(o, function(e, t) {
                    var a;
                    a = $(t).attr("id").split("_"), i.data("field_properties").options[a[1]].position++
                })
            } else $("#dialog-message").dialog("open"), $("#mr_temp_" + a).remove(), $("#li_mr_temp_" + a).remove()
        }
    })
}

function delete_matrix_row(e) {
    var t = e.attr("id").split("_")[1],
        i = ($("#" + active_element), $("#form_header").data("form_properties").id);
    if (1 >= $("#element_matrix_row > li").size()) return $("#ui-dialog-title-dialog-warning").html("Unable to delete this row!"), $("#dialog-warning-msg").html("You cannot delete all rows! <br />At least 1 row is required."), $("#dialog-warning").dialog("open"), !1;
    var a = $("#" + active_element + " table th").length,
        l = $("#mr_" + t).html();
    $("#mr_" + t).addClass("matrix_row_processing").html('<td colspan="' + a + '"><img src="images/loader_small.gif" style="vertical-align: middle"/> deleting row ...</td>'), $("#matrixrow_" + t).prop("disabled", !0), $("#matrixrowadd_" + t).fadeOut("fast"), $("#matrixrowdel_" + t).fadeOut("fast"), $.ajax({
        type: "POST",
        async: !0,
        url: "delete_matrix_row.php",
        data: {
            form_id: i,
            element_id: t
        },
        cache: !1,
        global: !0,
        dataType: "json",
        error: function(e, i, a) {
            $("#mr_" + t).removeClass("matrix_row_processing").html(l), $("#matrixrow_" + t).prop("disabled", !1), $("#matrixrowadd_" + t).show(), $("#matrixrowdel_" + t).show()
        },
        success: function(e) {
            if ("ok" == e.status) {
                var t = e.element_id,
                    i = $("#" + active_element),
                    a = i.data("field_properties").options;
                delete a[t], i.data("field_properties").options = a;
                var o = $("#matrixrow_" + t).parent().nextAll().children().filter("input.text");
                $.each(o, function(e, t) {
                    var a;
                    a = $(t).attr("id").split("_"), i.data("field_properties").options[a[1]].position--
                }), $("#matrixrow_" + t).parent().fadeOut("normal", function() {
                    $(this).remove()
                }), $("#mr_" + t).fadeOut("normal", function() {
                    if ($(this).remove(), $("#" + active_element + " tbody tr:gt(0)").length > 0) {
                        var e = $("#" + active_element + " tbody tr:gt(0)"),
                            t = [];
                        e.each(function(e) {
                            var i;
                            i = $(this).attr("id").split("_"), t[e] = i[1]
                        });
                        var a = t.join(",");
                        i.data("field_properties").constraint = a
                    } else i.data("field_properties").constraint = ""
                })
            } else $("#dialog-message").dialog("open"), $("#mr_" + t).removeClass("matrix_row_processing").html(l), $("#matrixrow_" + t).prop("disabled", !1), $("#matrixrowadd_" + t).show(), $("#matrixrowdel_" + t).show()
        }
    })
}

function add_matrix_column(e) {
    var t = e.attr("id").split("_")[1],
        i = $("#" + active_element),
        a = i.data("field_properties").id,
        l = parseInt(i.data("field_properties").last_option_id) + 1;
    i.data("field_properties").last_option_id = l;
    var o, n = $("#mc_" + a + "_" + t).index();
    $("#mc_" + a + "_" + t).after('<th scope="col" id="mc_' + a + "_" + l + '" class="matrix_choice_header">&nbsp;</th>'), o = 1 == i.data("field_properties").matrix_allow_multiselect ? "checkbox" : "radio";
    var r = "";
    $("#" + active_element + " table tbody").find("tr").each(function() {
        r = $(this).attr("id").split("_")[1], $(this).find("td").eq(n).after('<td><input type="' + o + '" value="' + l + '" name="element_' + r + '" id="element_' + r + "_" + l + '"></td>')
    });
    var s = $("#" + active_element + " table th").length,
        d = 100 / s * 2,
        p = (100 - (d = Math.round(d))) / (s - 1);
    p = Math.round(p), $("#" + active_element + " table th:eq(0)").css("width", d + "%"), $("#" + active_element + " table th:gt(0)").css("width", p + "%"), e.parent().after('<li><input type="text" value="" autocomplete="off" class="text" id="matrixcol_' + l + '" /> <a href="#" class="add_choice" title="Add" id="matrixcoladd_' + l + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Remove Permanently" id="matrixcoldel_' + l + '"><span class="icon-remove"></span></a></li>'), $("#matrixcol_" + l).focus();
    var c = i.data("field_properties").options[a].column_data;
    c[l] = {
        column_title: "",
        is_db_live: 0,
        position: n + 1
    }, i.data("field_properties").options[a].column_data = c;
    var m = $("#matrixcol_" + l).parent().nextAll().children().filter("input.text");
    $.each(m, function(e, t) {
        var l;
        l = $(t).attr("id").split("_"), i.data("field_properties").options[a].column_data[l[1]].position++
    })
}

function delete_matrix_column(e) {
    var t = e.attr("id").split("_")[1],
        i = $("#" + active_element),
        a = i.data("field_properties").id;
    if (1 >= $("#element_matrix_column > li").size()) return $("#ui-dialog-title-dialog-warning").html("Unable to delete this column!"), $("#dialog-warning-msg").html("You cannot delete all columns! <br />At least 1 column is required."), $("#dialog-warning").dialog("open"), !1;
    var l = i.data("field_properties").options[a].column_data;
    delete l[t], i.data("field_properties").options[a].column_data = l;
    var o = $("#matrixcol_" + t).parent().nextAll().children().filter("input.text");
    $.each(o, function(e, t) {
        var l;
        l = $(t).attr("id").split("_"), i.data("field_properties").options[a].column_data[l[1]].position--
    }), $("#matrixcol_" + t).parent().remove();
    var n = $("#mc_" + a + "_" + t).index();
    $("#mc_" + a + "_" + t).remove(), $("#" + active_element + " table tbody").find("tr").each(function() {
        $(this).find("td").eq(n).remove()
    })
}

function set_form_properties(e, t) {
    var i = $("#form_header").data("form_properties");
    if ("form_title" == e) $("#form_header_title").html(t.replace(/\n/g, "<br />")), i.name = t;
    else if ("form_description" == e) $("#form_header_desc").html(t.replace(/\n/g, "<br />")), i.description = t;
    else if ("form_review_title" == e) i.review_title = t;
    else if ("form_review_description" == e) i.review_description = t;
    else if ("form_resume_subject" == e) i.resume_subject = t;
    else if ("form_resume_content" == e) i.resume_content = t;
    else if ("form_resume_from_name" == e) i.resume_from_name = t;
    else if ("form_resume_from_email_address" == e) i.resume_from_email_address = t;
    else if ("form_label_alignment" == e) $("#form_builder_sortable > li").not(".li_pagination").css("width", ""), $("#form_builder_preview").removeClass("top_label right_label left_label").addClass(t), i.label_alignment = t;
    else if ("form_language" == e) i.language = t;
    else if ("form_redirect_enable" == e) 1 == t ? ($("#form_success_message").hide(), $("#form_redirect_url").show().focus().select()) : ($("#form_success_message").show().focus().select(), $("#form_redirect_url").hide()), i.redirect_enable = t;
    else if ("form_review_use_image" == e) 1 == t ? ($("#div_review_use_image").show(), $("#div_review_use_text").hide()) : ($("#div_review_use_image").hide(), $("#div_review_use_text").show()), i.review_use_image = t;
    else if ("form_success_message" == e) i.success_message = t;
    else if ("form_redirect" == e) i.redirect = t;
    else if ("form_custom_script_url" == e) i.custom_script_url = t;
    else if ("form_review" == e) i.review = t, 1 == $("#li_lastpage").length && 1 == t ? "Submit" == $("#li_lastpage").data("field_properties").submit_primary_text && ($("#li_lastpage").data("field_properties").submit_primary_text = "Continue", $("#btn_submit_lastpage").val("Continue")) : 1 == $("#li_lastpage").length && 0 == t && "Continue" == $("#li_lastpage").data("field_properties").submit_primary_text && ($("#li_lastpage").data("field_properties").submit_primary_text = "Submit", $("#btn_submit_lastpage").val("Submit")), 1 == t ? $("#form_prop_review").slideDown("slow", function() {
        adjust_main_height(), $("#form_prop_review").show()
    }) : $("#form_prop_review").slideUp("slow", function() {
        adjust_main_height()
    });
    else if ("review_primary_text" == e) i.review_primary_text = t;
    else if ("review_primary_img" == e) i.review_primary_img = t;
    else if ("review_secondary_text" == e) i.review_secondary_text = t;
    else if ("review_secondary_img" == e) i.review_secondary_img = t;
    else if ("form_resume_enable" == e) i.resume_enable = t, 1 == t ? $("#form_prop_resume").slideDown("slow", function() {
        adjust_main_height(), $("#form_prop_resume").show()
    }) : $("#form_prop_resume").slideUp("slow", function() {
        adjust_main_height()
    });
    else if ("form_password" == e) i.password = t;
    else if ("form_limit" == e) i.limit = parseInt(t);
    else if ("form_unique_ip_maxcount" == e) i.unique_ip_maxcount = parseInt(t);
    else if ("form_pagination_type" == e) {
        var a = $("#form_builder_sortable > li.page_break"),
            l = a.length,
            o = 1,
            n = "",
            r = "",
            s = "";
        if (a.each(function(e) {
                var i = $(this);
                if (o = e + 1, "li_lastpage" != i.attr("id")) {
                    var a = i.data("field_properties").id;
                    $("#pagenum_" + a).text(o), $("#pagetotal_" + a).text("Page " + o + " of " + l), 1 == o ? (r = " ap_tp_num_active", s = " ap_tp_text_active") : (r = "", s = ""), "steps" == t && (n += '<td align="center"><span id="page_num_' + o + '" class="ap_tp_num' + r + '">' + o + '</span><span id="page_title_' + o + '" class="ap_tp_text' + s + '">' + i.data("field_properties").page_title + '</span></td><td align="center" class="ap_tp_arrow">&gt;</td>')
                } else $("#pagenum_lastpage").text(o), $("#pagetotal_lastpage").text("Page " + o + " of " + l), n += '<td align="center"><span id="page_num_' + o + '" class="ap_tp_num">' + o + '</span><span id="page_title_' + o + '" class="ap_tp_text">' + i.data("field_properties").page_title + "</span></td>"
            }), $("#pagination_header").children().remove(), "steps" == t) {
            var d = '<table class="ap_table_pagination" width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' + n + "</tr></table>";
            $("#pagination_header").append(d)
        } else if ("percentage" == t) {
            $("#pagination_header").append('<h3 id="page_title_1">Page 1 of 1 - Page Title</h3><div class="mf_progress_container"><div id="mf_progress_percentage" class="mf_progress_value" style="width: 1%"><span>1%</span></div></div>'), $("#page_title_1").html("Page 1 of " + l + " - " + a.eq(0).data("field_properties").page_title);
            var p = Math.round(1 / l * 100);
            $("#mf_progress_percentage > span").html(p + "%"), $("#mf_progress_percentage").animate({
                width: p + "%"
            }, {
                duration: 200,
                queue: !1
            })
        } else $("#pagination_header").append('<h3 class="no_header">Pagination Header Disabled</h3>');
        "disabled" == t ? ($("#prop_pagination_style legend").css({
            "background-color": "#DC6666",
            "border-color": "#DC6666"
        }), $("#prop_pagination_style fieldset").css("border-color", "#DC6666"), $("#prop_pagination_titles").fadeOut("slow")) : ($("#prop_pagination_style legend").css({
            "background-color": "#3D6C10",
            "border-color": "#3D6C10"
        }), $("#prop_pagination_style fieldset").css("border-color", "#3D6C10"), "disabled" == i.pagination_type && $("#prop_pagination_titles").slideDown()), i.pagination_type = t
    }
}

function adjust_main_height() {
    var e = 75;
    $.browser.msie && (e = -10);
    var t = $("#sidebar").offset().top + $("#sidebar").outerHeight() - e,
        i = $("#header").outerHeight() + $("#navigation").outerHeight() + $("#content").outerHeight();
    t > i && $("#main").animate({
        "padding-bottom": t - i + "px"
    }, {
        duration: 200,
        queue: !0
    })
}

function update_date_range_min_linked(e) {
    $("#date_range_min_mm").val(e.length ? e[0].getMonth() + 1 : ""), $("#date_range_min_dd").val(e.length ? e[0].getDate() : ""), $("#date_range_min_yyyy").val(e.length ? e[0].getFullYear() : ""), set_properties("element_date_range_min", $("#date_range_min_yyyy").val() + "-" + $("#date_range_min_mm").val() + "-" + $("#date_range_min_dd").val())
}

function update_date_range_max_linked(e) {
    $("#date_range_max_mm").val(e.length ? e[0].getMonth() + 1 : ""), $("#date_range_max_dd").val(e.length ? e[0].getDate() : ""), $("#date_range_max_yyyy").val(e.length ? e[0].getFullYear() : ""), set_properties("element_date_range_max", $("#date_range_max_yyyy").val() + "-" + $("#date_range_max_mm").val() + "-" + $("#date_range_max_dd").val())
}

function update_scheduling_start_linked(e) {
    $("#scheduling_start_mm").val(e.length ? e[0].getMonth() + 1 : ""), $("#scheduling_start_dd").val(e.length ? e[0].getDate() : ""), $("#scheduling_start_yyyy").val(e.length ? e[0].getFullYear() : "");
    var t = $("#scheduling_start_yyyy").val() + "-" + $("#scheduling_start_mm").val() + "-" + $("#scheduling_start_dd").val();
    $("#form_header").data("form_properties").schedule_start_date = t
}

function update_scheduling_end_linked(e) {
    $("#scheduling_end_mm").val(e.length ? e[0].getMonth() + 1 : ""), $("#scheduling_end_dd").val(e.length ? e[0].getDate() : ""), $("#scheduling_end_yyyy").val(e.length ? e[0].getFullYear() : "");
    var t = $("#scheduling_end_yyyy").val() + "-" + $("#scheduling_end_mm").val() + "-" + $("#scheduling_end_dd").val();
    $("#form_header").data("form_properties").schedule_end_date = t
}

function reorganize_page_break() {
    var e = $("#form_builder_sortable > li.page_break"),
        t = $("#form_header").data("form_properties").pagination_type,
        i = '<li class="no_fields_in_page" title="Drag the button on the right side here to add new field."><span style="float: none;font-family: machform;margin-bottom: 20px;color: #529214;font-size: 50px;display: block" class="icon-arrow-right"></span><h3>This page has no fields!</h3><p><span style="color: #529214; font-weight: bold; float: none">Drag the button</span> on the right sidebar here to add new field.</p></li>';
    if (e.not("#li_lastpage").length >= 1) {
        if (1 == $("#li_lastpage").length && $("#li_lastpage").appendTo("#form_builder_sortable"), 1 == e.not("#li_lastpage").length) {
            if (0 == $("#pagination_header").length ? ($("#form_builder_sortable").prepend('<li id="pagination_header" style="display: none" class="li_pagination" title="Click to edit"><table class="ap_table_pagination" width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><span id="page_num_1" class="ap_tp_num ap_tp_num_active">1</span><span id="page_title_1" class="ap_tp_text ap_tp_text_active">Untitled Page</span></td><td align="center" class="ap_tp_arrow">&gt;</td><td align="center"><span id="page_num_2" class="ap_tp_num">2</span><span id="page_title_2" class="ap_tp_text">Untitled Page</span></td></tr></table></li>'), $("#pagination_header").fadeIn(), $("#pagination_header").click(function(e) {
                    $("#form_header").data("coming_from_click", 1), select_form_header($(this).attr("id"))
                })) : "steps" == t ? ($("#pagination_header td:gt(2)").remove(), $("#page_num_1").html("1"), $("#page_num_2").html("2"), $("#page_title_1").html($("#form_builder_sortable > li.page_break").not(".li_pagination").not("#li_lastpage").data("field_properties").page_title), $("#page_title_2").html($("#li_lastpage").data("field_properties").page_title)) : "percentage" == t && ($("#page_title_1").html("Page 1 of 2 - " + $("#form_builder_sortable > li.page_break").not(".li_pagination").not("#li_lastpage").data("field_properties").page_title), $("#mf_progress_percentage").animate({
                    width: "50%"
                }, {
                    duration: 200,
                    queue: !1
                }), $("#mf_progress_percentage > span").html("50%")), 0 == $("#li_lastpage").length) $('<li id="li_lastpage" class="page_break" title="Click to edit">' + e.html().replace(/_[0-9]+/g, "_lastpage") + "</li>").appendTo("#form_builder_sortable").addClass("synched"), $("#pagenum_lastpage").text("2"), $("#pagetotal_lastpage").text("Page 2 of 2"), $("#btn_submit_lastpage").val("Submit"), $("#li_lastpage").prev().hasClass("page_break") && $("#li_lastpage").before(i), $("#li_lastpage").data("field_properties", {
                id: "lastpage",
                type: "page_break",
                page_title: "Untitled Page",
                submit_primary_text: "Submit",
                submit_secondary_text: "Previous"
            });
            else {
                var a = 2;
                $("#form_builder_sortable > li.page_break").each(function(e) {
                    var t = e + 1;
                    if ("li_lastpage" != $(this).attr("id")) {
                        var i = $(this).data("field_properties").id;
                        $("#pagenum_" + i).text(t), $("#pagetotal_" + i).text("Page " + t + " of " + a)
                    } else $("#pagenum_lastpage").text(t), $("#pagetotal_lastpage").text("Page " + t + " of " + a)
                })
            }
            1 == e.index() && (0 == $("#form_builder_sortable > li").not(".li_pagination").not(".page_break").not(".li_lastpage").length ? (e.before(i), e.after(i)) : e.before(i))
        } else {
            a = e.length;
            var l = 1,
                o = "",
                n = "",
                r = "";
            if ("steps" == t && $("#pagination_header td").remove(), e.each(function(e) {
                    var s = $(this);
                    if (1 == s.index() && s.before(i), s.prev().hasClass("page_break") && s.before(i), s.next().hasClass("page_break") && s.after(i), l = e + 1, "li_lastpage" != s.attr("id")) {
                        var d = s.data("field_properties").id;
                        $("#pagenum_" + d).text(l), $("#pagetotal_" + d).text("Page " + l + " of " + a), 1 == l ? (n = " ap_tp_num_active", r = " ap_tp_text_active") : (n = "", r = ""), "steps" == t && (o += '<td align="center"><span id="page_num_' + l + '" class="ap_tp_num' + n + '">' + l + '</span><span id="page_title_' + l + '" class="ap_tp_text' + r + '">' + s.data("field_properties").page_title + '</span></td><td align="center" class="ap_tp_arrow">&gt;</td>')
                    } else $("#pagenum_lastpage").text(l), $("#pagetotal_lastpage").text("Page " + l + " of " + a), o += '<td align="center"><span id="page_num_' + l + '" class="ap_tp_num">' + l + '</span><span id="page_title_' + l + '" class="ap_tp_text">' + s.data("field_properties").page_title + "</span></td>"
                }), "steps" == t) $("#pagination_header tr").append(o);
            else if ("percentage" == t) {
                $("#page_title_1").html("Page 1 of " + a + " - " + e.eq(0).data("field_properties").page_title);
                var s = Math.round(1 / a * 100);
                $("#mf_progress_percentage").animate({
                    width: s + "%"
                }, {
                    duration: 200,
                    queue: !1
                }), $("#mf_progress_percentage > span").html(s + "%")
            }
        }
        $("#form_builder_sortable > li.no_fields_in_page").each(function(e) {
            var t = $(this);
            1 == t.index() ? 0 == t.next().hasClass("page_break") && t.remove() : 0 != t.prev().hasClass("page_break") && 0 != t.next().hasClass("page_break") || t.remove()
        }), $("#form_builder_sortable > li.firstpage").removeClass("firstpage"), $("#form_builder_sortable > li.page_break:eq(0)").addClass("firstpage"), $("#form_resume").prop("disabled", !1)
    } else $("#pagination_header").remove(), $("#li_lastpage").remove(), $("#form_builder_sortable > li").not(".no_fields_in_page").length > 0 ? $("#form_builder_sortable > li.no_fields_in_page").remove() : ($("#form_builder_sortable > li.no_fields_in_page").remove(), $("#form_builder_sortable").append(i)), $("#form_header").data("form_properties").resume_enable = 0, $("#form_resume").prop("checked", !1), $("#form_resume").prop("disabled", !0)
}

function rebuild_quantity_link_dropdown() {
    var e = $("#form_builder_sortable > li.multiple_choice,#form_builder_sortable > li.dropdown,#form_builder_sortable > li.checkboxes,#form_builder_sortable > li.price"),
        t = 0,
        i = [],
        a = [];
    e.each(function(e) {
        var l, o;
        if (l = $(this).data("field_properties"), o = $("#pagination_header").length > 0 ? l.position : parseInt(l.position) + 1, "checkbox" == l.type) {
            var n = l.options;
            $.each(n, function(e, n) {
                i[t] = n.option + " (#" + o + ")", a[t] = "element_" + l.id + "_" + e, t++
            })
        } else i[t] = l.title + " (#" + o + ")", a[t] = "element_" + l.id, t++
    }), $("#prop_number_quantity_link > option").remove(), $("#prop_number_quantity_link").append('<option value="">-- Please Select --</option>'), $.each(i, function(e, t) {
        var i = '<option value="' + a[e] + '">' + t + "</option>";
        $("#prop_number_quantity_link").append(i)
    }), 0 == i.length && ($("#prop_number_quantity_link > option").remove(), $("#prop_number_quantity_link").append('<option value=""> -- No supported fields available --</option>'))
}

function random_string(e, t) {
    for (var i = "", a = e; a > 0; --a) i += t[Math.round(Math.random() * (t.length - 1))];
    return i
}

function rebuild_default_text_random_preview() {
    var e = $("#" + active_element).data("field_properties"),
        t = "",
        i = parseInt(e.text_default_length);
    if (0 == i && (i = 10), "letter" == e.text_default_random_type) switch (e.text_default_case) {
            case "u":
                t = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                break;
            case "l":
                t = "abcdefghijklmnopqrstuvwxyz";
                break;
            case "b":
                t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
        } else if ("number" == e.text_default_random_type) t = "0123456789";
        else if ("alphanum" == e.text_default_random_type) switch (e.text_default_case) {
        case "u":
            t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
        case "l":
            t = "0123456789abcdefghijklmnopqrstuvwxyz";
            break;
        case "b":
            t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    } else if ("all" == e.text_default_random_type) switch (e.text_default_case) {
        case "u":
            t = "\"'`~!@#$%^&*()_-+={}[]|\\:;<>,.?/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            break;
        case "l":
            t = "\"'`~!@#$%^&*()_-+={}[]|\\:;<>,.?/0123456789abcdefghijklmnopqrstuvwxyz";
            break;
        case "b":
            t = "\"'`~!@#$%^&*()_-+={}[]|\\:;<>,.?/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    }
    $("#" + active_element + " :input").val(e.text_default_prefix + random_string(i, t))
}
$("#prop_choices_other_checkbox").click(function() {
        var e = $("#maximum_field_count").val();
        if (field_count = $("#field_count_span").text()) var t = parseInt(field_count);
        else t = 0;
        if (1 == $(this).prop("checked")) {
            if (!(t < e)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
            $("#field_count_span").text(t + 1)
        } else 0 == $(this).prop("checked") && $("#field_count_span").text(t - 1)
    }),
    function() {
        var e;
        $("#prop_element_type select.select").on("focusin", function() {
            var t = $(this).val();
            switch (t) {
                case t = "text":
                case t = "textarea":
                case t = "number":
                case t = "date":
                case t = "time":
                case t = "phone":
                case t = "money":
                case t = "url":
                case t = "email":
                    e = 1;
                    break;
                case t = "address":
                    e = 6;
                    break;
                case t = "file":
                case t = "signature":
                    e = 1;
                    break;
                case t = "section":
                case t = "media":
                    e = 0;
                    break;
                case t = "simple_name":
                    var i = $("#name_format").val();
                    "name_type" == i ? e = 2 : "name" == i ? e = 4 : "simple_name_wmiddle" == i ? e = 3 : "name_wmiddle" == i && (e = 5);
                    break;
                case t = "radio":
                case t = "select":
                    e = 1;
                    break;
                case t = "matrix":
                    e = 0;
                    break;
                case t = "checkbox":
                    var a = $("ul#element_choices li").length;
                    if (1 == $("#prop_choices_other_checkbox").prop("checked")) var l = 1;
                    else 0 == $("#prop_choices_other_checkbox").prop("checked") && (l = 0);
                    e = a + l
            }
        }).change(function() {
            if (field_count_shown = $("#field_count_span").text()) var t = parseInt(field_count_shown);
            else t = 0;
            $("#field_count_span").text(t - e);
            var i = t - e,
                a = $(this).val();
            switch (a) {
                case a = "text":
                case a = "textarea":
                case a = "number":
                case a = "date":
                case a = "time":
                case a = "phone":
                case a = "money":
                case a = "url":
                case a = "email":
                    new_value = 1;
                    break;
                case a = "address":
                    new_value = 6;
                    break;
                case a = "file":
                case a = "signature":
                    new_value = 1;
                    break;
                case a = "section":
                case a = "media":
                    new_value = 0;
                    break;
                case a = "simple_name":
                    new_value = 2;
                    break;
                case a = "radio":
                case a = "select":
                    new_value = 1;
                    break;
                case a = "matrix":
                    new_value = 0;
                    break;
                case a = "checkbox":
                    var l = $("ul#element_choices li").length;
                    if (1 == $("#prop_choices_other_checkbox").prop("checked")) var o = 1;
                    else 0 == $("#prop_choices_other_checkbox").prop("checked") && (o = 0);
                    new_value = l + o
            }
            $("#field_count_span").text(i + new_value)
        })
    }(), $(function() {
        $("#tab_field_properties").show(), $("#tab_form_properties").show(), $("#builder_tabs_btn").show(), $("#builder_tabs").tabs(), $("#builder_tabs").bind("tabsshow", function(e, t) {
            0 === t.index ? ($("#" + active_element).removeClass("highlighted"), active_element = null, $("#form_header .highlighted").removeClass("highlighted"), $("#pagination_header").removeClass("highlighted"), $("#selected_field_image").css("visibility", "hidden"), $("#form_prop_toggle_a").text("show more options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_next.gif"), $("#all_form_properties .advanced_prop").hide(), $("#bottom_bar_field_action").fadeOut("fast", function() {
                $("#bottom_bar_content").animate({
                    "margin-left": "225px"
                }, {
                    duration: 200,
                    queue: !1
                })
            }), check_synch_fields()) : 1 === t.index ? ($("#form_header .highlighted").removeClass("highlighted"), $("#pagination_header").removeClass("highlighted"), $("#form_prop_toggle_a").text("show more options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_next.gif"), $("#all_form_properties .advanced_prop").hide(), null === active_element && ($("#element_properties_form").hide(), $("#element_inactive_msg").show())) : 2 === t.index && 1 != $("#form_header").data("coming_from_click") && select_form_header("form_header_title")
        }), $("#form_builder_sortable").sortable({
            items: "li:not(.li_pagination,#li_lastpage)",
            axis: "y",
            opacity: .7,
            placeholder: "ui-state-highlight",
            scrollSensitivity: 100,
            scrollSpeed: 40,
            receive: function(e, t) {
                var i = $("#form_header").data("form_properties").id;
                $("#li_dummy").length && ($("#li_dummy").remove(), $("#no_fields_notice").remove());
                var a, l = $("#form_builder_sortable > li").not(".li_pagination").size() + 1;
                switch ($(t.sender).attr("id")) {
                    case "btn_single_line_text":
                    default:
                        a = "text";
                        break;
                    case "btn_number":
                        a = "number";
                        break;
                    case "btn_paragraph_text":
                        a = "textarea";
                        break;
                    case "btn_checkboxes":
                        a = "checkbox";
                        break;
                    case "btn_multiple_choice":
                        a = "radio";
                        break;
                    case "btn_drop_down":
                        a = "select";
                        break;
                    case "btn_name":
                        a = "simple_name";
                        break;
                    case "btn_date":
                        a = "date";
                        break;
                    case "btn_time":
                        a = "time";
                        break;
                    case "btn_phone":
                        a = "phone";
                        break;
                    case "btn_address":
                        a = "address";
                        break;
                    case "btn_website":
                        a = "url";
                        break;
                    case "btn_price":
                        a = "money";
                        break;
                    case "btn_email":
                        a = "email";
                        break;
                    case "btn_section_break":
                        a = "section";
                        break;
                    case "btn_file_upload":
                        a = "file";
                        break;
                    case "btn_page_break":
                        a = "page_break";
                        break;
                    case "btn_matrix":
                        a = "matrix";
                        break;
                    case "btn_signature":
                        a = "signature";
                        break;
                    case "btn_media":
                        a = "media"
                }
                var o = $("#maximum_field_count").val();
                if (field_count = $("#field_count_span").text()) var n = parseInt(field_count);
                else n = 0;
                switch (is_allowed = !0, a) {
                    case a = "text":
                    case a = "number":
                    case a = "textarea":
                        n < o ? field_count ? $("#field_count_span").text(n + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                        break;
                    case a = "checkbox":
                        n + 3 <= o ? field_count ? $("#field_count_span").text(n + 3) : $("#field_count_span").text(3) : is_allowed = !1;
                        break;
                    case a = "radio":
                    case a = "select":
                        n < o ? field_count ? $("#field_count_span").text(n + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                        break;
                    case a = "simple_name":
                        n + 2 <= o ? field_count ? $("#field_count_span").text(n + 2) : $("#field_count_span").text(2) : is_allowed = !1;
                        break;
                    case a = "date":
                    case a = "time":
                        n < o ? field_count ? $("#field_count_span").text(n + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                        break;
                    case a = "address":
                        n + 6 <= o ? field_count ? $("#field_count_span").text(n + 6) : $("#field_count_span").text(6) : is_allowed = !1;
                        break;
                    case a = "url":
                    case a = "money":
                    case a = "email":
                        n < o ? field_count ? $("#field_count_span").text(n + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                        break;
                    case a = "matrix":
                        n + 4 <= o ? field_count ? $("#field_count_span").text(n + 4) : $("#field_count_span").text(4) : is_allowed = !1;
                        break;
                    case a = "file":
                    case a = "phone":
                    case a = "signature":
                        n < o ? field_count ? $("#field_count_span").text(n + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                        break;
                    case a = "section":
                    case a = "page_break":
                    case a = "media":
                        is_allowed = 1
                }
                if (!is_allowed) return $("#form_builder_sortable li.ui-ui-draggable").remove(), $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#form_builder_sortable .ui-draggable").attr("id", "li_temp_" + l).removeClass("box ui-draggable").addClass("drop_processing").html('<img src="images/loader_small.gif" style="vertical-align: middle"/> creating field ...').hide().fadeIn();
                var r = $("#li_temp_" + l).index() + 1,
                    s = $("#authTokenTrackActivity").length && "" != $("#authTokenTrackActivity").val() ? $("#authTokenTrackActivity").val() : "";
                $.ajax({
                    type: "POST",
                    async: !0,
                    url: "http://192.168.1.193:8124/add_field",
                    data: {
                        element_type: a,
                        form_id: i,
                        holder_id: "li_temp_" + l,
                        position: r,
                        action: "drag_new"
                    },
                    headers: {
                        "Authentication-Token": s
                    },
                    cache: !1,
                    global: !0,
                    dataType: "json",
                    error: function(e, t, i) {
                        $("#form_builder_sortable .drop_processing").remove()
                    },
                    success: function(e) {
                        debugger;
                        if ("ok" == e.status) {
                            var t = $(e.markup);
                            t.data("field_properties", e.field_properties).addClass("synched"), $("#" + e.holder_id).replaceWith(t), $("#li_" + e.element_id).hide().fadeIn(), reorganize_page_break(), $("#form_builder_sortable").sortable("refreshPositions")
                        } else $("#dialog-message").dialog("open"), $("#form_builder_sortable .drop_processing").remove()
                    }
                })
            },
            update: function(e, t, i) {
                $("#form_builder_preview li.ui-draggable").remove(), $(t.item).hasClass("no_fields_in_page") ? $(this).sortable("cancel") : (!1 === $(t.item).hasClass("drop_processing") && ($("#builder_tabs").tabs("select", 1), select_element("#" + $(t.item).attr("id"))), reorganize_page_break(), 1 == $(t.item).hasClass("firstpage") && select_element("#" + $(t.item).attr("id")))
            }
        }), $("#form_builder_sortable").disableSelection(), $(document).ready(function() {
            sidebar_scroll_pos = $("#sidebar").position().top, isScrolledIntoView("#bottom_bar_limit") ? $("#bottom_bar").css("position", "relative").css("background-color", "#fff") : $("#bottom_bar").css("position", "fixed").css("background-color", "#effab4"), $(window).scroll(function() {
                var e = (sidebar_pos = isScrolledIntoView("#navigation") ? sidebar_scroll_pos : sidebar_scroll_pos - 135) + $(document).scrollTop() + "px";
                0 === $("#builder_tabs").tabs("option", "selected") && $("#sidebar").animate({
                    top: e
                }, {
                    duration: 500,
                    queue: !1
                }), isScrolledIntoView("#bottom_bar_limit") ? $("#bottom_bar").css("position", "relative").css("background-color", "#fff") : $("#bottom_bar").css("position", "fixed").css("background-color", "#effab4")
            }), $("#prop_file_enable_advance").next().next().hide(), $("#prop_file_enable_advance").next().hide(), $("#prop_file_enable_advance").hide()
        }), $("#form_builder_preview").delegate("li:not(#pagination_header):not(.no_fields_in_page)", "click", function(e) {
            $("#builder_tabs").tabs("select", 1), select_element("#" + $(this).attr("id"))
        }), $("#form_header_title,#form_header_desc,#pagination_header").click(function(e) {
            $("#form_header").data("coming_from_click", 1), select_form_header($(this).attr("id"))
        }), $("#bottom_bar_add_field").click(function() {
            $("#builder_tabs").tabs("select", 0);
            var e = (sidebar_pos = isScrolledIntoView("#navigation") ? sidebar_scroll_pos : sidebar_scroll_pos - 100) + $(document).scrollTop() + "px";
            return $("#sidebar").animate({
                top: e
            }, {
                duration: 500,
                queue: !1
            }), $("#" + active_element).removeClass("highlighted"), active_element = null, $("#form_header .highlighted").removeClass("highlighted"), $("#selected_field_image").css("visibility", "hidden"), $("#bottom_bar_field_action").fadeOut("fast", function() {
                $("#bottom_bar_content").animate({
                    "margin-left": "225px"
                }, {
                    duration: 200,
                    queue: !1
                })
            }), !1
        }), $("#bottom_bar_save_form").click(function() {
            if ($("#form_builder_sortable > li.no_fields_in_page").length > 0) return $("#ui-dialog-title-dialog-warning").html("Unable to save. Your form contain empty pages!"), $("#dialog-warning-msg").html("Your form contain one or more empty pages<br />Please add a field into the empty page or delete the empty page."), $("#dialog-warning").dialog("open"), !1;
            $("#bottom_bar_msg").text("Please wait... Synching..."), $("#bottom_bar_content").fadeOut("fast", function() {
                $("#bottom_bar_loader").fadeIn()
            });
            var e = $("#form_header").data("form_properties").id,
                t = $("#form_builder_sortable > li").not(".dblive").not(".synched").not(".li_pagination").not("#li_lastpage");
            if (t.length >= 1) {
                var i = [];
                t.each(function(e) {
                    i[e] = $(this).data("field_properties")
                }), $.ajax({
                    type: "POST",
                    async: !0,
                    url: "http://192.168.1.193:8124/synch_fields",
                    data: {
                        form_id: e,
                        fp: i
                    },
                    cache: !1,
                    global: !1,
                    dataType: "json",
                    error: function(e, t, i) {},
                    success: function(e) {
                        "ok" == e.status && ($(e.updated_element_id).addClass("synched"), save_form())
                    }
                })
            } else save_form();
            return !1
        }), $("#field_properties_pane img[title].helpmsg,#form_properties_pane img[title].helpmsg").tooltip({
            position: "bottom center",
            offset: [10, 20],
            effect: "fade",
            opacity: .8,
            events: {
                def: "click,mouseout"
            }
        }), $("#element_label").bind("keyup mouseout", function() {
            set_properties("element_label", $(this).val())
        }), $("#element_required").bind("change", function() {
            set_properties("element_required", 1 == $(this).prop("checked") ? "1" : "0")
        }), $("#element_unique").bind("change", function() {
            set_properties("element_unique", 1 == $(this).prop("checked") ? "1" : "0")
        }), $("#element_readonly").bind("change", function() {
            set_properties("element_readonly", 1 == $(this).prop("checked") ? "1" : "0")
        }), $("#element_public").bind("click", function() {
            set_properties("element_visibility", 1 == $(this).prop("checked") ? "0" : "1")
        }), $("#element_hidden").bind("click", function() {
            set_properties("element_visibility", 1 == $(this).prop("checked") ? "2" : "0")
        }), $("#element_private").bind("click", function() {
            set_properties("element_visibility", 1 == $(this).prop("checked") ? "1" : "0")
        }), $("#element_media_image").bind("click", function() {
            1 == $(this).prop("checked") && set_properties("element_media_type", "image")
        }), $("#element_media_video").bind("click", function() {
            1 == $(this).prop("checked") && set_properties("element_media_type", "video")
        }), $("#element_default_value_text_static").bind("click", function() {
            1 == $(this).prop("checked") && set_properties("element_text_default_type", "static")
        }), $("#element_default_value_text_random").bind("click", function() {
            1 == $(this).prop("checked") && set_properties("element_text_default_type", "random")
        }), $("#element_text_default_length").bind("keyup mouseout", function() {
            set_properties("element_text_default_length", $(this).val())
        }), $("#element_text_default_prefix").bind("keyup mouseout", function() {
            set_properties("element_text_default_prefix", $(this).val())
        }), $("#element_text_default_random_type").bind("change", function() {
            set_properties("element_text_default_random_type", $(this).val())
        }), $("#element_text_default_case").bind("change", function() {
            set_properties("element_text_default_case", $(this).val())
        }), $("#element_instructions").bind("keyup mouseout", function() {
            set_properties("element_guidelines", $(this).val())
        }), $("#element_custom_css").bind("keyup mouseout", function() {
            set_properties("element_custom_css", $(this).val())
        }), $("#prop_confirmation_field_label").bind("keyup mouseout", function() {
            set_properties("element_email_confirm_field_label", $(this).val())
        }), $("#element_choices").delegate("input.text", "keyup", function(e) {
            var t = $(this),
                i = t.attr("id").split("_")[1],
                a = "&nbsp;",
                l = $("#" + active_element),
                o = l.data("field_properties").options[i].position,
                n = l.data("field_properties").id,
                r = l.data("field_properties").type;
            if (13 == e.keyCode) {
                var s = parseInt(l.data("field_properties").last_option_id) + 1,
                    d = "";
                "radio" == r || "select" == r ? d = "radio" : "checkbox" == r && (d = "checkbox");
                var p = '<li><input type="' + d + '" title="Select this choice as the default." class="choices_default" name="choices_default" id="choicedef_' + s + '" /><input type="text" value="" autocomplete="off" class="text" id="choice_' + s + '" /> <a href="#" class="add_choice" title="Add Choice" id="choiceadd_' + s + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Hide Choice" id="choicedel_' + s + '"><span class="icon-cancel-circle"></span></a></li>';
                t.parent().after(p), l.data("field_properties").last_option_id = s;
                var c = "";
                "radio" == r ? (c = '<span><input type="radio" value="1" class="element radio" name="element_' + n + '" id="element_' + n + "_" + s + '"><label for="element_' + n + "_" + s + '" class="choice">&nbsp;</label></span>', $("#element_" + n + "_" + i).parent().after(c)) : "checkbox" == r ? (c = '<span><input type="checkbox" value="1" class="element checkbox" name="element_' + n + '" id="element_' + n + "_" + s + '"><label for="element_' + n + "_" + s + '" class="choice">&nbsp;</label></span>', $("#element_" + n + "_" + i).parent().after(c)) : "select" == r && (c = '<option value="' + s + '">&nbsp;</option>', $("#element_" + n + " option[value=" + i + "]").after(c)), $("#choice_" + s).focus();
                var m = l.data("field_properties").options;
                m[s] = {
                    position: o + 1,
                    option: "",
                    is_default: 0,
                    is_hidden: 0,
                    is_db_live: "0"
                }, l.data("field_properties").options = m;
                var u = $("#element_choices input.text"),
                    f = 1;
                $.each(u, function(e, t) {
                    var i;
                    i = $(t).attr("id").split("_"), l.data("field_properties").options[i[1]].position = f, f++
                }), $.each(l.data("field_properties").options, function(e, t) {
                    "1" == l.data("field_properties").options[e].is_hidden && (l.data("field_properties").options[e].position = f, f++)
                })
            } else "" != t.val() && (a = t.val()), "select" == r ? $("#element_" + n + " option[value=" + i + "]").text(a) : $("#element_" + n + "_" + i).next().html(a), l.data("field_properties").options[i].option = t.val()
        }), $("#element_choices").delegate("input.choices_default", "click", function(e) {
            var t = $(this),
                i = t.attr("id").split("_")[1],
                a = active_element.split("_")[1],
                l = $("#" + active_element),
                o = l.data("field_properties").type;
            "radio" == o || "select" == o ? "0" == l.data("field_properties").options[i].is_default ? ("radio" == o ? $("#element_" + a + "_" + i).prop("checked", !0) : "select" == o && $("#element_" + a).val(i), $(l.data("field_properties").options).each(function(e, t) {
                $.each(t, function(e, t) {
                    l.data("field_properties").options[e].is_default = "0"
                })
            }), l.data("field_properties").options[i].is_default = "1") : ("radio" == o ? $("#element_" + a + "_" + i).prop("checked", !1) : "select" == o && (0 == $("#element_" + a).find('option[value=""]').length && $("#element_" + a).prepend('<option value=""></option>'), $("#element_" + a).val("")), $(l.data("field_properties").options).each(function(e, t) {
                $.each(t, function(e, t) {
                    l.data("field_properties").options[e].is_default = "0"
                })
            }), $(this).prop("checked", !1)) : "checkbox" == o && (1 == t.prop("checked") ? ($("#element_" + a + "_" + i).prop("checked", !0), l.data("field_properties").options[i].is_default = "1") : ($("#element_" + a + "_" + i).prop("checked", !1), l.data("field_properties").options[i].is_default = "0"))
        }), $("#element_choices").delegate("a.add_choice", "click", function(e) {
            var t = $(this),
                i = t.attr("id").split("_")[1],
                a = $("#" + active_element),
                l = a.data("field_properties").options[i].position,
                o = a.data("field_properties").id,
                n = a.data("field_properties").type,
                r = "";
            if ("checkbox" == n) {
                var s = $("#maximum_field_count").val(),
                    d = $("#field_count_span").text();
                if (d) var p = parseInt(d);
                else p = 0;
                if (!(p < s)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#field_count_span").text(p + 1)
            }
            "radio" == n || "select" == n ? r = "radio" : "checkbox" == n && (r = "checkbox");
            var c = parseInt(a.data("field_properties").last_option_id) + 1,
                m = '<li><input type="' + r + '" title="Select this choice as the default." class="choices_default" name="choices_default" id="choicedef_' + c + '" /><input type="text" value="" autocomplete="off" class="text" id="choice_' + c + '" /> <a href="#" class="add_choice" title="Add Choice" id="choiceadd_' + c + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Hide Choice" id="choicedel_' + c + '"><span class="icon-cancel-circle"></span></a></li>';
            t.parent().after(m), a.data("field_properties").last_option_id = c;
            var u = "";
            "radio" == n ? u = '<span><input type="radio" value="1" class="element radio" name="element_' + o + '" id="element_' + o + "_" + c + '"><label for="element_' + o + "_" + c + '" class="choice">&nbsp;</label></span>' : "checkbox" == n ? u = '<span><input type="checkbox" value="1" class="element checkbox" name="element_' + o + '" id="element_' + o + "_" + c + '"><label for="element_' + o + "_" + c + '" class="choice">&nbsp;</label></span>' : "select" == n && (u = '<option value="' + c + '">&nbsp;</option>', $("#element_" + o + " option[value=" + i + "]").after(u)), $("#element_" + o + "_" + i).parent().after(u), $("#choice_" + c).focus();
            var f = a.data("field_properties").options;
            f[c] = {
                position: l + 1,
                option: "",
                is_default: 0,
                is_hidden: 0,
                is_db_live: "0"
            }, a.data("field_properties").options = f;
            var h = $("#element_choices input.text"),
                g = 1;
            return $.each(h, function(e, t) {
                var i;
                i = $(t).attr("id").split("_"), a.data("field_properties").options[i[1]].position = g, g++
            }), $.each(a.data("field_properties").options, function(e, t) {
                "1" == a.data("field_properties").options[e].is_hidden && (a.data("field_properties").options[e].position = g, g++)
            }), !1
        }), $("#element_choices_hidden").delegate("a.unhide_choice", "click", function(e) {
            var t = $(this).attr("id").split("_")[1],
                i = $("#" + active_element),
                a = (i.data("field_properties").options[t].position, i.data("field_properties").id),
                l = i.data("field_properties").type,
                o = i.data("field_properties").options[t].option,
                n = "";
            "radio" == l || "select" == l ? n = "radio" : "checkbox" == l && (n = "checkbox");
            var r = $("#element_choices input.text").last().attr("id").split("_")[1],
                s = parseInt(t),
                d = '<li><input type="' + n + '" title="Select this choice as the default." class="choices_default" name="choices_default" id="choicedef_' + s + '" /><input type="text" value="' + o + '" autocomplete="off" class="text" id="choice_' + s + '" /> <a href="#" class="add_choice" title="Add Choice" id="choiceadd_' + s + '"><span class="icon-plus-circle"></span></a><a href="#" class="del_choice" title="Hide Choice" id="choicedel_' + s + '"><span class="icon-cancel-circle"></span></a></li>';
            $("#element_choices").append(d), i.data("field_properties").last_option_id = s;
            var p = "";
            "radio" == l ? p = '<span><input type="radio" value="1" class="element radio" name="element_' + a + '" id="element_' + a + "_" + s + '"><label for="element_' + a + "_" + s + '" class="choice">' + o + "</label></span>" : "checkbox" == l ? p = '<span><input type="checkbox" value="1" class="element checkbox" name="element_' + a + '" id="element_' + a + "_" + s + '"><label for="element_' + a + "_" + s + '" class="choice">' + o + "</label></span>" : "select" == l && (p = '<option value="' + s + '">' + o + "</option>", $("#element_" + a + " option[value=" + r + "]").after(p)), $("#element_" + a + "_" + r).parent().after(p), $("#choice_" + s).focus(), i.data("field_properties").options[s].is_hidden = 0;
            var c = $("#element_choices input.text"),
                m = 1;
            $.each(c, function(e, t) {
                var a;
                a = $(t).attr("id").split("_"), i.data("field_properties").options[a[1]].position = m, m++
            }), $.each(i.data("field_properties").options, function(e, t) {
                "1" == i.data("field_properties").options[e].is_hidden && (i.data("field_properties").options[e].position = m, m++)
            }), $("#choiceunhide_" + t).parent().remove();
            var u = parseInt($("#hidden_choices_counter").text()) - 1;
            return $("#hidden_choices_counter").text(u), u > 0 ? $("#toggle_hidden_choices").show() : ($("#toggle_hidden_choices").hide(), $("#element_choices_hidden").hide(), $("#toggle_hidden_choices").css("font-weight", "normal")), !1
        }), $("#element_choices").delegate("a.del_choice", "click", function(e) {
            if (1 >= $("#element_choices > li").size()) return $("#ui-dialog-title-dialog-warning").html("Unable to delete this choice!"), $("#dialog-warning-msg").html("You cannot delete all choices! <br />At least 1 choice is required."), $("#dialog-warning").dialog("open"), !1;
            var t = $(this).attr("id").split("_")[1],
                i = $("#" + active_element),
                a = (i.data("field_properties").options[t].position, i.data("field_properties").id),
                l = i.data("field_properties").type;
            i.data("field_properties").options[t].is_hidden = 1, $("#choicedel_" + t).parent().remove();
            var o = $("#element_choices input.text"),
                n = 1;
            $.each(o, function(e, t) {
                var a;
                a = $(t).attr("id").split("_"), i.data("field_properties").options[a[1]].position = n, n++
            }), $.each(i.data("field_properties").options, function(e, t) {
                "1" == i.data("field_properties").options[e].is_hidden && (i.data("field_properties").options[e].position = n, n++)
            }), "radio" == l || "checkbox" == l ? $("#element_" + a + "_" + t).parent().remove() : "select" == l && $("#element_" + a + " option[value=" + t + "]").remove();
            var r = parseInt($("#hidden_choices_counter").text()) + 1;
            return $("#hidden_choices_counter").text(r), r > 0 ? $("#toggle_hidden_choices").show() : $("#toggle_hidden_choices").hide(), !1
        }), $("#element_choices_hidden").delegate("a.trash_choice", "click", function(e) {
            var t = $(this).attr("id").split("_")[1],
                i = $("#" + active_element);
            return i.data("field_properties").options[t].position, i.data("field_properties").id, i.data("field_properties").type, $("#dialog-confirm-choice-delete").data("current_choice_option_id", t), $("#dialog-confirm-choice-delete").dialog("open"), !1
        }), $("#choice_max_entry").bind("keyup mouseout", function() {
            set_properties("element_choice_max_entry", $(this).val())
        }), $("#prop_choice_max_entry_enable").bind("change", function() {
            1 == $(this).prop("checked") ? $("#form_choice_max_entry").slideDown() : ($("#choice_max_entry").val(0), set_properties("element_choice_max_entry", 0), $("#form_choice_max_entry").hide())
        }), $("#bulk_import_choices").click(function() {
            var e = $("#field_count_span").text();
            if (e) var t = parseInt(e);
            else t = 0;
            return t == $("#maximum_field_count").val() ? ($("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1) : ($("#bulk_insert_choices").val(""), void 0 !== $("#" + active_element).data("field_properties").options[1] && "First option" == $("#" + active_element).data("field_properties").options[1].option && 3 == $("#element_choices > li").size() && $("#bulk_insert_choices").val("New option 1\nNew option 2\nNew option 3"), $("#dialog-insert-choices").next().children().eq(1).addClass("negative_btn"), $("#dialog-insert-choices").dialog("open"), $("#bulk_insert_choices").focus(), !1)
        }), $("#toggle_hidden_choices").click(function() {
            if ($("#element_choices_hidden").is(":visible")) $("#element_choices_hidden").hide(), $("#toggle_hidden_choices").css("font-weight", "normal");
            else {
                var e = "",
                    t = "",
                    i = $("#" + active_element).data("field_properties"),
                    a = i.options,
                    l = [];
                $.each(a, function(e, t) {
                    l[t.position] = e
                }), "radio" == i.type || "select" == i.type ? t = "radio" : "checkbox" == i.type && (t = "checkbox"), $.each(l, function(a, l) {
                    a > 0 && "1" == i.options[l].is_hidden && (choice_option_id = l, choice_label = i.options[l].option, choice_position = a, e += '<li><input disabled="disabled" type="' + t + '" title="Select this choice as the default." class="choices_default_hidden" name="choices_default_hidden" id="choicedefhidden_' + choice_option_id + '" /><input disabled="disabled" type="text" value="' + choice_label.replace(/\"/g, "&quot;") + '" autocomplete="off" class="text" id="choicehidden_' + choice_option_id + '" /> <a href="#" class="unhide_choice" title="Unhide" id="choiceunhide_' + choice_option_id + '"><span class="icon-circle-up4"></span></a><a href="#" class="trash_choice" title="Remove Permanently" id="choicetrash_' + choice_option_id + '"><span class="icon-remove"></span></a></li>')
                }), $("#element_choices_hidden li").remove(), $("#element_choices_hidden").append(e), $("#element_choices_hidden").show(), $("#toggle_hidden_choices").css("font-weight", "bold")
            }
            return !1
        }), $("#bulk_import_matrix_row").click(function() {
            var e = $("#field_count_span").text();
            if (e) var t = parseInt(e);
            else t = 0;
            var i = $("#maximum_field_count").val();
            if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                if (t + $("ul#element_matrix_column li").length > i) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1
            } else if (0 == $("#prop_matrix_allow_multiselect").prop("checked") && t + 1 > i) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
            return $("#bulk_insert_rows").val(""), "First Question" == $("#" + active_element + " table td.first_col").eq(0).text() && "Second Question" == $("#" + active_element + " table td.first_col").eq(1).text() && "Third Question" == $("#" + active_element + " table td.first_col").eq(2).text() && "Fourth Question" == $("#" + active_element + " table td.first_col").eq(3).text() && $("#bulk_insert_rows").val("New question 1\nNew question 2\nNew question 3"), $("#dialog-insert-matrix-rows").next().children().eq(1).addClass("negative_btn"), $("#dialog-insert-matrix-rows").dialog("open"), $("#bulk_insert_rows").focus(), !1
        }), $("#bulk_import_matrix_column").click(function() {
            var e = $("#field_count_span").text();
            if (e) var t = parseInt(e);
            else t = 0;
            var i = $("#maximum_field_count").val();
            return 1 == $("#prop_matrix_allow_multiselect").prop("checked") && t + $("#element_matrix_row li").length > i ? ($("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1) : ($("#bulk_insert_columns").val(""), "Answer A" == $("#" + active_element + " table thead th").eq(1).text() && "Answer B" == $("#" + active_element + " table thead th").eq(2).text() && "Answer C" == $("#" + active_element + " table thead th").eq(3).text() && "Answer D" == $("#" + active_element + " table thead th").eq(4).text() && $("#bulk_insert_columns").val("Answer E\nAnswer F\nAnswer G"), $("#dialog-insert-matrix-columns").next().children().eq(1).addClass("negative_btn"), $("#dialog-insert-matrix-columns").dialog("open"), $("#bulk_insert_columns").focus(), !1)
        }), $("#element_choice_columns").bind("change", function() {
            set_properties("element_choice_columns", $(this).val())
        }), $("#prop_choice_limit_rule").bind("change", function() {
            set_properties("element_choice_limit_rule", $(this).val())
        }), $("#prop_choice_limit_qty").bind("keyup mouseout", function() {
            set_properties("element_choice_limit_qty", $(this).val())
        }), $("#prop_choice_limit_range_min").bind("keyup mouseout", function() {
            set_properties("element_choice_limit_range_min", $(this).val())
        }), $("#prop_choice_limit_range_max").bind("keyup mouseout", function() {
            set_properties("element_choice_limit_range_max", $(this).val())
        }), $("#element_range_min").bind("keyup mouseout", function() {
            set_properties("element_range_min", $(this).val())
        }), $("#element_range_max").bind("keyup mouseout", function() {
            set_properties("element_range_max", $(this).val())
        }), $("#element_range_limit_by").bind("change", function() {
            set_properties("element_range_limit_by", $(this).val())
        }), $("#element_range_number_limit_by").bind("change", function() {
            set_properties("element_range_limit_by", $(this).val())
        }), $("#element_type").bind("change", function() {
            set_properties("element_type_change", $(this).val())
        }), $("#element_size").bind("change", function() {
            set_properties("element_size", $(this).val())
        }), $("#name_format").bind("change", function() {
            var e = $("ul#form_builder_sortable li.highlighted").find("fieldset span").length - 1,
                t = $("#field_count_span").text();
            if (t) var i = parseInt(t);
            else i = 0;
            var a = $(this).val(),
                l = 0;
            switch (a) {
                case a = "simple_name":
                    l = 2;
                    break;
                case a = "name":
                    l = 4;
                    break;
                case a = "simple_name_wmiddle":
                    l = 3;
                    break;
                case a = "name_wmiddle":
                    l = 5
            }
            var o = $("#maximum_field_count").val();
            if (e - l < 0) {
                var n = i - e;
                if (!((n += l) <= o)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#field_count_span").text(n), set_properties("element_type", $(this).val())
            } else n = i - e, n += l, $("#field_count_span").text(n), set_properties("element_type", $(this).val())
        }), $("#phone_format").bind("change", function() {
            set_properties("element_type", $(this).val())
        }), $("#element_default_value,#element_default_value_text").bind("keyup mouseout", function() {
            set_properties("element_default_value", $(this).val())
        }), $("#element_default_phone1,#element_default_phone2,#element_default_phone3").bind("keyup mouseout", function() {
            set_properties("element_default_value", $("#element_default_phone1").val() + $("#element_default_phone2").val() + $("#element_default_phone3").val())
        }), $("#element_default_value_textarea").bind("keyup mouseout", function() {
            set_properties("element_default_value", $(this).val())
        }), $("#element_default_date").bind("keyup mouseout", function() {
            set_properties("element_default_value", $(this).val());
            var e = $("#" + active_element).data("field_properties");
            $.ajax({
                type: "POST",
                async: !0,
                url: "string_to_time.php",
                data: {
                    default_date: $(this).val(),
                    date_format: e.type
                },
                cache: !1,
                global: !1,
                dataType: "json",
                error: function(e, t, i) {},
                success: function(t) {
                    if ("ok" == t.status) {
                        if ("date" == e.type) {
                            var i = t.default_date.split("-");
                            $("#element_" + e.id + "_1").val(i[1]), $("#element_" + e.id + "_2").val(i[0]), $("#element_" + e.id + "_3").val(i[2])
                        } else "europe_date" == e.type && (i = t.default_date.split("-"), $("#element_" + e.id + "_1").val(i[0]), $("#element_" + e.id + "_2").val(i[1]), $("#element_" + e.id + "_3").val(i[2]))
                    }
                }
            })
        }), $("#element_default_time").bind("keyup mouseout", function() {
            set_properties("element_default_value", $(this).val());
            var e = $("#" + active_element).data("field_properties");
            $.ajax({
                type: "POST",
                async: !0,
                url: "string_to_time.php",
                data: {
                    default_time: $(this).val(),
                    time_24hour: e.time_24hour
                },
                cache: !1,
                global: !1,
                dataType: "json",
                error: function(e, t, i) {},
                success: function(t) {
                    if ("ok" == t.status) {
                        var i = t.default_time.split("-");
                        $("#element_" + e.id + "_1").val(i[0]), $("#element_" + e.id + "_2").val(i[1]), $("#element_" + e.id + "_3").val(i[2]), $("#element_" + e.id + "_4").val(i[3])
                    }
                }
            })
        }), $("#prop_other_choices_label").bind("keyup mouseout", function() {
            set_properties("element_choice_other_label", $(this).val())
        }), $("#prop_choices_other_checkbox").bind("change", function() {
            set_properties("element_choice_has_other", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_choices_randomize").bind("change", function() {
            set_properties("constraint", 1 == $(this).prop("checked") ? "random" : "")
        }), $("#prop_text_as_password").bind("change", function() {
            set_properties("constraint", 1 == $(this).prop("checked") ? "password" : "")
        }), $("#prop_encrypt_data").bind("change", function() {
            set_properties("element_encrypted", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_enable_email_confirmation").bind("change", function() {
            set_properties("element_email_enable_confirmation", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#element_enable_placeholder,#element_enable_placeholder_text").bind("change", function() {
            set_properties("element_enable_placeholder", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_section_email_display").bind("change", function() {
            set_properties("element_section_display_in_email", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_section_size").bind("change", function() {
            set_properties("element_size", $(this).val())
        }), $("#prop_section_enable_scroll").bind("change", function() {
            set_properties("element_section_enable_scroll", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_time_showsecond").bind("change", function() {
            set_properties("element_time_showsecond", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_time_24hour").bind("change", function() {
            set_properties("element_time_24hour", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#element_countries").bind("change", function() {
            set_properties("element_default_value", $(this).val())
        }), $("#money_format").bind("change", function() {
            set_properties("constraint", $(this).val())
        }), $("#prop_address_hideline2").bind("change", function() {
            set_properties("element_address_hideline2", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_address_us_only").bind("change", function() {
            set_properties("element_address_us_only", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_date_range").bind("change", function() {
            set_properties("element_date_enable_range", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_date_range_format_switcher").bind("change", function() {
            set_properties("element_date_range_format", $(this).val())
        }), $("#date_range_min_relative").bind("keyup mouseout", function() {
            var e = parseInt($(this).val());
            if (e < 0) var t = ("0000" + Math.abs(e)).slice(-4) + "-00-01";
            else t = ("0000" + e).slice(-4) + "-00-00";
            set_properties("element_date_range_min", t)
        }), $("#date_range_max_relative").bind("keyup mouseout", function() {
            var e = parseInt($(this).val());
            if (e < 0) var t = ("0000" + Math.abs(e)).slice(-4) + "-00-01";
            else t = ("0000" + e).slice(-4) + "-00-00";
            set_properties("element_date_range_max", t)
        }), $("#prop_date_selection_limit").bind("change", function() {
            set_properties("element_date_enable_selection_limit", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_date_past_future_selection").bind("change", function() {
            set_properties("element_date_disable_past_future", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#date_selection_max").bind("keyup mouseout", function() {
            set_properties("element_date_selection_max", $(this).val())
        }), $("#prop_date_disable_specific").bind("change", function() {
            set_properties("element_date_disable_specific", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#date_disabled_list").bind("keyup mouseout", function() {
            set_properties("element_date_disabled_list", $(this).val())
        }), $("#prop_date_past_future").bind("change", function() {
            set_properties("date_past_future", $(this).val())
        }), $("#prop_date_disable_dayofweek").bind("change", function() {
            set_properties("element_date_disable_dayofweek", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("input.dayofweek").bind("change", function() {
            var e = [];
            $("input.dayofweek").each(function(t) {
                var i = $(this).attr("id").slice(-1);
                !0 === $(this).prop("checked") && e.push(i)
            }), set_properties("element_date_disabled_dayofweek_list", e.join(","))
        }), $("#date_type").bind("change", function() {
            set_properties("element_type", $(this).val())
        }), $("#linked_picker_range_min").datepick({
            onSelect: update_date_range_min_linked,
            showTrigger: "#date_range_min_pick_img"
        }), $("#date_range_min_mm,#date_range_min_dd,#date_range_min_yyyy").bind("blur mouseout", function() {
            var e = parseInt($("#date_range_min_dd").val(), 10),
                t = parseInt($("#date_range_min_mm").val(), 10) - 1,
                i = parseInt($("#date_range_min_yyyy").val(), 10);
            isNaN(e) || isNaN(t) || isNaN(i) || 0 == e || -1 == t || ($("#linked_picker_range_min").datepick("setDate", new Date(i, t, e)), set_properties("element_date_range_min", $("#date_range_min_yyyy").val() + "-" + $("#date_range_min_mm").val() + "-" + $("#date_range_min_dd").val()))
        }), $("#linked_picker_range_max").datepick({
            onSelect: update_date_range_max_linked,
            showTrigger: "#date_range_max_pick_img"
        }), $("#date_range_max_mm,#date_range_max_dd,#date_range_max_yyyy").bind("blur mouseout", function() {
            var e = parseInt($("#date_range_max_dd").val(), 10),
                t = parseInt($("#date_range_max_mm").val(), 10) - 1,
                i = parseInt($("#date_range_max_yyyy").val(), 10);
            isNaN(e) || isNaN(t) || isNaN(i) || 0 == e || -1 == t || ($("#linked_picker_range_max").datepick("setDate", new Date(i, t, e)), set_properties("element_date_range_max", $("#date_range_max_yyyy").val() + "-" + $("#date_range_max_mm").val() + "-" + $("#date_range_max_dd").val()))
        }), $("#date_disabled_list").datepick({
            multiSelect: 999,
            multiSeparator: ", ",
            showTrigger: "#date_disable_specific_pick_img",
            onClose: function(e) {
                for (var t = e.length, i = 0; i < t; i++) e[i] = $.datepick.formatDate("mm/dd/yyyy", e[i]);
                set_properties("element_date_disabled_list", e.join(", "))
            }
        }), $("#prop_file_enable_type_limit").bind("change", function() {
            set_properties("element_file_enable_type_limit", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_file_block_or_allow").bind("change", function() {
            set_properties("element_file_block_or_allow", $(this).val())
        }), $("#file_type_list").bind("keyup mouseout", function() {
            set_properties("element_file_type_list", $(this).val())
        }), $("#prop_file_as_attachment").bind("change", function() {
            set_properties("element_file_as_attachment", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_file_enable_advance").bind("change", function() {
            set_properties("element_file_enable_advance", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_file_auto_upload").bind("change", function() {
            set_properties("element_file_auto_upload", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_file_show_inline").bind("change", function() {
            set_properties("element_file_show_inline", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_file_multi_upload").bind("change", function() {
            set_properties("element_file_enable_multi_upload", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#file_max_selection").bind("keyup mouseout change", function() {
            set_properties("element_file_max_selection", $(this).val())
        }), $("#prop_file_limit_size").bind("change", function() {
            set_properties("element_file_enable_size_limit", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#file_size_max").bind("keyup mouseout", function() {
            set_properties("element_file_size_max", $(this).val())
        }), $("#prop_number_enable_quantity").bind("change", function() {
            set_properties("element_number_enable_quantity", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#prop_number_quantity_link").bind("change", function() {
            set_properties("element_number_quantity_link", $(this).val())
        }), $("#prop_submit_use_text").bind("click", function() {
            set_properties("submit_use_image", 1 == $(this).prop("checked") ? 0 : 1)
        }), $("#prop_submit_use_image").bind("click", function() {
            set_properties("submit_use_image", 1 == $(this).prop("checked") ? 1 : 0)
        }), $("#submit_primary_text").bind("keyup mouseout", function() {
            set_properties("submit_primary_text", $(this).val())
        }), $("#submit_secondary_text").bind("keyup mouseout", function() {
            set_properties("submit_secondary_text", $(this).val())
        }), $("#submit_primary_img").bind("keyup mouseout", function() {
            set_properties("submit_primary_img", $(this).val())
        }), $("#submit_secondary_img").bind("keyup mouseout", function() {
            set_properties("submit_secondary_img", $(this).val())
        }), $("#element_matrix_row").delegate("input.text", "keyup", function(e) {
            var t = $(this),
                i = t.attr("id").split("_")[1],
                a = "&nbsp;",
                l = $("#" + active_element);
            13 == e.keyCode ? 0 == $("#element_matrix_row li.li_mr_temp_holder").length && add_matrix_row(t) : 0 == t.parent().hasClass("li_mr_temp_holder") && ("" != t.val() && (a = t.val()), $("#mr_" + i + " td.first_col").html(a), l.data("field_properties").options[i].row_title = t.val())
        }), $("#element_matrix_row").delegate("a.add_choice", "click", function(e) {
            var t = $(this),
                i = $("#field_count_span").text();
            if (i) var a = parseInt(i);
            else a = 0;
            var l = $("#maximum_field_count").val();
            if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                var o = $("#element_matrix_column li").length;
                if (!(a + o <= l)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#field_count_span").text(a + o)
            } else if (0 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                if (!(a + 1 <= l)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#field_count_span").text(a + 1)
            }
            return 0 == $("#element_matrix_row li.li_mr_temp_holder").length && add_matrix_row(t), !1
        }), $("#element_matrix_row").delegate("a.del_choice", "click", function(e) {
            delete_matrix_row($(this));
            var t = $("#field_count_span").text();
            if (t) var i = parseInt(t);
            else i = 0;
            if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                var a = $("#element_matrix_column li").length;
                $("#field_count_span").text(i - a)
            } else 0 == $("#prop_matrix_allow_multiselect").prop("checked") && $("#field_count_span").text(i - 1);
            return !1
        }), $("#element_matrix_column").delegate("input.text", "keyup", function(e) {
            var t = $(this),
                i = t.attr("id").split("_")[1],
                a = "&nbsp;",
                l = $("#" + active_element),
                o = l.data("field_properties").id;
            13 == e.keyCode ? add_matrix_column(t) : ("" != t.val() && (a = t.val()), $("#mc_" + o + "_" + i).html(a), l.data("field_properties").options[o].column_data[i].column_title = t.val())
        }), $("#element_matrix_column").delegate("a.add_choice", "click", function(e) {
            var t = $("#field_count_span").text();
            if (t) var i = parseInt(t);
            else i = 0;
            if ($("#maximum_field_count").val(), 1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                var a = i + $("#element_matrix_row li").length;
                if (!(a <= $("#maximum_field_count").val())) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                $("#field_count_span").text(a)
            }
            return add_matrix_column($(this)), !1
        }), $("#element_matrix_column").delegate("a.del_choice", "click", function(e) {
            delete_matrix_column($(this));
            var t = $("#field_count_span").text();
            if (t) var i = parseInt(t);
            else i = 0;
            if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                var a = $("#element_matrix_row li").length;
                $("#field_count_span").text(i - a)
            }
            return !1
        }), $("#prop_matrix_allow_multiselect").bind("click", function() {
            e = 1 == $(this).prop("checked") ? 1 : 0;
            var e, t = $("#field_count_span").text();
            if (t) var i = parseInt(t);
            else i = 0;
            var a = $("#maximum_field_count").val(),
                l = $("#element_matrix_row li").length,
                o = l * $("#element_matrix_column li").length;
            if (1 == e) {
                if (!((n = (n = i - l) + o) <= a)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), $("#prop_matrix_allow_multiselect").trigger("change"), !1;
                $("#field_count_span").text(n)
            } else {
                var n = i - o;
                $("#field_count_span").text(n + l)
            }
            set_properties("element_matrix_allow_multiselect", e)
        }), $("#form_title").bind("keyup mouseout", function() {
            set_form_properties("form_title", $(this).val())
        }), $("#form_description").bind("keyup mouseout", function() {
            set_form_properties("form_description", $(this).val())
        }), $("#form_success_message_option").click(function() {
            set_form_properties("form_redirect_enable", 0)
        }), $("#form_redirect_option").click(function() {
            set_form_properties("form_redirect_enable", 1)
        }), $("#form_success_message").bind("keyup mouseout", function() {
            set_form_properties("form_success_message", $(this).val())
        }), $("#form_redirect_url").bind("keyup mouseout", function() {
            set_form_properties("form_redirect", $(this).val())
        }), $("#form_review,#form_resume").bind("change", function() {
            var e;
            e = 1 == $(this).prop("checked") ? 1 : 0, "form_review" == $(this).attr("id") ? set_form_properties("form_review", e) : set_form_properties("form_resume_enable", e)
        }), $("#form_review_title").bind("keyup mouseout", function() {
            set_form_properties("form_review_title", $(this).val())
        }), $("#form_review_description").bind("keyup mouseout", function() {
            set_form_properties("form_review_description", $(this).val())
        }), $("#form_review_use_text").click(function() {
            set_form_properties("form_review_use_image", 0)
        }), $("#form_review_use_image").click(function() {
            set_form_properties("form_review_use_image", 1)
        }), $("#review_primary_text").bind("keyup mouseout", function() {
            set_form_properties("review_primary_text", $(this).val())
        }), $("#review_primary_img").bind("keyup mouseout", function() {
            set_form_properties("review_primary_img", $(this).val())
        }), $("#review_secondary_text").bind("keyup mouseout", function() {
            set_form_properties("review_secondary_text", $(this).val())
        }), $("#review_secondary_img").bind("keyup mouseout", function() {
            set_form_properties("review_secondary_img", $(this).val())
        }), $("#form_resume_subject").bind("keyup mouseout", function() {
            set_form_properties("form_resume_subject", $(this).val())
        }), $("#form_resume_content").bind("keyup mouseout", function() {
            set_form_properties("form_resume_content", $(this).val())
        }), $("#form_resume_from_name").bind("keyup mouseout", function() {
            set_form_properties("form_resume_from_name", $(this).val())
        }), $("#form_resume_from_email_address").bind("keyup mouseout", function() {
            set_form_properties("form_resume_from_email_address", $(this).val())
        }), $("#form_password_option").bind("change", function() {
            $("#form_header").data("form_properties").password = "", $("#form_password_data").val(""), 1 == $(this).prop("checked") ? $("#form_password").slideDown() : $("#form_password").fadeOut("slow")
        }), $("#form_password_data").bind("keyup mouseout", function() {
            set_form_properties("form_password", $(this).val())
        }), $("#form_captcha").bind("change", function() {
            $("#form_prop_captcha508").hide(), 1 == $(this).prop("checked") ? ("t" != $("#form_captcha_type").val() && $("#form_prop_captcha508").show(), $("#form_header").data("form_properties").captcha = 1, $("#form_captcha_type_option").slideDown()) : ($("#form_header").data("form_properties").captcha = 0, $("#form_captcha_type_option").fadeOut("slow"))
        }), $("#form_captcha_type").bind("change", function() {
            $("#form_header").data("form_properties").captcha_type = $(this).val(), "t" == $(this).val() ? $("#form_prop_captcha508").hide() : $("#form_prop_captcha508").show()
        }), $("#form_unique_ip").bind("change", function() {
            1 == $(this).prop("checked") ? ($("#form_unique_ip_div").slideDown(), $("#form_header").data("form_properties").unique_ip = 1) : ($("#form_unique_ip_div").fadeOut("slow"), $("#form_header").data("form_properties").unique_ip = 0)
        }), $("#form_unique_ip_maxcount").bind("keyup mouseout", function() {
            set_form_properties("form_unique_ip_maxcount", $(this).val())
        }), $("#form_unique_ip_period").bind("change", function() {
            $("#form_header").data("form_properties").unique_ip_period = $(this).val()
        }), $("#form_name_hide").bind("change", function() {
            1 == $(this).prop("checked") ? $("#form_header").data("form_properties").name_hide = 1 : $("#form_header").data("form_properties").name_hide = 0
        }), $("#form_limit_option").bind("change", function() {
            1 == $(this).prop("checked") ? ($("#form_limit_div").slideDown(), $("#form_header").data("form_properties").limit_enable = 1) : ($("#form_limit_div").fadeOut("slow"), $("#form_header").data("form_properties").limit_enable = 0)
        }), $("#form_limit").bind("keyup mouseout", function() {
            set_form_properties("form_limit", $(this).val())
        }), $("#form_encryption_enable").bind("change", function() {
            if (1 != $(this).prop("checked")) return $("#dialog-confirm-encryption-disable").dialog("open"), !1;
            $("#dialog-enable-data-encryption").dialog("open")
        }), $("#form_prop_toggle_a,#form_prop_toggle_img").click(function() {
            return "show more options" == $("#form_prop_toggle_a").text() ? ($("#form_prop_toggle_a").text("show less options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_up.gif"), $("#all_form_properties .advanced_prop").not("#form_prop_review").not("#form_prop_resume").show(), 1 == $("#form_review").prop("checked") && $("#form_prop_review").show(), 1 == $("#form_resume").prop("checked") && $("#form_prop_resume").show(), adjust_main_height(), $("#form_prop_toggle_a").data("expand", 1)) : ($("#form_prop_toggle_a").text("show more options"), $("#form_prop_toggle_img").attr("src", "images/icons/resultset_next.gif"), $("#form_prop_review,#form_prop_resume").hide(), $("#all_form_properties .advanced_prop").slideUp("slow", function() {
                adjust_main_height()
            }), $("#form_prop_toggle_a").data("expand", 0)), !1
        }), $("#form_label_alignment").bind("change", function() {
            set_form_properties("form_label_alignment", $(this).val())
        }), $("#form_language").bind("change", function() {
            set_form_properties("form_language", $(this).val())
        }), $("#pagination_style_steps,#pagination_style_percentage,#pagination_style_disabled").bind("click", function() {
            var e, t = $(this).attr("id");
            "pagination_style_steps" == t ? e = "steps" : "pagination_style_percentage" == t ? e = "percentage" : "pagination_style_disabled" == t && (e = "disabled"), set_form_properties("form_pagination_type", e)
        }), $("#pagination_title_list").delegate("input.text", "keyup", function(e) {
            var t = $(this),
                i = parseInt(t.attr("id").split("_")[1]),
                a = i + 1,
                l = $("#form_header").data("form_properties"),
                o = $("#form_builder_sortable > li.page_break"),
                n = l.pagination_type;
            "steps" == n ? 13 == e.keyCode ? $("#pagetitleinput_" + a).focus().select() : $("#page_title_" + i).text(t.val()) : "percentage" == n && (13 == e.keyCode ? $("#pagetitleinput_" + a).focus().select() : 1 == i && $("#page_title_1").html("Page 1 of " + o.length + " - " + t.val())), o.eq(i - 1).data("field_properties").page_title = t.val(), o.eq(i - 1).removeClass("synched")
        }), $("#form_schedule_enable").bind("change", function() {
            1 == $(this).prop("checked") ? ($("#form_header").data("form_properties").schedule_enable = 1, $("#form_prop_scheduling_start").fadeIn(), $("#form_prop_scheduling_end").fadeIn()) : ($("#form_header").data("form_properties").schedule_enable = 0, $("#form_prop_scheduling_start").fadeOut("slow"), $("#form_prop_scheduling_end").fadeOut("slow"))
        }), $("#linked_picker_scheduling_start").datepick({
            onSelect: update_scheduling_start_linked,
            showTrigger: "#scheduling_start_pick_img"
        }), $("#scheduling_start_mm,#scheduling_start_dd,#scheduling_start_yyyy").bind("blur mouseout", function() {
            var e = parseInt($("#scheduling_start_dd").val(), 10),
                t = parseInt($("#scheduling_start_mm").val(), 10) - 1,
                i = parseInt($("#scheduling_start_yyyy").val(), 10);
            if (!isNaN(e) && !isNaN(t) && !isNaN(i) && 0 != e && -1 != t) {
                $("#linked_picker_scheduling_start").datepick("setDate", new Date(i, t, e));
                var a = $("#scheduling_start_yyyy").val() + "-" + $("#scheduling_start_mm").val() + "-" + $("#scheduling_start_dd").val();
                $("#form_header").data("form_properties").schedule_start_date = a
            }
        }), $("#scheduling_start_hour,#scheduling_start_minute,#scheduling_start_ampm").bind("change", function() {
            $("#form_header").data("form_properties").schedule_start_hour = $("#scheduling_start_hour").val() + ":" + $("#scheduling_start_minute").val() + ":" + $("#scheduling_start_ampm").val()
        }), $("#linked_picker_scheduling_end").datepick({
            onSelect: update_scheduling_end_linked,
            showTrigger: "#scheduling_end_pick_img"
        }), $("#scheduling_end_mm,#scheduling_end_dd,#scheduling_end_yyyy").bind("blur mouseout", function() {
            var e = parseInt($("#scheduling_end_dd").val(), 10),
                t = parseInt($("#scheduling_end_mm").val(), 10) - 1,
                i = parseInt($("#scheduling_end_yyyy").val(), 10);
            if (!isNaN(e) && !isNaN(t) && !isNaN(i) && 0 != e && -1 != t) {
                $("#linked_picker_scheduling_end").datepick("setDate", new Date(i, t, e));
                var a = $("#scheduling_end_yyyy").val() + "-" + $("#scheduling_end_mm").val() + "-" + $("#scheduling_end_dd").val();
                $("#form_header").data("form_properties").schedule_end_date = a
            }
        }), $("#scheduling_end_hour,#scheduling_end_minute,#scheduling_end_ampm").bind("change", function() {
            $("#form_header").data("form_properties").schedule_end_hour = $("#scheduling_end_hour").val() + ":" + $("#scheduling_end_minute").val() + ":" + $("#scheduling_end_ampm").val()
        }), $("#form_custom_script_enable").bind("change", function() {
            1 == $(this).prop("checked") ? ($("#form_header").data("form_properties").custom_script_enable = 1, $("#form_custom_script_div").slideDown()) : ($("#form_header").data("form_properties").custom_script_enable = 0, $("#form_custom_script_div").fadeOut("slow"))
        }), $("#form_custom_script_url").bind("keyup mouseout", function() {
            set_form_properties("form_custom_script_url", $(this).val())
        }), $("#form_approval_enable").bind("change", function() {
            1 == $(this).prop("checked") ? $("#form_header").data("form_properties").approval_enable = 1 : $("#form_header").data("form_properties").approval_enable = 0
        }), $("#social a").click(function() {
            var e = $("#maximum_field_count").val();
            if (field_count = $("#field_count_span").text()) var t = parseInt(field_count);
            else t = 0;
            var i, a = $(this).attr("id");
            switch (is_allowed = !0, a) {
                case a = "a_single_line_text":
                case a = "a_number":
                case a = "a_paragraph_text":
                case a = "a_phone":
                    t < e ? field_count ? $("#field_count_span").text(t + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                    break;
                case a = "a_checkboxes":
                    t + 3 <= e ? field_count ? $("#field_count_span").text(t + 3) : $("#field_count_span").text(3) : is_allowed = !1;
                    break;
                case a = "a_multiple_choice":
                case a = "a_drop_down":
                    t < e ? field_count ? $("#field_count_span").text(t + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                    break;
                case a = "a_name":
                    t + 2 <= e ? field_count ? $("#field_count_span").text(t + 2) : $("#field_count_span").text(2) : is_allowed = !1;
                    break;
                case a = "a_date":
                case a = "a_time":
                    t < e ? field_count ? $("#field_count_span").text(t + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                    break;
                case a = "a_address":
                    t + 6 <= e ? field_count ? $("#field_count_span").text(t + 6) : $("#field_count_span").text(6) : is_allowed = !1;
                    break;
                case a = "a_website":
                case a = "a_price":
                case a = "a_email":
                    t < e ? field_count ? $("#field_count_span").text(t + 1) : $("#field_count_span").text(1) : is_allowed = !1;
                    break;
                case a = "a_matrix":
                    t + 4 <= e ? field_count ? $("#field_count_span").text(t + 4) : $("#field_count_span").text(4) : is_allowed = !1;
                    break;
                case a = "a_file_upload":
                case a = "a_signature":
                    t < e ? field_count ? $("#field_count_span").text(t + 1) : $("#field_count_span").text(1) : is_allowed = !1
            }
            switch ($(this).attr("id")) {
                case "a_single_line_text":
                default:
                    i = "text";
                    break;
                case "a_number":
                    i = "number";
                    break;
                case "a_paragraph_text":
                    i = "textarea";
                    break;
                case "a_checkboxes":
                    i = "checkbox";
                    break;
                case "a_multiple_choice":
                    i = "radio";
                    break;
                case "a_drop_down":
                    i = "select";
                    break;
                case "a_name":
                    i = "simple_name";
                    break;
                case "a_date":
                    i = "date";
                    break;
                case "a_time":
                    i = "time";
                    break;
                case "a_phone":
                    i = "phone";
                    break;
                case "a_address":
                    i = "address";
                    break;
                case "a_website":
                    i = "url";
                    break;
                case "a_price":
                    i = "money";
                    break;
                case "a_email":
                    i = "email";
                    break;
                case "a_section_break":
                    i = "section";
                    break;
                case "a_file_upload":
                    i = "file";
                    break;
                case "a_page_break":
                    i = "page_break";
                    break;
                case "a_matrix":
                    i = "matrix";
                    break;
                case "a_signature":
                    i = "signature";
                    break;
                case "a_media":
                    i = "media"
            }
            return is_allowed ? (add_element(i), !1) : ($("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1)
        }), $("#dialog-message").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 600,
            draggable: !1,
            resizable: !1,
            position: ["center", "center"],
            open: function() {
                $(this).next().find("button").blur()
            },
            buttons: [{
                text: "Close",
                class: "bb_button bb_small bb_green",
                click: function() {
                    $("#bottom_bar_loader").hide(), $("#bottom_bar_content").show(), $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-warning").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 600,
            position: ["center", "center"],
            draggable: !1,
            resizable: !1,
            open: function() {
                $(this).next().find("button").blur()
            },
            buttons: [{
                text: "OK",
                class: "bb_button bb_small bb_green",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-confirm-encryption-disable").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 550,
            resizable: !1,
            draggable: !1,
            position: ["center", "center"],
            buttons: [{
                text: "Yes. I Understand",
                id: "btn-confirm-encryption-disable-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    $("#form_header").data("form_properties").encryption_enable = 0, $("#form_header").data("form_properties").encryption_public_key = "", $("#form_encryption_enable").prop("checked", !1), $(this).dialog("close")
                }
            }, {
                text: "Cancel",
                id: "btn-field-delete-cancel",
                class: "btn_secondary_action",
                click: function() {
                    $("#form_header").data("form_properties").encryption_enable = 1, $("#form_encryption_enable").prop("checked", !0), $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-confirm-field-delete").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 550,
            resizable: !1,
            draggable: !1,
            position: ["center", "center"],
            open: function() {
                $("#btn-field-delete-ok").blur()
            },
            buttons: [{
                text: "Yes. Delete this field",
                id: "btn-field-delete-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    var e = $("#" + active_element),
                        t = e.html(),
                        i = $("#form_header").data("form_properties").id,
                        a = $("#authTokenTrackActivity").length && "" != $("#authTokenTrackActivity").val() ? $("#authTokenTrackActivity").val() : "";
                    e.html('<img src="images/loader_small.gif" style="vertical-align: middle"/> deleting field ...').addClass("delete_processing"), $(this).dialog("close"), $.ajax({
                        type: "POST",
                        async: !0,
                        url: "get_count_on_delete_live_fields.php",
                        data: {
                            form_id: i,
                            element_id: e.data("field_properties").id
                        },
                        cache: !1,
                        global: !0,
                        dataType: "json",
                        success: function(e) {
                            e.field_count && (field_count_shown = $("#field_count_span").text(), $("#field_count_span").text(parseInt(field_count_shown) - e.field_count))
                        }
                    }), $.ajax({
                        type: "POST",
                        async: !0,
                        url: "delete_live_field.php",
                        data: {
                            form_id: i,
                            element_id: e.data("field_properties").id
                        },
                        headers: {
                            "Authentication-Token": a
                        },
                        cache: !1,
                        global: !0,
                        dataType: "json",
                        error: function(i, a, l) {
                            e.html(t).removeClass("delete_processing")
                        },
                        success: function(i) {
                            if ("ok" == i.status) {
                                if ("media" == e.data("field_properties").type && "video" == e.data("field_properties").media_type) {
                                    var a = videojs("video_" + i.element_id);
                                    if (void 0 !== a) try {
                                        a.dispose()
                                    } catch (l) {}
                                }
                                $("#li_" + i.element_id).fadeOut("normal", function() {
                                    $(this).remove(), reorganize_page_break(), $("#form_builder_sortable").sortable("refreshPositions")
                                }), active_element = null, $("#selected_field_image").css("visibility", "hidden"), $("#bottom_bar_field_action").fadeOut("fast", function() {
                                    $("#bottom_bar_content").animate({
                                        "margin-left": "225px"
                                    }, {
                                        duration: 200,
                                        queue: !1
                                    })
                                }), $("#builder_tabs").tabs("select", 0)
                            } else $(this).dialog("close"), e.html(t).removeClass("delete_processing"), $("#dialog-message").dialog("open")
                        }
                    })
                }
            }, {
                text: "Cancel",
                id: "btn-field-delete-cancel",
                class: "btn_secondary_action",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-confirm-choice-delete").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 550,
            resizable: !1,
            draggable: !1,
            position: ["center", "center"],
            open: function() {
                $("#btn-choice-delete-ok").blur()
            },
            buttons: [{
                text: "Yes. Delete Choice",
                id: "btn-choice-delete-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    var e = $("#dialog-confirm-choice-delete").data("current_choice_option_id"),
                        t = $("#" + active_element),
                        i = (t.data("field_properties").options[e].position, t.data("field_properties").id),
                        a = t.data("field_properties").type,
                        l = t.data("field_properties").options;
                    delete l[e], "checkbox" == a && (field_count = $("#field_count_span").text(), $("#field_count_span").text(parseInt(field_count) - 1)), t.data("field_properties").options = l, $("#choicetrash_" + e).parent().remove();
                    var o = $("#element_choices input.text"),
                        n = 1;
                    $.each(o, function(e, i) {
                        var a;
                        a = $(i).attr("id").split("_"), t.data("field_properties").options[a[1]].position = n, n++
                    }), $.each(t.data("field_properties").options, function(e, i) {
                        "1" == t.data("field_properties").options[e].is_hidden && (t.data("field_properties").options[e].position = n, n++)
                    }), "radio" == a || "checkbox" == a ? $("#element_" + i + "_" + e).parent().remove() : "select" == a && $("#element_" + i + " option[value=" + e + "]").remove();
                    var r = parseInt($("#hidden_choices_counter").text()) - 1;
                    $("#hidden_choices_counter").text(r), r > 0 ? $("#toggle_hidden_choices").show() : ($("#toggle_hidden_choices").hide(), $("#element_choices_hidden").hide(), $("#toggle_hidden_choices").css("font-weight", "normal")), $(this).dialog("close")
                }
            }, {
                text: "Cancel",
                id: "btn-field-delete-choice-cancel",
                class: "btn_secondary_action",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-form-corruption").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 450,
            resizable: !1,
            draggable: !1,
            position: ["center", "center"],
            open: function() {
                $("#btn-form-form-corruption-fix").css("margin-left", "95px"), $("#btn-form-form-corruption-fix").blur()
            },
            buttons: [{
                text: "Fix Form error and Save the Form",
                id: "btn-form-form-corruption-fix",
                class: "bb_button bb_small bb_green",
                click: function() {
                    var e = $("#form_header").data("form_properties").id,
                        t = $("#authTokenTrackActivity").val();
                    $.ajax({
                        type: "POST",
                        async: !0,
                        url: "fix_form_corruption.php",
                        data: {
                            form_id: e,
                            corruptionType: "elementCorruptionFix"
                        },
                        cache: !1,
                        global: !1,
                        dataType: "json",
                        headers: {
                            "Authentication-Token": t,
                            "cache-control": "no-cache"
                        },
                        success: function(e) {
                            "true" == e.status || 1 == e.status ? setTimeout(function() {
                                $("#bottom_bar_msg").text("Please wait... Saving...");
                                var e = $("#form_header").data("form_properties").id,
                                    t = $("#form_header").data("form_properties");
                                t.frame_height = $("#form_container").outerHeight();
                                var i = $("#li_lastpage").data("field_properties"),
                                    a = $("#form_builder_sortable > li.dblive").not(".synched").not(".li_pagination");
                                if (a.length >= 1) {
                                    var l = [];
                                    a.each(function(e) {
                                        l[e] = $(this).data("field_properties")
                                    })
                                }
                                var o = $("#form_builder_sortable").sortable("serialize", {
                                    key: "el_pos[]"
                                });
                                $.ajax({
                                    type: "POST",
                                    async: !0,
                                    url: "http://192.168.1.193:8124/save_form",
                                    data: {
                                        form_id: e,
                                        fp: t,
                                        ep: l,
                                        el_pos: o,
                                        lp: i
                                    },
                                    cache: !1,
                                    global: !1,
                                    dataType: "json",
                                    error: function(e, t, i) {
                                        alert("Error while saving. Error Message:\n" + e.responseText)
                                    },
                                    success: function(e) {
                                        "ok" == e.status ? ($("#bottom_bar_loader").remove(), $("#bottom_bar_msg").hide(), $(".form_editor").data("form_saved", !0), $("#dialog-form-saved").dialog("open")) : alert("Error while saving. Error Message:\n" + e)
                                    }
                                })
                            }, 200) : alert("failure...")
                        },
                        error: function(e, t, i) {
                            alert("Error! Unable to fix the error. Please try again.")
                        }
                    })
                }
            }, ]
        }), $("#dialog-form-saved").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 450,
            resizable: !1,
            draggable: !1,
            position: ["center", "center"],
            open: function() {
                $("#btn-form-saved-ok").blur()
            },
            buttons: [{
                text: "Yes. Continue editing",
                id: "btn-form-saved-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    var e = $("#form_header").data("form_properties").id,
                        t = new Date().getTime();
                    window.location.replace("edit_form.php?id=" + e + "&t=" + t)
                }
            }, {
                text: "I'm finished",
                id: "btn-form-saved-cancel",
                class: "btn_secondary_action",
                click: function() {
                    var e = $("#form_header").data("form_properties").id;
                    1 == $("#form_header").data("is_new_form") ? window.location.replace("manage_forms.php?id=" + e + "&hl=1&filter=clear") : window.location.replace("manage_forms.php?id=" + e)
                }
            }, ]
        }), $("#dialog-insert-choices").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 515,
            position: ["center", "center"],
            draggable: !1,
            resizable: !1,
            open: function() {
                $(this).next().find("button").blur()
            },
            buttons: [{
                text: "Add Choices",
                class: "bb_button bb_small bb_green",
                click: function() {
                    if ("" == $("#bulk_insert_choices").val()) $(this).dialog("close");
                    else {
                        var e = $("#bulk_insert_choices").val().split("\n"),
                            t = $("#" + active_element);
                        if ("checkbox" == t.data("field_properties").type) {
                            var i = $("#bulk_insert_choices").val().split("\n").length,
                                a = $("#field_count_span").text();
                            if (a) var l = parseInt(a);
                            else l = 0;
                            if (!(l + i <= $("#maximum_field_count").val())) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                            $("#field_count_span").text(l + i)
                        }
                        var o = parseInt(t.data("field_properties").last_option_id) + 1,
                            n = 0;
                        $.each(t.data("field_properties").options, function(e, i) {
                            t.data("field_properties").options[e].position > n && (n = t.data("field_properties").options[e].position)
                        }), n++;
                        var r = t.data("field_properties").options,
                            s = "",
                            d = t.data("field_properties").id,
                            p = t.data("field_properties").type;
                        $.each(e, function(e, t) {
                            r[o] = {
                                position: n,
                                option: t,
                                is_default: 0,
                                is_hidden: 0,
                                is_db_live: "0"
                            }, "radio" == p ? s += '<span><input type="radio" value="1" class="element radio" name="element_' + d + '" id="element_' + d + "_" + o + '"><label for="element_' + d + "_" + o + '" class="choice">' + t + "</label></span>" : "checkbox" == p ? s += '<span><input type="checkbox" value="1" class="element checkbox" name="element_' + d + '" id="element_' + d + "_" + o + '"><label for="element_' + d + "_" + o + '" class="choice">' + t + "</label></span>" : "select" == p && (s += '<option value="' + o + '">' + t + "</option>"), o++, n++
                        }), "radio" == p || "checkbox" == p ? 1 == t.data("field_properties").choice_has_other ? $("#element_" + d + "_other").parent().before(s) : $("#li_" + d + " > div").append(s) : "select" == p && $("#element_" + d).append(s), t.data("field_properties").options = r, t.data("field_properties").last_option_id = o - 1;
                        var c = $("#element_choices input.text"),
                            m = 1;
                        $.each(c, function(e, i) {
                            var a;
                            a = $(i).attr("id").split("_"), t.data("field_properties").options[a[1]].position = m, m++
                        }), $.each(t.data("field_properties").options, function(e, i) {
                            "1" == t.data("field_properties").options[e].is_hidden && (t.data("field_properties").options[e].position = m, m++)
                        }), $(this).dialog("close"), load_properties("#" + active_element)
                    }
                }
            }, {
                text: "Cancel",
                class: "btn_secondary_action",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-insert-matrix-rows").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 500,
            draggable: !1,
            resizable: !1,
            open: function() {
                $(this).next().find("button").blur()
            },
            position: ["center", "center"],
            buttons: [{
                text: "Add Rows",
                class: "bb_button bb_small bb_green",
                click: function() {
                    if ("" == $("#bulk_insert_rows").val()) $(this).dialog("close");
                    else {
                        var e, t = $("#field_count_span").text();
                        if (t) var i = parseInt(t);
                        else i = 0;
                        var a = $("#maximum_field_count").val(),
                            l = $("#bulk_insert_rows").val().split("\n").length;
                        if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                            if (i + (e = l * $("#element_matrix_column li").length) > a) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                            $("#field_count_span").text(i + e)
                        } else if (0 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                            if (!((e = l + i) <= a)) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                            $("#field_count_span").text(e)
                        }
                        var o = $("#form_header").data("form_properties").id,
                            n = $("#bulk_insert_rows").val().split("\n"),
                            r = $("#" + active_element),
                            s = $("#form_builder_sortable > li").not(".li_pagination").size() + 1 + $("#form_builder_sortable li.matrix table tr").length,
                            d = $("#" + active_element + " table th").length;
                        $("#" + active_element + " table tbody").append('<tr id="mr_temp_' + s + '" class="matrix_row_processing"><td colspan="' + d + '"><img src="images/loader_small.gif" style="vertical-align: middle"/> creating new rows ...</td></tr>'), $.ajax({
                            type: "POST",
                            async: !0,
                            url: "add_matrix_row.php",
                            data: {
                                form_id: o,
                                row_holder_id: "mr_temp_" + s,
                                allow_multiselect: r.data("field_properties").matrix_allow_multiselect,
                                matrix_parent_id: r.data("field_properties").id,
                                position: $("#" + active_element + " table tbody tr").length,
                                total_column: d - 1,
                                column_data: r.data("field_properties").options[r.data("field_properties").id].column_data,
                                rows_titles: n
                            },
                            cache: !1,
                            global: !0,
                            dataType: "json",
                            error: function(e, t, i) {
                                $("#mr_temp_" + s).remove()
                            },
                            success: function(e) {
                                if ("ok" == e.status) {
                                    var t = r.data("field_properties").options;
                                    $.each(e.new_row_data, function(e, i) {
                                        t[e] = i
                                    }), r.data("field_properties").options = t, $("#" + e.row_holder_id).replaceWith(e.new_row_markup), load_properties("#" + active_element)
                                } else $("#dialog-message").dialog("open"), $("#mr_temp_" + s).remove()
                            }
                        }), $(this).dialog("close")
                    }
                }
            }, {
                text: "Cancel",
                class: "btn_secondary_action",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-insert-matrix-columns").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            draggable: !1,
            resizable: !1,
            open: function() {
                $(this).next().find("button").blur()
            },
            width: 515,
            position: ["center", "center"],
            buttons: [{
                text: "Add Columns",
                class: "bb_button bb_small bb_green",
                click: function() {
                    if ("" == $("#bulk_insert_columns").val()) $(this).dialog("close");
                    else {
                        var e = $("#field_count_span").text();
                        if (e) var t = parseInt(e);
                        else t = 0;
                        var i = $("#maximum_field_count").val(),
                            a = $("#bulk_insert_columns").val().split("\n").length;
                        if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                            var l = a * $("#element_matrix_row li").length;
                            if (t + l > i) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
                            $("#field_count_span").text(t + l)
                        }
                        $("#form_header").data("form_properties").id;
                        var o = $("#" + active_element + " table th").length,
                            n = $("#bulk_insert_columns").val().split("\n"),
                            r = $("#" + active_element),
                            s = r.data("field_properties").id,
                            d = parseInt(r.data("field_properties").last_option_id) + 1,
                            p = d;
                        r.data("field_properties").last_option_id = d + n.length - 1;
                        var c, m = "",
                            u = d;
                        $.each(n, function(e, t) {
                            m += '<th scope="col" id="mc_' + s + "_" + u + '" class="matrix_choice_header">' + t + "</th>", u++
                        }), $("#" + active_element + " table thead tr").append(m), c = 1 == r.data("field_properties").matrix_allow_multiselect ? "checkbox" : "radio";
                        var f = "",
                            h = "";
                        $("#" + active_element + " table tbody").find("tr").each(function() {
                            f = $(this).attr("id").split("_")[1], h = "", u = d, $.each(n, function(e, t) {
                                h += '<td><input type="' + c + '" value="' + u + '" name="element_' + f + '" id="element_' + f + "_" + u + '"></td>', u++
                            }), d++, $(this).append(h)
                        });
                        var g = $("#" + active_element + " table th").length,
                            b = 100 / g * 2,
                            y = (100 - (b = Math.round(b))) / (g - 1);
                        y = Math.round(y), $("#" + active_element + " table th:eq(0)").css("width", b + "%"), $("#" + active_element + " table th:gt(0)").css("width", y + "%");
                        var x = r.data("field_properties").options[s].column_data,
                            _ = o;
                        $.each(n, function(e, t) {
                            x[p] = {
                                column_title: t,
                                is_db_live: 0,
                                position: _
                            }, _++, p++
                        }), r.data("field_properties").options[s].column_data = x, load_properties("#" + active_element), $(this).dialog("close")
                    }
                }
            }, {
                text: "Cancel",
                class: "btn_secondary_action",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-enable-data-encryption").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 500,
            position: ["center", 100],
            draggable: !1,
            resizable: !1,
            buttons: [{
                text: "Generate Encryption Keys",
                id: "dialog-enable-data-encryption-btn-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    var e = $("#form_header").data("form_properties").id;
                    $("#dialog-enable-data-encryption-btn-ok").prop("disabled", !0), $("#dialog-enable-data-encryption-btn-cancel").hide(), $("#dialog-enable-data-encryption-btn-ok").text("Generating keys..."), $("#dialog-enable-data-encryption-btn-ok").after("<div class='small_loader_box'><img src='images/loader_small_grey.gif' /></div>"), $.ajax({
                        type: "POST",
                        async: !0,
                        url: "encryption_generate_keypair.php",
                        data: {
                            form_id: e
                        },
                        cache: !1,
                        global: !1,
                        dataType: "json",
                        error: function(e, t, i) {
                            $("#dialog-enable-data-encryption").dialog("close"), $("#dialog-enable-data-encryption-btn-ok").prop("disabled", !1), $("#dialog-enable-data-encryption-btn-cancel").show(), $("#dialog-enable-data-encryption-btn-ok").text("Generate Encryption Keys"), $("#dialog-enable-data-encryption-btn-ok").next().remove(), alert("Error! Unable to generate encryption keys. \nError message: " + e.responseText)
                        },
                        success: function(e) {
                            $("#dialog-enable-data-encryption").dialog("close"), $("#dialog-enable-data-encryption-btn-ok").prop("disabled", !1), $("#dialog-enable-data-encryption-btn-cancel").show(), $("#dialog-enable-data-encryption-btn-ok").text("Generate Encryption Keys"), $("#dialog-enable-data-encryption-btn-ok").next().remove(), "ok" == e.status && ($("#form_header").data("form_properties").encryption_enable = 1, $("#form_header").data("form_properties").encryption_public_key = e.public_key, $("#dialog-enable-encryption-private-key").val(e.private_key), $("#dialog-enable-data-encryption-success").dialog("open"))
                        }
                    })
                }
            }, {
                text: "Cancel",
                id: "dialog-enable-data-encryption-btn-cancel",
                class: "btn_secondary_action",
                click: function() {
                    $("#form_header").data("form_properties").encryption_enable = 0, $("#form_encryption_enable").prop("checked", !1), $(this).dialog("close")
                }
            }, ]
        }), $("#dialog-enable-data-encryption-success").dialog({
            modal: !0,
            autoOpen: !1,
            closeOnEscape: !1,
            width: 500,
            position: ["center", "center"],
            open: function() {
                $("#dialog-enable-encryption-private-key").focus().select()
            },
            draggable: !1,
            resizable: !1,
            buttons: [{
                text: "I Understand. Continue",
                id: "dialog-enable-data-encryption-success-btn-ok",
                class: "bb_button bb_small bb_green",
                click: function() {
                    $(this).dialog("close")
                }
            }, ]
        }), $(document).ajaxError(function(e, t, i, a) {
            $("#dialog-message").dialog("open")
        }), $("#social li").draggable({
            connectToSortable: "#form_builder_sortable",
            helper: "clone",
            revert: "invalid",
            revertDuration: 300,
            addClasses: !0
        }), $("#form_builder_sortable li").not(".li_pagination").addClass("synched dblive"), $("#bottom_bar_duplicate_field").click(function() {
            var e = $("#maximum_field_count").val();
            if (field_count = $("#field_count_span").text()) var t = parseInt(field_count);
            else t = 0;
            var i = $("#" + active_element).data("field_properties").type;
            switch (is_allowed = !0, i) {
                case i = "text":
                case i = "textarea":
                case i = "number":
                case i = "date":
                case i = "time":
                case i = "phone":
                case i = "money":
                case i = "url":
                case i = "email":
                    t < e ? increment_by = 1 : is_allowed = !1;
                    break;
                case i = "address":
                    t + 6 <= e ? increment_by = 6 : is_allowed = !1;
                    break;
                case i = "file":
                case i = "signature":
                    t < e ? increment_by = 1 : is_allowed = !1;
                    break;
                case i = "section":
                case i = "media":
                    increment_by = 0;
                    break;
                case i = "simple_name":
                    t + 2 <= e ? increment_by = 2 : is_allowed = !1;
                    break;
                case i = "name":
                    t + 4 <= e ? increment_by = 4 : is_allowed = !1;
                    break;
                case i = "simple_name_wmiddle":
                    t + 3 <= e ? increment_by = 3 : is_allowed = !1;
                    break;
                case i = "name_wmiddle":
                    t + 5 <= e ? increment_by = 5 : is_allowed = !1;
                    break;
                case i = "radio":
                case i = "select":
                    t < e ? increment_by = 1 : is_allowed = !1;
                    break;
                case i = "checkbox":
                    var a = $("ul#element_choices li").length;
                    1 == $("#prop_choices_other_checkbox").prop("checked") ? a += 1 : $("#prop_choices_other_checkbox").prop("checked"), t + a <= e ? increment_by = a : is_allowed = !1;
                    break;
                case i = "matrix":
                    var l = $("ul#element_matrix_row li").length,
                        o = $("ul#element_matrix_column li").length;
                    1 == $("#prop_matrix_allow_multiselect").prop("checked") ? is_allowed = t + (increment_by = l * o) <= e : 0 == $("#prop_matrix_allow_multiselect").prop("checked") && (increment_by = l, is_allowed = t + increment_by <= e)
            }
            if (0 == is_allowed) return $("#ui-dialog-title-dialog-warning").html("Sorry,Unable to create new field"), $("#dialog-warning-msg").html("This action will exceed the maximum fields allowed"), $("#dialog-warning").dialog("open"), !1;
            $("#field_count_span").text(t + increment_by);
            var n = $("#form_builder_sortable > li").not(".li_pagination").size() + 1;
            $('<li id="li_temp_' + n + '" class="duplicate_processing"><img src="images/loader_small.gif" style="vertical-align: middle"/> duplicating field ...</li>').insertAfter("#" + active_element).hide().fadeIn();
            var r = $("#form_header").data("form_properties").id,
                s = $("#" + active_element).data("field_properties"),
                d = s.position + 1,
                p = $("#authTokenTrackActivity").length && "" != $("#authTokenTrackActivity").val() ? $("#authTokenTrackActivity").val() : "";
            return $.ajax({
                type: "POST",
                async: !0,
                url: "http://192.168.1.193:8124/add_field",
                data: {
                    element_type: s.type,
                    form_id: r,
                    holder_id: "li_temp_" + n,
                    position: d,
                    action: "duplicate",
                    field_properties: s
                },
                headers: {
                    "Authentication-Token": p
                },
                cache: !1,
                global: !0,
                dataType: "json",
                error: function(e, t, i) {
                    $("#form_builder_sortable .duplicate_processing").remove()
                },
                success: function(e) {
                    if ("ok" == e.status) {
                        var t = $(e.markup);
                        t.data("field_properties", e.field_properties), $("#" + e.holder_id).replaceWith(t), "section" == t.data("field_properties").type ? $("#li_" + e.element_id + " > h3").html($("#li_" + e.element_id + " > h3").html().replace(/\n/g, "<br />")) : "media" == t.data("field_properties").type ? ($("#li_" + e.element_id + " > h3").html($("#li_" + e.element_id + " > h3").html().replace(/\n/g, "<br />")), "video" == t.data("field_properties").media_type && videojs("video_" + e.element_id)) : "page_break" == t.data("field_properties").type || "matrix" == t.data("field_properties").type || ($("#li_" + e.element_id + " > label").length > 0 ? $("#li_" + e.element_id + " > label").html($("#li_" + e.element_id + " > label").html().replace(/\n/g, "<br />")) : $("#li_" + e.element_id + " > span.description").length > 0 && $("#li_" + e.element_id + " > span.description").html($("#li_" + e.element_id + " > span.description").html().replace(/\n/g, "<br />"))), $("#li_" + e.element_id).hide().fadeIn(), reorganize_page_break(), $("#form_builder_sortable").sortable("refreshPositions")
                    } else $("#dialog-message").dialog("open"), $("#form_builder_sortable .duplicate_processing").remove()
                }
            }), !1
        }), $("#bottom_bar_delete_field").click(function() {
            var e = $("#" + active_element);
            if (1 >= $("#form_builder_sortable > li").not(".li_pagination").not(".page_break").size()) $("#ui-dialog-title-dialog-warning").html("Unable to delete this field!"), $("#dialog-warning-msg").html("You can't delete all fields in your form! <br />You must have at least 1 field."), $("#dialog-warning").dialog("open");
            else {
                if ("page_break" == e.data("field_properties").type && (e.data("field_properties").is_db_live = 0), 0 == e.data("field_properties").is_db_live) {
                    if (field_count_shown = $("#field_count_span").text()) var t = parseInt(field_count_shown);
                    else t = 0;
                    var i = e.data("field_properties").type;
                    if ("text" == i) $("#field_count_span").text(t - 1);
                    else if ("textarea" == i) $("#field_count_span").text(t - 1);
                    else if ("radio" == i) $("#field_count_span").text(t - 1);
                    else if ("checkbox" == i) {
                        var a = $("li.highlighted").find("input[type=checkbox]").length;
                        $("#field_count_span").text(t - a)
                    } else if ("select" == i) $("#field_count_span").text(t - 1);
                    else if ("number" == i) $("#field_count_span").text(t - 1);
                    else if ("simple_name" == i) $("#field_count_span").text(t - 2);
                    else if ("name" == i) $("#field_count_span").text(t - 4);
                    else if ("simple_name_wmiddle" == i) $("#field_count_span").text(t - 3);
                    else if ("name_wmiddle" == i) $("#field_count_span").text(t - 5);
                    else if ("date" == i) $("#field_count_span").text(t - 1);
                    else if ("time" == i) $("#field_count_span").text(t - 1);
                    else if ("phone" == i) $("#field_count_span").text(t - 1);
                    else if ("money" == i) $("#field_count_span").text(t - 1);
                    else if ("url" == i) $("#field_count_span").text(t - 1);
                    else if ("email" == i) $("#field_count_span").text(t - 1);
                    else if ("address" == i) $("#field_count_span").text(t - 6);
                    else if ("file" == i) $("#field_count_span").text(t - 1);
                    else if ("signature" == i) $("#field_count_span").text(t - 1);
                    else if ("matrix" == i) {
                        if (1 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                            var l = (o = $("#element_matrix_row li").length) * $("#element_matrix_column li").length;
                            $("#field_count_span").text(t - l)
                        } else if (0 == $("#prop_matrix_allow_multiselect").prop("checked")) {
                            var o = $("#element_matrix_row li").length;
                            $("#field_count_span").text(t - o)
                        }
                    }
                }
                if (0 == e.data("field_properties").is_db_live) {
                    auth = $("#authTokenTrackActivity").length && "" != $("#authTokenTrackActivity").val() ? $("#authTokenTrackActivity").val() : "";
                    var n = e.html(),
                        r = $("#form_header").data("form_properties").id;
                    e.html('<img src="images/loader_small.gif" style="vertical-align: middle"/> deleting field ...').addClass("delete_processing"), $.ajax({
                        type: "POST",
                        async: !0,
                        url: "delete_draft_field.php",
                        data: {
                            form_id: r,
                            element_id: e.data("field_properties").id,
                            element_type: e.data("field_properties").type
                        },
                        cache: !1,
                        global: !0,
                        headers: {
                            "Authentication-Token": auth
                        },
                        dataType: "json",
                        error: function(t, i, a) {
                            e.html(n).removeClass("delete_processing")
                        },
                        success: function(t) {
                            if ("ok" == t.status) {
                                if ("media" == e.data("field_properties").type && "video" == e.data("field_properties").media_type) {
                                    var i = videojs("video_" + t.element_id);
                                    if (void 0 !== i) try {
                                        i.dispose()
                                    } catch (a) {}
                                }
                                $("#li_" + t.element_id).fadeOut("normal", function() {
                                    $(this).remove(), reorganize_page_break(), $("#form_builder_sortable").sortable("refreshPositions")
                                }), active_element = null, $("#selected_field_image").css("visibility", "hidden"), $("#bottom_bar_field_action").fadeOut("fast", function() {
                                    $("#bottom_bar_content").animate({
                                        "margin-left": "225px"
                                    }, {
                                        duration: 200,
                                        queue: !1
                                    })
                                }), $("#builder_tabs").tabs("select", 0)
                            } else e.html(n).removeClass("delete_processing"), $("#dialog-message").dialog("open")
                        }
                    })
                } else $("#dialog-confirm-field-delete").dialog("open")
            }
            return !1
        }), $("#bottom_bar").fadeIn(), $("#editor_loading").fadeOut("slow"), $(window).on("beforeunload", function() {
            return !0 === $(".form_editor").data("form_saved") ? null : "Your changes haven't been saved! \nLeaving this page will discard all changes."
        }), window.setTimeout(function e() {
            var t = $("#form_header").data("form_properties").id;
            $.ajax({
                type: "POST",
                async: !0,
                url: "http://192.168.1.193:8124/ping",
                data: {
                    form_id: t
                },
                cache: !1,
                global: !0,
                dataType: "json",
                complete: function() {
                    setTimeout(e, 3e5)
                }
            })
        }, 3e5), is_support_html5_uploader() ? $("#element_image_file_uploader").uploadifive({
            uploadScript: "upload_form_images.php",
            buttonText: "Select Image",
            removeCompleted: !0,
            formData: {
                session_id: $("#form_header").data("session_id"),
                form_id: 0
            },
            auto: !0,
            multi: !1,
            onUploadError: function(e, t, i, a) {
                alert("The file " + e.name + " could not be uploaded: " + a)
            },
            onAddQueueItem: function(e) {
                var t = $("#form_header").data("form_properties").id;
                $(this).data("uploadifive").settings.formData = {
                    session_id: $("#form_header").data("session_id"),
                    form_id: t
                }
            },
            onUploadComplete: function(e, t) {
                var i = !1;
                try {
                    var a = jQuery.parseJSON(t);
                    i = !0
                } catch (l) {
                    i = !1, alert(t)
                }
                if (1 == i && "ok" == a.status) {
                    $("#element_image_src").val(a.image_url), $("#div_image_src").show(), $("#element_image_set_url").prop("checked", !0), $("#element_image_width").val(a.image_width), $("#element_image_height").val(a.image_height), $("#element_image_width").data("original-image-width", a.image_width), $("#element_image_height").data("original-image-height", a.image_height);
                    var o = $("#" + active_element).data("field_properties");
                    o.media_image_src = a.image_url, o.media_image_width = a.image_width, o.media_image_height = a.image_height;
                    var n = '<div class="media_image_container"><img src="' + a.image_url + '" width="' + a.image_width + '" height="' + a.image_height + '" alt="" title="" class="media_image" /></div>';
                    $("#" + active_element + " .media_icon").remove(), $("#" + active_element + " .media_image_container").remove(), $("#" + active_element).append(n)
                } else alert("Error uploading image. Please try again.")
            }
        }) : $("#div_image_upload_file").hide(), $("#element_image_upload_file").bind("click", function() {
            1 == $(this).prop("checked") && ($("#div_image_src").hide(), $("#div_image_upload_file").show())
        }), $("#element_image_set_url").bind("click", function() {
            1 == $(this).prop("checked") && ($("#div_image_src").show(), $("#div_image_upload_file").hide())
        }), $("#element_image_ratio_lock .icon-font").bind("click", function() {
            return $(this).hasClass("icon-lock5") ? ($(this).removeClass("icon-lock5").addClass("icon-unlocked"), $(".image-lock-ratio").css("border-bottom", "none")) : ($(this).removeClass("icon-unlocked").addClass("icon-lock5"), $(".image-lock-ratio").css("border-bottom", "2px solid #3D6C10")), !1
        }), $("#element_image_width").bind("keyup", function() {
            var e = parseInt($(this).val());
            if ($("#" + active_element).data("field_properties").media_image_width = e, $("#" + active_element + " .media_image").css("width", e), $("#" + active_element + " .media_image").css("height", parseInt($("#element_image_height").val())), $("#element_image_ratio_lock .icon-font").hasClass("icon-lock5")) {
                var t = parseInt($("#element_image_width").data("original-image-width")),
                    i = e * (parseInt($("#element_image_height").data("original-image-height")) / t);
                isNaN(i) ? ($("#element_image_height").val(""), $("#" + active_element).data("field_properties").media_image_height = "") : ($("#element_image_height").val(parseInt(i)), $("#" + active_element).data("field_properties").media_image_height = i, $("#" + active_element + " .media_image").css("height", i))
            }
        }), $("#element_image_height").bind("keyup", function() {
            var e = parseInt($(this).val());
            if ($("#" + active_element).data("field_properties").media_image_height = e, $("#" + active_element + " .media_image").css("height", e), $("#" + active_element + " .media_image").css("width", parseInt($("#element_image_width").val())), $("#element_image_ratio_lock .icon-font").hasClass("icon-lock5")) {
                var t = parseInt($("#element_image_width").data("original-image-width")),
                    i = parseInt($("#element_image_height").data("original-image-height")),
                    a = parseInt($(this).val()) * (t / i);
                isNaN(a) ? ($("#element_image_width").val(""), $("#" + active_element).data("field_properties").media_image_width = "") : ($("#element_image_width").val(parseInt(a)), $("#" + active_element).data("field_properties").media_image_width = a, $("#" + active_element + " .media_image").css("width", a))
            }
        }), $("#element_image_src").bind("keyup", function() {
            var e = $(this).val();
            $("#" + active_element).data("field_properties").media_image_src = e;
            var t = '<div class="media_image_container"><img src="' + e + '" width="' + $("#" + active_element).data("field_properties").media_image_width + '" height="' + $("#" + active_element).data("field_properties").media_image_height + '" alt="" title="" class="media_image" /></div>';
            $("#" + active_element + " .media_icon").remove(), $("#" + active_element + " .media_image_container").remove(), $("#" + active_element).append(t)
        }), $("#element_image_alignment_left,#element_image_alignment_center,#element_image_alignment_right").bind("click", function() {
            var e = $(this).attr("id");
            $("#" + active_element + " .media_image_container").removeClass("media_image_left media_image_center media_image_right"), "element_image_alignment_left" == e ? ($("#" + active_element).data("field_properties").media_image_alignment = "l", $("#" + active_element + " .media_image_container").addClass("media_image_left")) : "element_image_alignment_center" == e ? ($("#" + active_element).data("field_properties").media_image_alignment = "c", $("#" + active_element + " .media_image_container").addClass("media_image_center")) : "element_image_alignment_right" == e && ($("#" + active_element).data("field_properties").media_image_alignment = "r", $("#" + active_element + " .media_image_container").addClass("media_image_right"))
        }), $("#element_media_image_alt").bind("keyup mouseout", function() {
            $("#" + active_element).data("field_properties").media_image_alt = $(this).val()
        }), $("#element_media_image_href").bind("keyup mouseout", function() {
            $("#" + active_element).data("field_properties").media_image_href = $(this).val()
        }), $("#element_media_display_in_email").bind("change", function() {
            var e;
            e = 1 == $(this).prop("checked") ? 1 : 0, $("#" + active_element).data("field_properties").media_display_in_email = e
        }), $("#element_media_video_src").bind("keyup", function() {
            $("#" + active_element).data("field_properties").media_video_src = $(this).val();
            var e = $("#" + active_element).data("field_properties"),
                t = e.id,
                i = "";
            "1" == e.media_video_muted && (i = "muted");
            var a, l = document.createElement("a");
            if (l.href = e.media_video_src, a = "www.youtube.com" == l.hostname || "youtube.com" == l.hostname || "youtu.be" == l.hostname ? "video/youtube" : "video/mp4", 0 == $("#" + active_element + " .media_video_container").length) {
                var o = '<div class="media_video_container ' + e.media_video_size + '"><video id="video_' + t + '" class="video-js vjs-default-skin vjs-fluid" controls ' + i + '  preload="auto" aspectRatio="16:9" width="640" height="264" data-setup=\'{ "techOrder": ["youtube","html5"], "sources": [{ "type": "' + a + '", "src": "' + e.media_video_src + "\"}] }' > </video>";
                $("#" + active_element + " .media_icon").remove(), $("#" + active_element + " .media_image_container").remove(), $("#" + active_element).append(o)
            }
            void 0 === videojs("video_" + t) ? videojs("video_" + t) : (videojs("video_" + t).src({
                type: a,
                src: e.media_video_src
            }), setTimeout(function() {
                videojs("video_" + t).poster(videojs("video_" + t).tech_.poster())
            }, 2e3))
        }), $("#element_media_video_caption_file").bind("keyup mouseout", function() {
            $("#" + active_element).data("field_properties").media_video_caption_file = $(this).val()
        }), $("#element_media_video_size_small,#element_media_video_size_medium,#element_media_video_size_large").bind("click", function() {
            var e = $(this).attr("id");
            $("#" + active_element + " .media_video_container").removeClass("small medium large"), "element_media_video_size_small" == e ? ($("#" + active_element).data("field_properties").media_video_size = "small", $("#" + active_element + " .media_video_container").addClass("small")) : "element_media_video_size_medium" == e ? ($("#" + active_element).data("field_properties").media_video_size = "medium", $("#" + active_element + " .media_video_container").addClass("medium")) : "element_media_video_size_large" == e && ($("#" + active_element).data("field_properties").media_video_size = "large", $("#" + active_element + " .media_video_container").addClass("large"))
        }), $("#element_media_video_muted").bind("change", function() {
            var e;
            e = 1 == $(this).prop("checked") ? 1 : 0, $("#" + active_element).data("field_properties").media_video_muted = e
        }), $("#element_media_video_enable_caption").bind("change", function() {
            1 == $(this).prop("checked") ? $("#div_video_caption_file").show() : ($("#div_video_caption_file").hide(), $("#" + active_element).data("field_properties").media_video_caption_file = "", $("#element_media_video_caption_file").val(""))
        }), $("#form_title,#form_description,#form_review_title,#form_review_description,#form_custom_script_url").blur(function() {
            var e = $(this).attr("id"),
                t = $("#activity_form_id").val(),
                i = $(this).val();
            i = i ? encodeURI(i) : "none", e && t && $.ajax({
                type: "POST",
                async: !0,
                url: "ajax-track-activity.php",
                data: {
                    form_id: t,
                    property_type: e,
                    property_val: i
                },
                cache: !1,
                global: !1,
                dataType: "json",
                success: function(e) {}
            })
        }), $("#form_review,#form_custom_script_enable").change(function() {
            var e = $(this).attr("id"),
                t = $("#activity_form_id").val();
            if (1 == $(this).prop("checked")) var i = 1;
            else 0 == $(this).prop("checked") && (i = 0);
            e && t && $.ajax({
                type: "POST",
                async: !0,
                url: "ajax-track-activity.php",
                data: {
                    form_id: t,
                    property_type: e,
                    property_val: i
                },
                cache: !1,
                global: !1,
                dataType: "json",
                success: function(e) {}
            })
        })
    });