(function() {
    jQuery.extend({
        getJSONWait : function ( url, args, retry_cnt, callback ) {
            jQuery.ajax({
                type: "GET",
                url: url,
                data: args,
                success: function (json) {
                    if (json.status == 'wait' && retry_cnt > 0)
                        setTimeout(function () { $.getJSONWait(url, args, retry_cnt-1, callback); }, json.waittime);
                    else
                        callback(json);
                },
                dataType: "json",
                cache: false
            });
            return this;
        },
        truncate : function (str, len, elp) {
            if (!str)
                return;
            if (!elp)
                elp = '...';
            if (str.length > len)
                return str.substr(0, len - elp.length) + elp;
            else
                return str;
        }
    });
    jQuery.fn.extend({
        reset : function () {
            return this.each(function () {
                $(this).is('form') && this.reset();
            });
        }
    });
})();

