function s3_popup_refresh_main_form(){var a=getQueryParams(document.location.search),b=a.refresh;if("undefined"!=typeof b){var f=self.parent.$("#"+b);"undefined"!==typeof f.dataTable?f.dataTable().fnReloadAjax():(a=a.record,void 0!==a?self.parent.dlAjaxReloadItem(b,a):self.parent.dlAjaxReload(b));a=self.parent.S3.gis.maps;if("undefined"!=typeof a){var c,e,d,p,u,k,l,v,r;for(c in a)for(e=a[c],d=b.replace(/-/g,"_"),e=e.layers,p=0,u=e.length;p<u;p++)if(k=e[p],k.s3_layer_id==d)for(k=k.strategies,l=0,v=
k.length;l<v;l++)r=k[l],"OpenLayers.Strategy.Refresh"==r.CLASS_NAME&&r.refresh()}b=self.parent.$("#"+b+"-filter-form");b.length&&self.parent.S3.search.ajaxUpdateOptions(b);self.parent.s3_popup_remove()}else if("undefined"!=typeof a.level)self.parent.s3_popup_remove();else{var g=a.caller;s3_debug("caller",g);b=a.person_id;if("undefined"!=typeof b)"undefined"!=typeof g&&self.parent.$("#"+g).val(b).change(),self.parent.s3_popup_remove();else{b=RegExp(".*\\"+S3.Ap+"\\/");c=a.child;var n;"undefined"===
typeof c?(d=(new String(self.location)).replace(b,""),d=d.split("?")[0].split("/"),n=d[1]+"_id"):n=c;s3_debug("child_resource",n);c=a.parent;"undefined"===typeof c?(c=g.replace("_"+n,""),s3_debug("parent_field",c),a=c.replace(/_.*/,""),c=c.replace(a+"_",""),a=new String(self.parent.location),d=a.replace(b,""),d=d.split("?")[0].split("/"),a=null,b=d[0],e=d[1],2<d.length&&(null!==d[2].match(/\d*/)?3<d.length&&(a=d[3]):a=d[2]),null!==a&&(c!=e&&c==a)&&(c=e+"/"+a)):(a=new String(self.parent.location),
d=a.replace(b,""),d=d.split("?")[0].split("/"),b=d[0]);s3_debug("parent_resource",c);s3_debug("caller_prefix",b);b=S3.Ap.concat("/"+b+"/"+c+"/options.s3json?field="+n);f=self.parent.$("#"+g);s3_debug("selector",f);var A="sub_"==g.substring(0,4),w=self.parent.$("#dummy_"+g),x=void 0!=w.val();s3_debug("has_dummy",x);var s=f.hasClass("checkboxes-widget-s3"),h;if(s){var B=self.parent.$("#"+g+" tbody tr:first").children().length;h=[]}else{var y=self.parent.$("#"+g+" >option"),t=y.length;t?h=[]:b+="&only_last=1"}var q=
1,z="";$.getJSONS3(b,function(a){var b,c,d,e=0;$.each(a.option,function(){b=this["@value"];c=this.$;"undefined"===typeof c&&(c="");t?h.push(["<option value='",b,"'>",c,"</option>"].join("")):s&&(d="id_"+n+"-"+e,h.push(["<td><input id='",d,"' name='",n,"' value='",b,"' type='checkbox'><label for='",d,"'>",c,"</label></td>"].join("")),e++);numeric_value=+b;numeric_value>q&&(q=numeric_value,z=c)});x&&(w.val(z),f.val(q).change());if(t){if(A){var m=["_0","_none","_default"],k,p=g.split("_").slice(0,-1).join("_");
for(a=0;a<m.length;a++)k=m[a],self.parent.$("#"+p+k).empty().append(h.join(""))}else y.remove(),f.append(h.join("")).val(q).change();f.val(q).change()}else if(s){var l=[];self.parent.$("#"+g+" input").each(function(a){$(this).prop("checked")&&l.push($(this).val())});m=[];for(a=e=0;a<h.length;a++)0===e?(m.push("<tr>"),m.push(h[a]),e++):e==B-1?(m.push(h[a]),m.push("</tr>"),e=0):(m.push(h[a]),e++);f.html(m.join(""));l.push(q);for(a=0;a<l.length;a++)self.parent.$("#"+g+' input[value="'+l[a]+'"]').prop("checked",
!0)}self.parent.s3_popup_remove()})}}}function getQueryParams(a){a=a.split("?")[1];a=a.split("&");for(var b={},f=[],c=0;c<a.length;c++)f=a[c].split("="),b[decodeURIComponent(f[0])]=decodeURIComponent(f[1]);return b};
