﻿function PostbackPusher(g){var d=this,e=[];this.Separator="___SEP___";this.TimeOut=60000;this.Disabler=null;this.Call=function(b,a){var c=(new Date).getTime(),f=[];f.push(b);f.push(a);f.push(c);window[g+"_ServerCall"](f.join(d.Separator));d.Disabler!=null&&typeof d.Disabler=="function"&&d.Disabler(true);d.CheckProgress(c)};window[g+"_ClientReceive"]=function(){if(!(arguments==null||typeof arguments=="undefined"||arguments[0]==null||typeof arguments[0]=="undefined")){var b=arguments[0].split(d.Separator);if(!(b.length<2)){for(var a=0;a<e.length;a++){var c=e[a];if(!(c==null||c.t!=b[1])){c.r=false;e[a]=c;break}}if(d.Disabler!=null&&typeof d.Disabler=="function"){var f=false;for(a=0;a<e.length;a++){c=e[a];if(!(c==null||!c.r)){f=true;break}}f||d.Disabler(false)}if(typeof XMLParser=="undefined")alert("XMLParser is missing!");else{a=XMLParser(b[0]);if(!(a==null||typeof a=="undefined")){b=a.getElementsByTagName("r");if(!(b==null||typeof b=="undefined"||b.length==0))for(a=0;a<b.length;a++){c=b[a];switch(c.getAttribute("t").toLowerCase()){case "function":eval(c.getAttribute("v"));break;case "message":default:alert(c.getAttribute("v"));break}}}}}}};this.CheckProgress=function(b){var a=window.setInterval(g+'_ProgressChecker("'+b+'");',500);b={t:b,i:a,r:true};e.push(b)};window[g+"_ProgressChecker"]=function(b){var a=(new Date).getTime();if(a-b>=d.TimeOut)for(var c=0;c<e.length;c++){a=e[c];if(!(a==null||a.t!=b)){if(a.r){b=[];b.push('<response><r t="message" v="A fost depasit timpul maxim alocat executiei!"/></response>');b.push(a.t);window[g+"_ClientReceive"](b.join(d.Separator))}else{window.clearInterval(a.i);e[c]=null}break}}}};