diff --git a/src/messenger/webim/js/request.js b/src/messenger/webim/js/request.js
new file mode 100644
index 00000000..badd050f
--- /dev/null
+++ b/src/messenger/webim/js/request.js
@@ -0,0 +1,8 @@
+var mibewRequestedScripts=[],mibewHandlers=[],mibewHandlersDependences=[];
+function mibewMakeRequest(){mibewDoLoadScript(mibewRequestUrl+"&rnd="+Math.random(),"responseScript")}
+function mibewOnResponse(a){var b=a.load,c=a.handlers,e=a.data,a=a.dependences;for(id in b)if(!(b[id]in mibewRequestedScripts))mibewRequestedScripts[id]=[],mibewRequestedScripts[id].url=b[id],mibewRequestedScripts[id].status="loading",mibewLoadScript(id);for(handler in a)handler in mibewHandlersDependences||(mibewHandlersDependences[handler]=a[handler]);for(b=0;b
+
+
+
+
diff --git a/src/messenger/webim/js/source/request.js b/src/messenger/webim/js/source/request.js
new file mode 100644
index 00000000..df376c62
--- /dev/null
+++ b/src/messenger/webim/js/source/request.js
@@ -0,0 +1,98 @@
+var mibewRequestedScripts = new Array();
+var mibewHandlers = new Array();
+var mibewHandlersDependences = new Array();
+
+function mibewMakeRequest()
+{
+ mibewDoLoadScript(mibewRequestUrl + '&rnd=' + Math.random(), 'responseScript');
+}
+
+function mibewOnResponse(response)
+{
+ var load = response.load;
+ var handlers = response.handlers;
+ var data = response.data;
+ var dependences = response.dependences;
+
+ for(id in load){
+ if(! (load[id] in mibewRequestedScripts)){
+ mibewRequestedScripts[id] = new Array();
+ mibewRequestedScripts[id]['url'] = load[id];
+ mibewRequestedScripts[id]['status'] = 'loading';
+ mibewLoadScript(id);
+ }
+ }
+
+ for(handler in dependences){
+ if(! (handler in mibewHandlersDependences)){
+ mibewHandlersDependences[handler] = dependences[handler];
+ }
+ }
+
+ for(var i = 0; i < handlers.length; i++){
+ var handlerName = handlers[i];
+ if(mibewCanRunHandler(handlers[i])){
+ window[handlerName](data);
+ }else{
+ if(! (handlers[i] in mibewHandlers)){
+ mibewHandlers[handlerName] = function(){
+ window[handlerName](data);
+ };
+ }
+ }
+ }
+
+ mibewCleanUpAfterRequest();
+
+ window.setTimeout(mibewMakeRequest,mibewRequestTimeout);
+}
+
+function mibewCleanUpAfterRequest()
+{
+ document.getElementsByTagName('head')[0].removeChild(document.getElementById('responseScript'));
+}
+
+function mibewDoLoadScript(url, id)
+{
+ var script = document.createElement('script');
+ script.setAttribute('type', 'text/javascript');
+ script.setAttribute('src', url);
+ script.setAttribute('id', id);
+ document.getElementsByTagName('head')[0].appendChild(script);
+ return script;
+}
+
+function mibewLoadScript(id)
+{
+ var script = mibewDoLoadScript(mibewRequestedScripts[id]['url'], id);
+ script.onload = function(){
+ mibewScriptReady(id);
+ }
+ script.onreadystatechange = function(){
+ if (this.readyState == 'complete' || this.readyState == 'loaded') {
+ mibewScriptReady(id);
+ }
+ }
+}
+
+function mibewScriptReady(id)
+{
+ mibewRequestedScripts[id]['status'] = 'ready';
+ for(handlerName in mibewHandlers){
+ if(mibewCanRunHandler(handlerName)){
+ mibewHandlers[handlerName]();
+ delete mibewHandlers[handlerName];
+ }
+ }
+}
+
+function mibewCanRunHandler(handlerName)
+{
+ var dependences = mibewHandlersDependences[handlerName];
+ for(var i = 0; i < dependences.length; i++){
+ if(mibewRequestedScripts[dependences[i]]['status'] != 'ready'){
+ return false;
+ }
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php
index b29dcb93..b267a680 100644
--- a/src/messenger/webim/libs/common.php
+++ b/src/messenger/webim/libs/common.php
@@ -465,6 +465,14 @@ function start_html_output()
header("Content-type: text/html" . (isset($charset) ? "; charset=" . $charset : ""));
}
+function start_js_output(){
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate");
+ header("Pragma: no-cache");
+ header("Content-type: application/javascript; charset=utf-8");
+ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
+}
+
function escape_with_cdata($text)
{
return "", "]]>]]>";
diff --git a/src/messenger/webim/libs/request.php b/src/messenger/webim/libs/request.php
new file mode 100644
index 00000000..b4af2495
--- /dev/null
+++ b/src/messenger/webim/libs/request.php
@@ -0,0 +1,31 @@
+ (isset($response['load'])?$response['load']:array()),
+ 'handlers' => (isset($response['handlers'])?$response['handlers']:array()),
+ 'dependences' => (isset($response['dependences'])?$response['dependences']:array()),
+ 'data' => (isset($response['data'])?$response['data']:array()));
+ return "mibewOnResponse(" . json_encode($result) . ");";
+}
+
+?>
diff --git a/src/messenger/webim/request.php b/src/messenger/webim/request.php
new file mode 100644
index 00000000..6a4eb6ca
--- /dev/null
+++ b/src/messenger/webim/request.php
@@ -0,0 +1,30 @@
+
\ No newline at end of file