/**
 * jQuery Deserialize plugin
 * @author: Dawid Fatyga
 *
 * Forked from: http://github.com/jakubpawlowicz/jquery.deserialize
 *Modified: AN 6-29-2011 Avoid loading empty values, added urldecode to values
**/

(function ($) {
    $.fn.deserialize = function (s) {
        var data = {};
        var parts = s.split("&");
        for (var i = 0; i < parts.length; i++) {
            var pair = decodeURIComponent(parts[i]).split("=");
            if (pair[1] != "" && pair[1] != undefined) {
                pair[1] = decodeURI(pair[1]).replace(/\+/g, " ");
                data[pair[0]] = pair[1];
                $("[type!=radio][name='" + pair[0] + "']", this).val(pair[1]);
                $("[type=radio][name='" + pair[0] + "'][value='" + pair[1] + "']", this).attr("checked", true);
            }
        }
        $("input[type=checkbox]").not($("input[id^=iaci_]")).not($("input[id^=saci_]"), this).each(function () {
            $(this).attr("checked", $(this).attr("name") in data);
        });
    };
})(jQuery);


