Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(w) {
  2.   if (w.fastXDM) return;
  3.  
  4.   var handlers  = {};
  5.   var onEnvLoad = [];
  6.   var env       = {};
  7.  
  8.   function waitFor(obj, prop, func, self,  count) {
  9.     if (obj[prop]) {
  10.       func.apply(self);
  11.     } else {
  12.       count = count || 0;
  13.       if (count < 1000) {
  14.         setTimeout(function() {
  15.           waitFor(obj, prop, func, self, count + 1);
  16.         }, 0);
  17.       }
  18.     }
  19.   }
  20.  
  21.   function attachScript(url) {
  22.     setTimeout(function() {
  23.       var newScript  = document.createElement('script');
  24.       newScript.type = 'text/javascript';
  25.       newScript.src  = url || w.fastXDM.helperUrl;
  26.       waitFor(document, 'body', function() {
  27.         document.getElementsByTagName('HEAD')[0].appendChild(newScript);
  28.       });
  29.     }, 0);
  30.   }
  31.  
  32.   function walkVar(value, clean) {
  33.     var newValue;
  34.  
  35.     switch (typeof value) {
  36.       case 'string':
  37.         if (clean) {
  38.           newValue = value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;');
  39.         } else {
  40.           newValue = value.replace(/&#039;/g, '\'').replace(/&quot;/g, '"').replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&');
  41.         }
  42.         break;
  43.       case 'object':
  44.         if (Object.prototype.toString.apply(value) === '[object Array]') {
  45.           newValue = [];
  46.           for (var i = 0, len = value.length; i < len; i++) {
  47.             newValue[i] = walkVar(value[i], clean);
  48.           }
  49.         } else {
  50.           newValue = {};
  51.           for (var k in value) {
  52.             if (Object.hasOwnProperty.call(value, k)) {
  53.               newValue[k] = walkVar(value[k], clean);
  54.             }
  55.           }
  56.         }
  57.         break;
  58.       default:
  59.         newValue = value;
  60.         break;
  61.     }
  62.  
  63.     return newValue;
  64.   }
  65.  
  66.   // Env functions
  67.   function getEnv(callback, self) {
  68.     if (env.loaded) {
  69.       callback.apply(self, [env]);
  70.     } else {
  71.       onEnvLoad.push([self, callback]);
  72.     }
  73.   }
  74.  
  75.   function envLoaded() {
  76.     env.loaded = true;
  77.  
  78.     for (var i = 0, len = onEnvLoad.length; i < len; i++) {
  79.       onEnvLoad[i][1].apply(onEnvLoad[i][0], [env]);
  80.     }
  81.   }
  82.  
  83.   function applyMethod(strData, self) {
  84.     getEnv(function(env) {
  85.       var data = env.json.parse(strData);
  86.       if (data[0]) {
  87.         if (!data[1]) data[1] = [];
  88.  
  89.         for (var i = 0, len = data[1].length; i < len; i++) {
  90.           if (data[1][i] && data[1][i]._func) {
  91.             var funcNum = data[1][i]._func;
  92.             data[1][i] = function() {
  93.               var args = Array.prototype.slice.call(arguments);
  94.               args.unshift('_func' + funcNum);
  95.               self.callMethod.apply(self, args);
  96.             }
  97.           } else if (self.options.safe) {
  98.             data[1][i] = walkVar(data[1][i], true);
  99.           }
  100.         }
  101.  
  102.         setTimeout(function() {
  103.           if (!self.methods[data[0]]) {
  104.             throw Error('fastXDM: Method ' + data[0] + ' is undefined');
  105.           }
  106.           self.methods[data[0]].apply(self, data[1]);
  107.         }, 0);
  108.       }
  109.     });
  110.   }
  111.  
  112.   function extend(obj1, obj2) {
  113.     for (var i in obj2) {
  114.       if (obj1[i] && typeof(obj1[i]) === 'object') {
  115.         extend(obj1[i], obj2[i])
  116.       } else {
  117.         obj1[i] = obj2[i];
  118.       }
  119.     }
  120.   }
  121.  
  122.   // XDM object
  123.   w.fastXDM = {
  124.     _id: 0,
  125.     helperUrl: 'https://vk.com/js/api/xdmHelper.js',
  126.  
  127.     Server: function(methods, filter, options) {
  128.       this.methods   = methods || {};
  129.       this.filter    = filter;
  130.       this.options   = options || {};
  131.       this.id        = w.fastXDM._id++;
  132.       this.key       = genKey();
  133.       this.frameName = 'fXD' + this.key;
  134.       this.server    = true;
  135.  
  136.       this.methods['%init%'] = this.methods.__fxdm_i = function() {
  137.         w.fastXDM.run(this.id);
  138.         if (this.methods.onInit) {
  139.           this.methods.onInit();
  140.         }
  141.       };
  142.  
  143.       handlers[this.key] = [applyMethod, this];
  144.     },
  145.  
  146.     Client: function(methods, options) {
  147.       this.methods = methods || {};
  148.       this.options = options || {};
  149.       this.id      = w.fastXDM._id++;
  150.       this.client  = true;
  151.  
  152.       w.fastXDM.run(this.id);
  153.  
  154.       if (window.name.indexOf('fXD') === 0) {
  155.         this.key = window.name.substr(3);
  156.       } else {
  157.         throw Error('Wrong window.name property.');
  158.       }
  159.  
  160.       this.caller = window.parent;
  161.  
  162.       handlers[this.key] = [applyMethod, this];
  163.  
  164.       w.fastXDM.on('helper', function() {
  165.         w.fastXDM.onClientStart(this);
  166.       }, this);
  167.  
  168.       getEnv(function(env) {
  169.         env.send(this, env.json.stringify(['%init%']));
  170.  
  171.         var methods = this.methods;
  172.         setTimeout(function() {
  173.           if (methods.onInit) {
  174.             methods.onInit();
  175.           }
  176.         }, 0);
  177.       }, this);
  178.     },
  179.  
  180.     onMessage: function(e) {
  181.       var data = e.data;
  182.       if (!data) {
  183.         return false;
  184.       }
  185.       if (typeof data !== 'string' && !(data instanceof String)) {
  186.         return false;
  187.       }
  188.  
  189.       var key = data.substr(0, 5);
  190.       if (handlers[key]) {
  191.         var self = handlers[key][1];
  192.         if (self && (!self.filter || self.filter(e.origin))) {
  193.           handlers[key][0](data.substr(6), self);
  194.         }
  195.       }
  196.     },
  197.  
  198.     setJSON: function(json) {
  199.       env.json = json;
  200.     },
  201.  
  202.     getJSON: function(callback) {
  203.       if (!callback) {
  204.         return env.json;
  205.       }
  206.  
  207.       getEnv(function(env) {
  208.         callback(env.json);
  209.       });
  210.     },
  211.  
  212.     setEnv: function(exEnv) {
  213.       for (var i in exEnv) {
  214.         env[i] = exEnv[i];
  215.       }
  216.  
  217.       envLoaded();
  218.     },
  219.  
  220.     _q: {},
  221.  
  222.     on: function(key, act, self) {
  223.       if (!this._q[key]) this._q[key] = [];
  224.  
  225.       if (this._q[key] == -1) {
  226.         act.apply(self);
  227.       } else {
  228.         this._q[key].push([act, self]);
  229.       }
  230.     },
  231.  
  232.     run: function(key) {
  233.       var len = (this._q[key] || []).length;
  234.       for (var i = 0; i < len; i++) {
  235.         this._q[key][i][0].apply(this._q[key][i][1]);
  236.       }
  237.  
  238.       this._q[key] = -1;
  239.     },
  240.  
  241.     waitFor: waitFor
  242.   }
  243.  
  244.   w.fastXDM.Server.prototype.start = function(obj, count) {
  245.     if (obj.contentWindow) {
  246.       this.caller = obj.contentWindow;
  247.       this.frame  = obj;
  248.  
  249.       w.fastXDM.on('helper', function() {
  250.         w.fastXDM.onServerStart(this);
  251.       }, this);
  252.     } else { // Opera old versions
  253.       var self = this;
  254.       count = count || 0;
  255.       if (count < 50) {
  256.         setTimeout(function() {
  257.           self.start.apply(self, [obj, count + 1]);
  258.         }, 100);
  259.       }
  260.     }
  261.   }
  262.  
  263.   w.fastXDM.Server.prototype.destroy = function() {
  264.     delete handlers[this.key];
  265.   }
  266.  
  267.   w.fastXDM.Server.prototype.append = function(obj, options, attrs) {
  268.     var div       = document.createElement('DIV');
  269.     div.innerHTML = '<iframe name="' + this.frameName + '" ' + (attrs || '') + '></iframe>';
  270.     var frame     = div.firstChild;
  271.     var self      = this;
  272.  
  273.     setTimeout(function() {
  274.       frame.frameBorder = '0';
  275.       if (options) extend(frame, options);
  276.       obj.insertBefore(frame, obj.firstChild);
  277.       self.start(frame);
  278.     }, 0);
  279.  
  280.     return frame;
  281.   }
  282.  
  283.   w.fastXDM.Client.prototype.callMethod = w.fastXDM.Server.prototype.callMethod = function() {
  284.     var args   = Array.prototype.slice.call(arguments);
  285.     var method = args.shift();
  286.  
  287.     for (var i = 0, len = args.length; i < len; i++) {
  288.       if (typeof(args[i]) === 'function') {
  289.         this.funcsCount = (this.funcsCount || 0) + 1;
  290.         var func        = args[i];
  291.         var funcName    = '_func' + this.funcsCount;
  292.  
  293.         this.methods[funcName] = function() {
  294.           func.apply(this, arguments);
  295.           delete this.methods[funcName];
  296.         }
  297.  
  298.         args[i] = {_func: this.funcsCount};
  299.       } else if (this.options.safe) {
  300.         args[i] = walkVar(args[i], false);
  301.       }
  302.     }
  303.  
  304.     waitFor(this, 'caller', function() {
  305.       w.fastXDM.on(this.id, function() {
  306.         getEnv(function(env) {
  307.           env.send(this, env.json.stringify([method, args]));
  308.         }, this);
  309.       }, this);
  310.     }, this);
  311.   }
  312.  
  313.   if (w.JSON && typeof(w.JSON) === 'object' && w.JSON.parse && w.JSON.stringify && w.JSON.stringify({a:[1,2,3]}).replace(/ /g, '') === '{"a":[1,2,3]}') {
  314.     env.json = {parse: w.JSON.parse, stringify: w.JSON.stringify};
  315.   } else {
  316.     w.fastXDM._needJSON = true;
  317.   }
  318.  
  319.   // PostMessage cover
  320.   if (w.postMessage) {
  321.     env.protocol = 'p';
  322.     env.send = function(xdm, strData) {
  323.       var win = (xdm.frame ? xdm.frame.contentWindow : xdm.caller);
  324.       if (win) {
  325.         try {
  326.           win.postMessage(xdm.key + ':' + strData, "*");
  327.         } catch(e) {
  328.           window.postMessage.call(win, xdm.key + ':' + strData, "*");
  329.         }
  330.       }
  331.     }
  332.  
  333.     if (w.addEventListener) {
  334.       w.addEventListener("message", w.fastXDM.onMessage, false);
  335.     } else {
  336.       w.attachEvent("onmessage", w.fastXDM.onMessage);
  337.     }
  338.  
  339.     if (w.fastXDM._needJSON) {
  340.       w.fastXDM._onlyJSON = true;
  341.       attachScript();
  342.     } else {
  343.       envLoaded();
  344.     }
  345.   } else {
  346.     attachScript();
  347.   }
  348. })(window);
  349.  
  350. if (!window.VK) window.VK = {};
  351.  
  352. /*
  353.  * Based on JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  354.  * Copyright (C) Paul Johnston 1999 - 2009
  355.  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  356.  * Distributed under the BSD License
  357.  */
  358. if(!VK.MD5){VK.MD5=function(n){var j=function(o,r){var q=(o&65535)+(r&65535),p=(o>>16)+(r>>16)+(q>>16);return(p<<16)|(q&65535)},g=function(o,p){return(o<<p)|(o>>>(32-p))},k=function(w,r,p,o,v,u){return j(g(j(j(r,w),j(o,u)),v),p)},a=function(q,p,w,v,o,u,r){return k((p&w)|((~p)&v),q,p,o,u,r)},h=function(q,p,w,v,o,u,r){return k((p&v)|(w&(~v)),q,p,o,u,r)},c=function(q,p,w,v,o,u,r){return k(p^w^v,q,p,o,u,r)},m=function(q,p,w,v,o,u,r){return k(w^(p|(~v)),q,p,o,u,r)},b=function(A,u){var z=1732584193,y=-271733879,w=-1732584194,v=271733878,r,q,p,o;A[u>>5]|=128<<((u)%32);A[(((u+64)>>>9)<<4)+14]=u;for(var t=0,s=A.length;t<s;t+=16){r=z;q=y;p=w;o=v;z=a(z,y,w,v,A[t+0],7,-680876936);v=a(v,z,y,w,A[t+1],12,-389564586);w=a(w,v,z,y,A[t+2],17,606105819);y=a(y,w,v,z,A[t+3],22,-1044525330);z=a(z,y,w,v,A[t+4],7,-176418897);v=a(v,z,y,w,A[t+5],12,1200080426);w=a(w,v,z,y,A[t+6],17,-1473231341);y=a(y,w,v,z,A[t+7],22,-45705983);z=a(z,y,w,v,A[t+8],7,1770035416);v=a(v,z,y,w,A[t+9],12,-1958414417);w=a(w,v,z,y,A[t+10],17,-42063);y=a(y,w,v,z,A[t+11],22,-1990404162);z=a(z,y,w,v,A[t+12],7,1804603682);v=a(v,z,y,w,A[t+13],12,-40341101);w=a(w,v,z,y,A[t+14],17,-1502002290);y=a(y,w,v,z,A[t+15],22,1236535329);z=h(z,y,w,v,A[t+1],5,-165796510);v=h(v,z,y,w,A[t+6],9,-1069501632);w=h(w,v,z,y,A[t+11],14,643717713);y=h(y,w,v,z,A[t+0],20,-373897302);z=h(z,y,w,v,A[t+5],5,-701558691);v=h(v,z,y,w,A[t+10],9,38016083);w=h(w,v,z,y,A[t+15],14,-660478335);y=h(y,w,v,z,A[t+4],20,-405537848);z=h(z,y,w,v,A[t+9],5,568446438);v=h(v,z,y,w,A[t+14],9,-1019803690);w=h(w,v,z,y,A[t+3],14,-187363961);y=h(y,w,v,z,A[t+8],20,1163531501);z=h(z,y,w,v,A[t+13],5,-1444681467);v=h(v,z,y,w,A[t+2],9,-51403784);w=h(w,v,z,y,A[t+7],14,1735328473);y=h(y,w,v,z,A[t+12],20,-1926607734);z=c(z,y,w,v,A[t+5],4,-378558);v=c(v,z,y,w,A[t+8],11,-2022574463);w=c(w,v,z,y,A[t+11],16,1839030562);y=c(y,w,v,z,A[t+14],23,-35309556);z=c(z,y,w,v,A[t+1],4,-1530992060);v=c(v,z,y,w,A[t+4],11,1272893353);w=c(w,v,z,y,A[t+7],16,-155497632);y=c(y,w,v,z,A[t+10],23,-1094730640);z=c(z,y,w,v,A[t+13],4,681279174);v=c(v,z,y,w,A[t+0],11,-358537222);w=c(w,v,z,y,A[t+3],16,-722521979);y=c(y,w,v,z,A[t+6],23,76029189);z=c(z,y,w,v,A[t+9],4,-640364487);v=c(v,z,y,w,A[t+12],11,-421815835);w=c(w,v,z,y,A[t+15],16,530742520);y=c(y,w,v,z,A[t+2],23,-995338651);z=m(z,y,w,v,A[t+0],6,-198630844);v=m(v,z,y,w,A[t+7],10,1126891415);w=m(w,v,z,y,A[t+14],15,-1416354905);y=m(y,w,v,z,A[t+5],21,-57434055);z=m(z,y,w,v,A[t+12],6,1700485571);v=m(v,z,y,w,A[t+3],10,-1894986606);w=m(w,v,z,y,A[t+10],15,-1051523);y=m(y,w,v,z,A[t+1],21,-2054922799);z=m(z,y,w,v,A[t+8],6,1873313359);v=m(v,z,y,w,A[t+15],10,-30611744);w=m(w,v,z,y,A[t+6],15,-1560198380);y=m(y,w,v,z,A[t+13],21,1309151649);z=m(z,y,w,v,A[t+4],6,-145523070);v=m(v,z,y,w,A[t+11],10,-1120210379);w=m(w,v,z,y,A[t+2],15,718787259);y=m(y,w,v,z,A[t+9],21,-343485551);z=j(z,r);y=j(y,q);w=j(w,p);v=j(v,o)}return[z,y,w,v]},f=function(r){var q="",s=-1,p=r.length,o,t;while(++s<p){o=r.charCodeAt(s);t=s+1<p?r.charCodeAt(s+1):0;if(55296<=o&&o<=56319&&56320<=t&&t<=57343){o=65536+((o&1023)<<10)+(t&1023);s++}if(o<=127){q+=String.fromCharCode(o)}else{if(o<=2047){q+=String.fromCharCode(192|((o>>>6)&31),128|(o&63))}else{if(o<=65535){q+=String.fromCharCode(224|((o>>>12)&15),128|((o>>>6)&63),128|(o&63))}else{if(o<=2097151){q+=String.fromCharCode(240|((o>>>18)&7),128|((o>>>12)&63),128|((o>>>6)&63),128|(o&63))}}}}}return q},e=function(p){var o=Array(p.length>>2),r,q;for(r=0,q=o.length;r<q;r++){o[r]=0}for(r=0,q=p.length*8;r<q;r+=8){o[r>>5]|=(p.charCodeAt(r/8)&255)<<(r%32)}return o},l=function(p){var o="";for(var r=0,q=p.length*32;r<q;r+=8){o+=String.fromCharCode((p[r>>5]>>>(r%32))&255)}return o},d=function(o){return l(b(e(o),o.length*8))},i=function(q){var t="0123456789abcdef",p="",o;for(var s=0,r=q.length;s<r;s++){o=q.charCodeAt(s);p+=t.charAt((o>>>4)&15)+t.charAt(o&15)}return p};return i(d(f(n)))}}
  359.  
  360. /*
  361.  * VKontakte Open API JavaScript library
  362.  * http://vk.com/
  363.  */
  364.  
  365. VK.extend = function(target, source, overwrite) {
  366.   for (var key in source) {
  367.     if (overwrite || typeof target[key] === 'undefined') {
  368.       target[key] = source[key];
  369.     }
  370.   }
  371.   return target;
  372. };
  373.  
  374. VK._protocol = 'https:';
  375.  
  376. if (!VK.xdConnectionCallbacks) {
  377.  
  378.   VK.extend(VK, {
  379.     version: 1,
  380.     _apiId: null,
  381.     _session: null,
  382.     _userStatus: 'unknown',
  383.     _domain: {
  384.       main: 'https://oauth.vk.com/',
  385.       api: 'https://api.vk.com/'
  386.     },
  387.     _path: {
  388.       login: 'authorize',
  389.       proxy: 'fxdm_oauth_proxy.html'
  390.     },
  391.     _rootId: 'vk_api_transport',
  392.     _nameTransportPath: '',
  393.     xdReady: false,
  394.     access: {
  395.       FRIENDS:   0x2,
  396.       PHOTOS:    0x4,
  397.       AUDIO:     0x8,
  398.       VIDEO:     0x10,
  399.       MATCHES:   0x20,
  400.       QUESTIONS: 0x40,
  401.       WIKI:      0x80
  402.     }
  403.   });
  404.  
  405.   VK.init = function(options) {
  406.     var body, root;
  407.  
  408.     VK._apiId = null;
  409.     if (!options.apiId) {
  410.       throw Error('VK.init() called without an apiId');
  411.     }
  412.     VK._apiId = options.apiId;
  413.  
  414.     if (options.onlyWidgets) return true;
  415.  
  416.     if (options.nameTransportPath && options.nameTransportPath !== '') {
  417.       VK._nameTransportPath = options.nameTransportPath;
  418.     }
  419.  
  420.     root = document.getElementById(VK._rootId);
  421.     if (!root) {
  422.       root = document.createElement('div');
  423.       root.id = VK._rootId;
  424.       body = document.getElementsByTagName('body')[0];
  425.       body.insertBefore(root, body.childNodes[0]);
  426.     }
  427.     root.style.position = 'absolute';
  428.     root.style.top = '-10000px';
  429.  
  430.     var session = VK.Cookie.load();
  431.     if (session) {
  432.       VK.Auth._loadState = 'loaded';
  433.       VK.Auth.setSession(session, session ? 'connected' : 'unknown');
  434.     }
  435.   };
  436.  
  437.   if (!VK.Cookie) {
  438.     VK.Cookie = {
  439.       _domain: null,
  440.       load: function() {
  441.         var cookie = document.cookie.match('\\bvk_app_' + VK._apiId + '=([^;]*)\\b')
  442.         var session;
  443.  
  444.         if (cookie) {
  445.           session = this.decode(cookie[1]);
  446.           if (session.secret != 'oauth') {
  447.             return false;
  448.           }
  449.           session.expire = parseInt(session.expire, 10);
  450.           VK.Cookie._domain = '.' + window.location.hostname;//session.base_domain;
  451.         }
  452.  
  453.         return session;
  454.       },
  455.       setRaw: function(val, ts, domain, time) {
  456.         var rawCookie;
  457.         rawCookie = 'vk_app_' + VK._apiId + '=' + val + '';
  458.         var exp = time ? (new Date().getTime() + time * 1000) : ts * 1000;
  459.         rawCookie += (val && ts === 0 ? '' : '; expires=' + new Date(exp).toGMTString());
  460.         rawCookie += '; path=/';
  461.         rawCookie += (domain ? '; domain=.' + domain : '');
  462.         document.cookie = rawCookie;
  463.  
  464.         this._domain = domain;
  465.       },
  466.       set: function(session, resp) {
  467.         if (session) {
  468.           this.setRaw(this.encode(session), session.expire, window.location.hostname, (resp || {}).time);
  469.         } else {
  470.           this.clear();
  471.         }
  472.       },
  473.       clear: function() {
  474.         this.setRaw('', 0, this._domain, 0);
  475.       },
  476.       encode: function(params) {
  477.         var
  478.             pairs = [],
  479.             key;
  480.  
  481.         for (key in params) {
  482.           if (key != 'user') pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  483.         }
  484.         pairs.sort();
  485.  
  486.         return pairs.join('&');
  487.       },
  488.       decode: function(str) {
  489.         var
  490.             params = {},
  491.             parts = str.split('&'),
  492.             i,
  493.             pair;
  494.  
  495.         for (i=0; i < parts.length; i++) {
  496.           pair = parts[i].split('=', 2);
  497.           if (pair && pair[0]) {
  498.             params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  499.           }
  500.         }
  501.  
  502.         return params;
  503.       }
  504.     };
  505.   }
  506.  
  507.   if (!VK.Api) {
  508.     VK.Api = {
  509.       _headId: null,
  510.       _callbacks: {},
  511.  
  512.       ie6_7: function() {
  513.         if (!VK.Api.ieTested) {
  514.           VK.Api.isIE6_7 = navigator.userAgent.match(/MSIE [6|7]/i);
  515.           VK.Api.ieTested = true;
  516.         }
  517.         return VK.Api.isIE6_7;
  518.       },
  519.  
  520.       supportCORS: function() {
  521.         var xhr = new XMLHttpRequest();
  522.         if ("withCredentials" in xhr) {
  523.           return true;
  524.         }
  525.  
  526.         if (typeof XDomainRequest != "undefined") {
  527.           return true;
  528.         }
  529.  
  530.         return false;
  531.       },
  532.  
  533.       makeRequest: function(url, cb) {
  534.         var xhr = VK.Api.createRequest('GET', url);
  535.         if (!xhr) {
  536.           return false;
  537.         }
  538.  
  539.         xhr.onload = function() {
  540.           var text = xhr.responseText;
  541.           if (xhr.status === 200) {
  542.             cb(text);
  543.           } else {
  544.             try {
  545.               console.error('Open api access error', xhr.response);
  546.             } catch(e) {
  547.               //nop
  548.             }
  549.           }
  550.         };
  551.  
  552.         xhr.onerror = function() {
  553.           try {
  554.             console.error('Open api access error');
  555.           } catch(e) {
  556.             //nop
  557.           }
  558.         };
  559.  
  560.         xhr.send();
  561.         return true;
  562.       },
  563.  
  564.       createRequest: function(method, url) {
  565.         var xhr = new XMLHttpRequest();
  566.  
  567.         if ("withCredentials" in xhr) {
  568.           // XHR for Chrome/Firefox/Opera/Safari.
  569.           xhr.open(method, url, true);
  570.           xhr.withCredentials = true;
  571.         } else if (typeof XDomainRequest != "undefined") {
  572.           // XDomainRequest for IE.
  573.           xhr = new XDomainRequest();
  574.           xhr.open(method, url);
  575.           xhr.withCredentials = true;
  576.         } else {
  577.           // CORS not supported.
  578.           xhr = null;
  579.         }
  580.  
  581.         return xhr;
  582.       },
  583.  
  584.       attachScript: function(url) {
  585.         if (!VK.Api._headId) VK.Api._headId = document.getElementsByTagName("head")[0];
  586.         var newScript = document.createElement('script');
  587.         newScript.type = 'text/javascript';
  588.         newScript.setAttribute('encoding', 'UTF-8');
  589.         newScript.src = url;
  590.         VK.Api._headId.appendChild(newScript);
  591.       },
  592.  
  593.       checkMethod: function(method, params, cb, queryTry) {
  594.         var m = method.toLowerCase();
  595.         if (m == 'wall.post' || m == 'activity.set') {
  596.           var text = (m == 'activity.set') ? params.text : params.message;
  597.           if (!text) {
  598.             text = '';
  599.           }
  600.           var query =  VK._protocol + '//vk.com/al_apps.php?act=wall_post_box&widget=4&method='+m+'&aid=' + parseInt(VK._apiId, 10) + '&text=' + encodeURIComponent(text);
  601.           if (m == 'wall.post') {
  602.             query += '&owner_id=' + parseInt(params.owner_id || 0, 10) + '&attachments=' + (params.attachments || params.attachment || '') + '&publish_date=' + (params.publish_date || '');
  603.           }
  604.           var method_access = '_'+(Math.random()).toString(16).substr(2);
  605.           query += '&method_access='+method_access;
  606.           var popup = VK.UI.popup({
  607.             url: query,
  608.             width: 560,
  609.             height: 304
  610.           });
  611.           var timer = setInterval(function() {
  612.             if (VK.UI.active.closed) {
  613.               clearInterval(timer);
  614.               params.method_access = method_access;
  615.               VK.Api.call(method, params, cb, queryTry);
  616.             }
  617.           }, 500);
  618.           return false;
  619.         }
  620.  
  621.         if (m == 'messages.allowmessagesfromgroup') {
  622.           var method_access = '_' + (Math.random()).toString(16).substr(2);
  623.           var query = VK._protocol + '//vk.com/widget_allow_messages_from_community.php?act=allow_box&group_id=' + parseInt(params.group_id, 10) + '&app_id=' + parseInt(VK._apiId, 10) + '&method_access=' + method_access;
  624.  
  625.           VK.UI.popup({
  626.             url: query,
  627.             width: 560,
  628.             height: 304
  629.           });
  630.  
  631.           var timer = setInterval(function () {
  632.             if (VK.UI.active.closed) {
  633.               clearInterval(timer);
  634.               params.method_access = method_access;
  635.               VK.Api.call(method, params, cb, queryTry);
  636.             }
  637.           }, 500);
  638.  
  639.           return false;
  640.         }
  641.  
  642.         return true;
  643.       },
  644.  
  645.       call: function(method, params, cb, queryTry) {
  646.         var
  647.             query = params || {},
  648.             qs,
  649.             responseCb;
  650.  
  651.         if (typeof query != 'object' || typeof cb != 'function') {
  652.           return false;
  653.         }
  654.         if (!params.method_access && !params.method_force && !VK.Api.checkMethod(method, params, cb, queryTry)) {
  655.           return;
  656.         }
  657.  
  658.         if (!queryTry) queryTry = 0;
  659.  
  660.         if (VK.Auth._loadState != 'loaded') {
  661.           var authFunc = function(result) {
  662.             if (result && result.session) {
  663.               VK.Observer.unsubscribe('auth.loginStatus', authFunc);
  664.               VK.Api.call(method, params, cb);
  665.             }
  666.           };
  667.           VK.Observer.subscribe('auth.loginStatus', authFunc);
  668.           VK.Auth.getLoginStatus();
  669.           return;
  670.         }
  671.  
  672.         if (VK.Api.queryLength(query) < 1500 && !VK.Api.ie6_7()) {
  673.           var useXDM = false;
  674.           var rnd = parseInt(Math.random() * 10000000, 10);
  675.           while (VK.Api._callbacks[rnd]) {
  676.             rnd = parseInt(Math.random() * 10000000, 10)
  677.           }
  678.           query.callback = 'VK.Api._callbacks['+rnd+']';
  679.         } else {
  680.           var useXDM = true;
  681.         }
  682.  
  683.         if (VK._session && VK._session.sid) {
  684.           query.access_token = VK._session.sid;
  685.         }
  686.  
  687.         qs = VK.Cookie.encode(query);
  688.  
  689.         responseCb = function(response) {
  690.           if (response.error && (response.error.error_code == 3 || response.error.error_code == 4 || response.error.error_code == 5)) {
  691.             if (queryTry > 3) return false;
  692.             var repeatCall = function(resp) {
  693.               VK.Observer.unsubscribe('auth.sessionChange', repeatCall);
  694.               delete params.access_token;
  695.               if (resp.session) VK.Api.call(method, params, cb, queryTry + 1);
  696.             }
  697.             VK.Observer.subscribe('auth.sessionChange', repeatCall);
  698.             VK.Auth.getLoginStatus();
  699.           } else {
  700.             cb(response);
  701.           }
  702.           if (!useXDM) delete VK.Api._callbacks[rnd];
  703.         };
  704.  
  705.         if (useXDM) {
  706.           if (VK.xdReady) {
  707.             VK.XDM.remote.callMethod('apiCall', method, qs, responseCb);
  708.           } else {
  709.             VK.Observer.subscribe('xdm.init', function() {
  710.               VK.XDM.remote.callMethod('apiCall', method, qs, responseCb);
  711.             });
  712.             VK.XDM.init();
  713.           }
  714.         } else {
  715.           VK.Api._callbacks[rnd] = responseCb;
  716.           VK.Api.attachScript(VK._domain.api + 'method/' + method +'?' + qs);
  717.         }
  718.       },
  719.  
  720.       queryLength: function(query) {
  721.         var len = 100, i; // sid + sig
  722.         for (i in query) {
  723.           len += i.length + encodeURIComponent(query[i]).length + 1;
  724.         }
  725.         return len;
  726.       }
  727.     };
  728.  
  729. // Alias
  730.     VK.api = function(method, params, cb) {VK.Api.call(method, params, cb);}
  731.   };
  732.  
  733.   if (!VK.Auth) {
  734.     VK.Auth = {
  735.       popup: null,
  736.       lsCb: {},
  737.  
  738.       setSession: function(session, status, settings, resp) {
  739.         var
  740.             login = !VK._session && session,
  741.             logout = VK._session && !session,
  742.             both = VK._session && session && VK._session.mid != session.mid,
  743.             sessionChange = login || logout || (VK._session && session && VK._session.sid != session.sid),
  744.             statusChange = status != VK._userStatus,
  745.             response = {
  746.               'session': session,
  747.               'status': status,
  748.               'settings': settings
  749.             };
  750.  
  751.         VK._session = session;
  752.  
  753.         VK._userStatus = status;
  754.  
  755.         VK.Cookie.set(session, resp);
  756.  
  757.         if (sessionChange || statusChange || both) {
  758.           setTimeout(function() {
  759.             if (statusChange) {
  760.               VK.Observer.publish('auth.statusChange', response);
  761.             }
  762.  
  763.             if (logout || both) {
  764.               VK.Observer.publish('auth.logout', response);
  765.             }
  766.  
  767.             if (login || both) {
  768.               VK.Observer.publish('auth.login', response);
  769.             }
  770.  
  771.             if (sessionChange) {
  772.               VK.Observer.publish('auth.sessionChange', response);
  773.             }
  774.           }, 0);
  775.         }
  776.  
  777.         return response;
  778.       },
  779.  
  780.       // Public VK.Auth methods
  781.       login: function(cb, settings) {
  782.         if (!VK._apiId) {
  783.           return false;
  784.         }
  785.  
  786.         var url = VK._domain.main + VK._path.login + '?client_id='+VK._apiId+'&display=popup&redirect_uri=close.html&response_type=token';
  787.         if (settings && parseInt(settings, 10) > 0) {
  788.           url += '&scope=' + settings;
  789.         }
  790.  
  791.         VK.Observer.unsubscribe('auth.onLogin');
  792.         VK.Observer.subscribe('auth.onLogin', cb);
  793.  
  794.         VK.UI.popup({
  795.           width: 665,
  796.           height: 370,
  797.           url: url
  798.         });
  799.  
  800.         var authCallback = function() {
  801.           VK.Auth.getLoginStatus(function(resp) {
  802.             VK.Observer.publish('auth.onLogin', resp);
  803.             VK.Observer.unsubscribe('auth.onLogin');
  804.           }, true);
  805.         }
  806.  
  807.         VK.UI.popupOpened = true;
  808.         var popupCheck = function() {
  809.           if (!VK.UI.popupOpened) {
  810.             return false;
  811.           }
  812.  
  813.           try {
  814.             if (!VK.UI.active.top || VK.UI.active.closed) {
  815.               VK.UI.popupOpened = false;
  816.               authCallback();
  817.               return true;
  818.             }
  819.           } catch(e) {
  820.             VK.UI.popupOpened = false;
  821.             authCallback();
  822.             return true;
  823.           }
  824.           setTimeout(popupCheck, 100);
  825.         };
  826.  
  827.         setTimeout(popupCheck, 100);
  828.       },
  829.  
  830.       // Logout user from app, vk.com & login.vk.com
  831.       logout: function(cb) {
  832.         VK.Auth.revokeGrants(cb);
  833.       },
  834.  
  835.       revokeGrants: function(cb) {
  836.         var onLogout = function(resp) {
  837.           VK.Observer.unsubscribe('auth.statusChange', onLogout);
  838.           if (cb) {
  839.             cb(resp);
  840.           }
  841.         }
  842.  
  843.         VK.Observer.subscribe('auth.statusChange', onLogout);
  844.         if (VK._session && VK._session.sid) {
  845.           var url = 'https://login.vk.com/?act=openapi&oauth=1&aid=' + parseInt(VK._apiId, 10) + '&location=' + encodeURIComponent(window.location.hostname) + '&do_logout=1&token=' + VK._session.sid;
  846.           if (VK.Api.supportCORS()) {
  847.             var logoutCallback = function() {
  848.               VK.Auth.setSession(null, 'unknown');
  849.             };
  850.  
  851.             VK.Api.makeRequest(url + '&new=1', logoutCallback);
  852.           } else {
  853.             VK.Api.attachScript(url);
  854.           }
  855.         }
  856.  
  857.         VK.Cookie.clear();
  858.       },
  859.  
  860.       // Get current login status from session (sync) (not use on load time)
  861.       getSession: function() {
  862.         return VK._session;
  863.       },
  864.  
  865.       // Get current login status from vk.com (async)
  866.       getLoginStatus: function(cb, force) {
  867.         if (!VK._apiId) {
  868.           return;
  869.         }
  870.  
  871.         if (cb) {
  872.           if (!force && VK.Auth._loadState == 'loaded') {
  873.             cb({status: VK._userStatus, session: VK._session});
  874.             return;
  875.           } else {
  876.             VK.Observer.subscribe('auth.loginStatus', cb);
  877.           }
  878.         }
  879.  
  880.         if (!force && VK.Auth._loadState == 'loading') {
  881.           return;
  882.         }
  883.  
  884.         VK.Auth._loadState = 'loading';
  885.  
  886.         var url = 'https://login.vk.com/?act=openapi&oauth=1&aid=' + parseInt(VK._apiId, 10) + '&location=' + encodeURIComponent(window.location.hostname);
  887.         if (VK.Api.supportCORS()) {
  888.           var loginCallback = function(response) {
  889.             if (!this.JSON) {
  890.               this.JSON = {};
  891.             }
  892.  
  893.             if (typeof JSON.parse !== 'function') {
  894.               //IE6 and IE7
  895.               response = eval(response);
  896.             } else {
  897.               response = JSON.parse(response);
  898.             }
  899.  
  900.             VK.Auth._loadState = 'loaded';
  901.             if (response && response.auth) {
  902.               var session = {
  903.                 mid: response.user.id,
  904.                 sid: response.access_token,
  905.                 sig: response.sig,
  906.                 secret: response.secret,
  907.                 expire: response.expire
  908.               };
  909.  
  910.               if (force) {
  911.                 session.user = response.user;
  912.               }
  913.  
  914.               var status = 'connected';
  915.             } else {
  916.               var session = null;
  917.               var status = response.user ? 'not_authorized' : 'unknown';
  918.               VK.Cookie.clear();
  919.             }
  920.  
  921.             VK.Auth.setSession(session, status, false, response);
  922.             VK.Observer.publish('auth.loginStatus', {session: session, status: status});
  923.             VK.Observer.unsubscribe('auth.loginStatus');
  924.           };
  925.  
  926.           VK.Api.makeRequest(url + '&new=1', loginCallback);
  927.         } else {
  928.           var rnd = parseInt(Math.random() * 10000000, 10);
  929.           while (VK.Auth.lsCb[rnd]) {
  930.             rnd = parseInt(Math.random() * 10000000, 10);
  931.           }
  932.  
  933.           VK.Auth.lsCb[rnd] = function(response) {
  934.             delete VK.Auth.lsCb[rnd];
  935.             VK.Auth._loadState = 'loaded';
  936.             if (response && response.auth) {
  937.               var session = {
  938.                 mid: response.user.id,
  939.                 sid: response.access_token,
  940.                 sig: response.sig,
  941.                 secret: response.secret,
  942.                 expire: response.expire
  943.               };
  944.               if (force) session.user = response.user;
  945.               var status = 'connected';
  946.             } else {
  947.               var session = null;
  948.               var status = response.user ? 'not_authorized' : 'unknown';
  949.               VK.Cookie.clear();
  950.             }
  951.             VK.Auth.setSession(session, status, false, response);
  952.             VK.Observer.publish('auth.loginStatus', {session: session, status: status});
  953.             VK.Observer.unsubscribe('auth.loginStatus');
  954.           };
  955.  
  956.             // AttachScript here
  957.           VK.Api.attachScript(url+'&rnd='+rnd);
  958.         }
  959.       }
  960.     };
  961.   }
  962.  
  963. } else { // if VK.xdConnectionCallbacks
  964.   setTimeout(function() {
  965.     var callback;
  966.     while (callback = VK.xdConnectionCallbacks.pop()) {
  967.       callback();
  968.     }
  969.   }, 0);
  970.   if (VK.Widgets && !VK.Widgets._constructor) {
  971.     VK.Widgets = false;
  972.   }
  973. }
  974.  
  975. if (!VK.UI) {
  976.   VK.UI = {
  977.     active: null,
  978.     _buttons: [],
  979.     popup: function(options) {
  980.       var
  981.           screenX = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
  982.           screenY = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
  983.           outerWidth = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
  984.           outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
  985.           width = options.width,
  986.           height = options.height,
  987.           left = parseInt(screenX + ((outerWidth - width) / 2), 10),
  988.           top = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
  989.           features = (
  990.               'width=' + width +
  991.               ',height=' + height +
  992.               ',left=' + left +
  993.               ',top=' + top
  994.           );
  995.       this.active = window.open(options.url, 'vk_openapi', features);
  996.     },
  997.     button: function(el, handler) {
  998.       var html = '';
  999.  
  1000.       if (typeof el == 'string') {
  1001.         el = document.getElementById(el);
  1002.       }
  1003.  
  1004.  
  1005.       this._buttons.push(el);
  1006.       index = this._buttons.length - 1;
  1007.  
  1008.       html = (
  1009.           '<table cellspacing="0" cellpadding="0" id="openapi_UI_' + index + '" onmouseover="VK.UI._change(1, ' + index + ');" onmouseout="VK.UI._change(0, ' + index + ');" onmousedown="VK.UI._change(2, ' + index + ');" onmouseup="VK.UI._change(1, ' + index + ');" style="cursor: pointer; border: 0px; font-family: tahoma, arial, verdana, sans-serif, Lucida Sans; font-size: 10px;"><tr style="vertical-align: middle">' +
  1010.           '<td><div style="border: 1px solid #3b6798;border-radius: 2px 0px 0px 2px;-moz-border-radius: 2px 0px 0px 2px;-webkit-border-radius: 2px 0px 0px 2px;"><div style="border: 1px solid #5c82ab; border-top-color: #7e9cbc; background-color: #6D8DB1; color: #fff; text-shadow: 0px 1px #45688E; height: 15px; padding: 2px 4px 0px 6px;line-height: 13px;">&#1042;&#1086;&#1081;&#1090;&#1080;</div></div></td>' +
  1011.           '<td><div style="background: url(' + VK._protocol + '//vk.com/images/btns.png) 0px -42px no-repeat; width: 21px; height: 21px"></div></td>' +
  1012.           '<td><div style="border: 1px solid #3b6798;border-radius: 0px 2px 2px 0px;-moz-border-radius: 0px 2px 2px 0px;-webkit-border-radius: 0px 2px 2px 0px;"><div style="border: 1px solid #5c82ab; border-top-color: #7e9cbc; background-color: #6D8DB1; color: #fff; text-shadow: 0px 1px #45688E; height: 15px; padding: 2px 6px 0px 4px;line-height: 13px;">&#1050;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1077;</div></div></td>' +
  1013.           '</tr></table>'
  1014.       );
  1015.       el.innerHTML = html;
  1016.       el.style.width = el.childNodes[0].offsetWidth + 'px';
  1017.     },
  1018.     _change: function(state, index) {
  1019.       var row = document.getElementById('openapi_UI_' + index).rows[0];
  1020.       var elems = [row.cells[0].firstChild.firstChild, row.cells[2].firstChild.firstChild];
  1021.       for (var i = 0; i < 2; ++i) {
  1022.         var elem = elems[i];
  1023.         if (state === 0) {
  1024.           elem.style.backgroundColor = '#6D8DB1';
  1025.           elem.style.borderTopColor = '#7E9CBC';
  1026.           elem.style.borderLeftColor = elem.style.borderRightColor = elem.style.borderBottomColor = '#5C82AB';
  1027.         } else if (state == 1) {
  1028.           elem.style.backgroundColor = '#7693B6';
  1029.           elem.style.borderTopColor = '#88A4C4';
  1030.           elem.style.borderLeftColor = elem.style.borderRightColor = elem.style.borderBottomColor = '#6088B4';
  1031.         } else if (state == 2) {
  1032.           elem.style.backgroundColor = '#6688AD';
  1033.           elem.style.borderBottomColor = '#7495B8';
  1034.           elem.style.borderLeftColor = elem.style.borderRightColor = elem.style.borderTopColor = '#51779F';
  1035.         }
  1036.       }
  1037.       if (state === 0 || state == 2) {
  1038.         row.cells[2].firstChild.style.backgroundPosition = '0px -42px';
  1039.       } else if (state == 1) {
  1040.         row.cells[2].firstChild.style.backgroundPosition = '0px -63px';
  1041.       }
  1042.     }
  1043.   };
  1044. }
  1045.  
  1046. if (!VK.XDM) {
  1047.   VK.XDM = {
  1048.     remote: null,
  1049.     init: function() {
  1050.       if (this.remote) return false;
  1051.       var url = VK._domain.api + VK._path.proxy;
  1052.       this.remote = new fastXDM.Server({
  1053.         onInit: function() {
  1054.           VK.xdReady = true;
  1055.           VK.Observer.publish('xdm.init');
  1056.         }
  1057.       });
  1058.  
  1059.       this.remote.append(document.getElementById(VK._rootId), {
  1060.         src: url
  1061.       });
  1062.     },
  1063.     xdHandler: function(code) {
  1064.       try {
  1065.         eval('VK.' + code);
  1066.       } catch(e) {}
  1067.     }
  1068.   };
  1069. }
  1070.  
  1071. if (!VK.Observer) {
  1072.   VK.Observer = {
  1073.     _subscribers: function() {
  1074.       if (!this._subscribersMap) {
  1075.         this._subscribersMap = {};
  1076.       }
  1077.       return this._subscribersMap;
  1078.     },
  1079.     publish: function(eventName) {
  1080.       var
  1081.           args = Array.prototype.slice.call(arguments),
  1082.           eventName = args.shift(),
  1083.           subscribers = this._subscribers()[eventName],
  1084.           i, j;
  1085.  
  1086.       if (!subscribers) return;
  1087.  
  1088.       for (i = 0, j = subscribers.length; i < j; i++) {
  1089.         if (subscribers[i] != null) {
  1090.           subscribers[i].apply(this, args);
  1091.         }
  1092.       }
  1093.     },
  1094.     subscribe: function(eventName, handler) {
  1095.       var
  1096.           subscribers = this._subscribers();
  1097.  
  1098.       if (typeof handler != 'function') return false;
  1099.  
  1100.       if (!subscribers[eventName]) {
  1101.         subscribers[eventName] = [handler];
  1102.       } else {
  1103.         subscribers[eventName].push(handler);
  1104.       }
  1105.     },
  1106.     unsubscribe: function(eventName, handler) {
  1107.       var
  1108.           subscribers = this._subscribers()[eventName],
  1109.           i, j;
  1110.  
  1111.       if (!subscribers) return false;
  1112.       if (typeof handler == 'function') {
  1113.         for (i = 0, j = subscribers.length; i < j; i++) {
  1114.           if (subscribers[i] == handler) {
  1115.             subscribers[i] = null;
  1116.           }
  1117.         }
  1118.       } else {
  1119.         delete this._subscribers()[eventName];
  1120.       }
  1121.     }
  1122.   };
  1123. }
  1124.  
  1125. if (!VK.Widgets) {
  1126.   VK.Widgets = {};
  1127.  
  1128.   VK.Widgets.count = 0;
  1129.   VK.Widgets.RPC = {};
  1130.  
  1131.   VK.Widgets.showBoxUrl = function(domain, url) {
  1132.     domain = (domain || VK._protocol + '//vk.com').replace(/\/?\s*$/, '');
  1133.     url = url.replace(/^\s*\/?/, '');
  1134.     return domain + '/' + url;
  1135.   };
  1136.  
  1137.   VK.Widgets.loading = function(obj, enabled) {
  1138.     obj.style.background = enabled ? 'url("' + VK._protocol + '//vk.com/images/upload.gif") center center no-repeat transparent' : 'none';
  1139.   };
  1140.  
  1141.   VK.Widgets.Comments = function(objId, options, page) {
  1142.     var pData = VK.Util.getPageData();
  1143.     if (!VK._apiId) throw Error('VK not initialized. Please use VK.init');
  1144.     options = options || {};
  1145.     var params = {
  1146.       limit: options.limit || 10,
  1147.       height: options.height || 0,
  1148.       mini: options.mini === undefined ? 'auto' : options.mini,
  1149.       norealtime: options.norealtime ? 1 : 0
  1150.     }, mouseup = function() {
  1151.       rpc.callMethod('mouseUp');
  1152.       return false;
  1153.     }, move = function(event) {
  1154.       rpc.callMethod('mouseMove', {screenY: event.screenY});
  1155.     }, iframe, rpc;
  1156.  
  1157.     if (options.browse) { // browse all comments
  1158.       params.browse = 1;
  1159.       params.replies = options.replies || 0;
  1160.     } else { // page
  1161.       var url = options.pageUrl || pData.url;
  1162.       if (url.substr(0, 1) == '/') {
  1163.         url = (location.protocol + '//' + location.host) + url;
  1164.       }
  1165.       VK.extend(params, {
  1166.         page: page || 0,
  1167.         status_publish: options.autoPublish === undefined ? 1 : options.autoPublish,
  1168.         attach: options.attach === undefined ? '*' : (options.attach ? options.attach : ''),
  1169.         url: url,
  1170.         title: options.pageTitle || pData.title,
  1171.         description: options.pageDescription || pData.description,
  1172.         image: options.pageImage || pData.image
  1173.       });
  1174.     }
  1175.     if (options.onChange) { // DEPRECATED
  1176.       VK.Observer.subscribe('widgets.comments.new_comment', options.onChange);
  1177.       VK.Observer.subscribe('widgets.comments.delete_comment', options.onChange);
  1178.     }
  1179.  
  1180.     return VK.Widgets._constructor('widget_comments.php', objId, options, params, {
  1181.       showBox: function(url, props) {
  1182.         var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1183.           proxy: function() {
  1184.             rpc.callMethod.apply(rpc, arguments);
  1185.           }
  1186.         });
  1187.         box.show();
  1188.       },
  1189.       startDrag: function() {
  1190.         cursorBack = window.document.body.style.cursor;
  1191.         window.document.body.style.cursor = 'pointer';
  1192.         VK.Util.addEvent('mousemove', move);
  1193.         VK.Util.addEvent('mouseup', mouseup);
  1194.       },
  1195.       stopDrag: function() {
  1196.         window.document.body.style.cursor = cursorBack;
  1197.         VK.Util.removeEvent('mousemove', move);
  1198.         VK.Util.removeEvent('mouseup', mouseup);
  1199.       }
  1200.     }, {
  1201.       startHeight: 133,
  1202.       minWidth: 300,
  1203.       width: '100%'
  1204.     }, function(o, i, r) {iframe = i; rpc = r;});
  1205.   };
  1206.  
  1207.   VK.Widgets.CommentsBrowse = function(objId, options) {
  1208.     options = options || {};
  1209.     options.browse = 1;
  1210.     return VK.Widgets.Comments(objId, options);
  1211.   };
  1212.  
  1213.   VK.Widgets.Recommended = function(objId, options) {
  1214.     var pData = VK.Util.getPageData();
  1215.     if (!VK._apiId) throw Error('VK not initialized. Please use VK.init');
  1216.     options = options || {};
  1217.     var params = {
  1218.       limit: options.limit || 5,
  1219.       max: options.max || 0,
  1220.       sort: options.sort || 'friend_likes',
  1221.       verb: options.verb || 0,
  1222.       period: options.period || 'week',
  1223.       target: options.target || 'parent'
  1224.     };
  1225.     return VK.Widgets._constructor('widget_recommended.php', objId, options, params, {}, {
  1226.       startHeight: (116 + params.limit * 47 - 15),
  1227.       minWidth: 150,
  1228.       width: '100%'
  1229.     });
  1230.   };
  1231.  
  1232.   VK.Widgets.Post = function(objId, ownerId, postId, hash, options) {
  1233.     options = options || {};
  1234.     var obj = document.getElementById(objId),
  1235.       params = {
  1236.         owner_id: ownerId,
  1237.         post_id: postId,
  1238.         hash: hash || '',
  1239.         width: options.width || (obj && obj.offsetWidth > 0 ? obj.offsetWidth : 500)
  1240.       }, iframe, rpc, cursorBack;
  1241.     if (options.preview) {
  1242.       params.preview = 1;
  1243.       delete options['preview'];
  1244.     }
  1245.     return VK.Widgets._constructor('widget_post.php', objId, options, params, {
  1246.       showBox: function(url, props) {
  1247.         var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1248.           proxy: function() {
  1249.             rpc.callMethod.apply(rpc, arguments);
  1250.           }
  1251.         });
  1252.         box.show();
  1253.       },
  1254.       startDrag: function() {
  1255.         cursorBack = window.document.body.style.cursor;
  1256.         window.document.body.style.cursor = 'pointer';
  1257.       },
  1258.       stopDrag: function() {
  1259.         window.document.body.style.cursor = cursorBack;
  1260.       }
  1261.     }, {
  1262.       startHeight: 90,
  1263.       minWidth: 250,
  1264.       width: '100%'
  1265.     }, function(o, i, r) {iframe = i; rpc = r;});
  1266.   };
  1267.  
  1268.   VK.Widgets.Like = (function(Like) {
  1269.     if (Like) return Like;
  1270.  
  1271.     var instances = [];
  1272.  
  1273.     Like = function(objId, options, page) {
  1274.       var pData = VK.Util.getPageData();
  1275.       if (!VK._apiId) throw Error('VK not initialized. Please use VK.init');
  1276.       options = VK.extend(options || {}, {allowTransparency: true});
  1277.       var verticalBtnHeightWidth = {
  1278.             18: 43,
  1279.             20: 47,
  1280.             22: 51,
  1281.             24: 55,
  1282.             30: 67,
  1283.           },
  1284.           type = (options.type == 'full' || options.type == 'button' || options.type == 'vertical' || options.type == 'mini') ? options.type : 'full',
  1285.           autoWidth = options.width === 'auto' && (type == 'button' || type == 'mini'),
  1286.           btnHeight = parseInt(options.height, 10) || 22,
  1287.           size = btnHeight && verticalBtnHeightWidth[btnHeight] ? btnHeight : 22,
  1288.           width = autoWidth ? 153 : (type == 'full' ? Math.max(200, options.width || 350) : (type == 'button' ? 180 : (type == 'mini' ? 115 : verticalBtnHeightWidth[size]))),
  1289.           height = type == 'vertical' ? (2 * btnHeight + 7) : btnHeight,
  1290.           params = {
  1291.             page: page || 0,
  1292.             url: options.pageUrl || pData.url,
  1293.             type: type,
  1294.             verb: options.verb == 1 ? 1 : 0,
  1295.             color: options.color || '',
  1296.             title: options.pageTitle || pData.title,
  1297.             description: options.pageDescription || pData.description,
  1298.             image: options.pageImage || pData.image,
  1299.             text: (options.text || '').substr(0, 140),
  1300.             h: btnHeight
  1301.           },
  1302.           ttHere = options.ttHere || false,
  1303.           isOver = false,
  1304.           hideTimeout = null,
  1305.           obj, buttonIfr, buttonRpc, tooltipIfr, tooltipRpc, checkTO, statsBox;
  1306.       if (type == 'vertical' || type == 'button' || type == 'mini') delete options.width;
  1307.       if (autoWidth) params.auto_width = 1;
  1308.       function showTooltip(force) {
  1309.         if ((!isOver && !force) || !tooltipRpc) return;
  1310.         if (!tooltipIfr || !tooltipRpc || tooltipIfr.style.display != 'none' && tooltipIfr.getAttribute('vkhidden') != 'yes') return;
  1311.         hideTimeout && clearTimeout(hideTimeout);
  1312.         checkTO && clearTimeout(checkTO);
  1313.         var scrollTop = options.getScrollTop ? options.getScrollTop() : (document.body.scrollTop || document.documentElement.scrollTop || 0);
  1314.         var objPos = VK.Util.getXY(obj, options.fixed);
  1315.         var startY = ttHere ? 0 : objPos[1];
  1316.         if (scrollTop > objPos[1] - 120 && options.tooltipPos != 'top' || type == 'vertical' || options.tooltipPos == 'bottom') {
  1317.           tooltipIfr.style.top = (startY + height + 2) + 'px';
  1318.           tooltipRpc.callMethod('show', false, type+'_'+size);
  1319.         } else {
  1320.           tooltipIfr.style.top = (startY - 128) + 'px';
  1321.           tooltipRpc.callMethod('show', true, type+'_'+size);
  1322.         }
  1323.         VK.Util.ss(tooltipIfr, {left: (ttHere ? 0 : objPos[0]) - (type == 'full' || type == 'button' ? 32 : 2) + 'px', display: 'block', opacity: 1, filter: 'none'});
  1324.         tooltipIfr.setAttribute('vkhidden', 'no');
  1325.         isOver = true;
  1326.       }
  1327.  
  1328.       function hideTooltip(force) {
  1329.         if ((isOver && !force) || !tooltipRpc) return;
  1330.         tooltipRpc.callMethod('hide');
  1331.         buttonRpc.callMethod('hide');
  1332.         hideTimeout = setTimeout(function() {
  1333.           tooltipIfr.style.display = 'none'
  1334.         }, 400);
  1335.       }
  1336.  
  1337.       function handleStatsBox(act) {
  1338.         hideTooltip(true);
  1339.         statsBox = VK.Util.Box(buttonIfr.src + '&act=a_stats_box&widget_width=638&from=wlike');
  1340.         statsBox.show();
  1341.       }
  1342.  
  1343.       var widgetId = VK.Widgets._constructor('widget_like.php', objId, options, params, {
  1344.         initTooltip: function(counter) {
  1345.           tooltipRpc = new fastXDM.Server({
  1346.             onInit: counter ? function() {
  1347.                 showTooltip();
  1348.               } : function() {},
  1349.             proxy: function() {
  1350.               buttonRpc.callMethod.apply(buttonRpc, arguments);
  1351.             },
  1352.             showBox: function(url, props) {
  1353.               var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [props.width, props.height], {
  1354.                 proxy: function() {
  1355.                   tooltipRpc.callMethod.apply(tooltipRpc, arguments);
  1356.                 }
  1357.               });
  1358.               box.show();
  1359.             },
  1360.             statsBox: handleStatsBox
  1361.           }, false, {safe: true});
  1362.           tooltipIfr = tooltipRpc.append(ttHere ? obj : document.body, {
  1363.             src: buttonIfr.src + '&act=a_like_tooltip',
  1364.             scrolling: 'no',
  1365.             allowTransparency: true,
  1366.             id: buttonIfr.id + '_tt',
  1367.             style: {position: 'absolute', padding: 0, display: 'block', opacity: 0.01, filter: 'alpha(opacity=1)', border: '0', width: '274px', height: '130px', zIndex: 5000, overflow: 'hidden'}
  1368.           });
  1369.           tooltipIfr.setAttribute('vkhidden', 'yes');
  1370.  
  1371.           tooltipIfr.onmouseover = function() {
  1372.             clearTimeout(checkTO);
  1373.             isOver = true;
  1374.           };
  1375.           tooltipIfr.onmouseout = function() {
  1376.             clearTimeout(checkTO);
  1377.             isOver = false;
  1378.             checkTO = setTimeout(function() {hideTooltip(); }, 200);
  1379.           };
  1380.         },
  1381.         statsBox: handleStatsBox,
  1382.         showTooltip: showTooltip,
  1383.         hideTooltip: hideTooltip,
  1384.         destroy: function() {
  1385.           buttonRpc.destroy();
  1386.           try {buttonIfr.src = 'about: blank;';} catch (e) {}
  1387.           buttonIfr.parentNode.removeChild(buttonIfr);
  1388.           if (tooltipIfr) {
  1389.             try {tooltipIfr.src = 'about: blank;';} catch (e) {}
  1390.             tooltipIfr.parentNode.removeChild(tooltipIfr);
  1391.           }
  1392.           tooltipRpc && tooltipRpc.destroy();
  1393.           if (statsBox) {
  1394.             if (statsBox.iframe) {
  1395.               try {statsBox.iframe.src = 'about: blank;';} catch (e) {}
  1396.               statsBox.iframe.parentNode.removeChild(statsBox.iframe);
  1397.             }
  1398.             statsBox.rpc && statsBox.rpc.destroy();
  1399.           }
  1400.         },
  1401.         showBox: function(url, props) {
  1402.           var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1403.             proxy: function() {
  1404.               buttonRpc.callMethod.apply(buttonRpc, arguments);
  1405.             }
  1406.           });
  1407.           box.show();
  1408.         },
  1409.         proxy: function() {if (tooltipRpc) tooltipRpc.callMethod.apply(tooltipRpc, arguments);}
  1410.       }, {
  1411.         startHeight: height,
  1412.         minWidth: width
  1413.       }, function(o, i, r) {
  1414.         buttonRpc = r;
  1415.         VK.Util.ss(obj = o, {height: height + 'px', width: width + 'px', position: 'relative', clear: 'both'});
  1416.         VK.Util.ss(buttonIfr = i, {height: height + 'px', width: width + 'px', overflow: 'hidden', zIndex: 150});
  1417.         obj.onmouseover = function() {
  1418.           clearTimeout(checkTO);
  1419.           isOver = true;
  1420.         };
  1421.         obj.onmouseout = function() {
  1422.           clearTimeout(checkTO);
  1423.           isOver = false;
  1424.           checkTO = setTimeout(function() {hideTooltip(); }, 200);
  1425.         };
  1426.       });
  1427.  
  1428.       instances.push(widgetId);
  1429.       return widgetId;
  1430.     };
  1431.  
  1432.     Like.destroyAll = function() {
  1433.       var xdm = null;
  1434.       while (instances[0]) {
  1435.         xdm = VK.Widgets.RPC[instances.pop()];
  1436.         xdm && xdm.methods.destroy();
  1437.       }
  1438.     }
  1439.  
  1440.     return Like;
  1441.   })(VK.Widgets.Like);
  1442.  
  1443.   VK.Widgets.Poll = function(objId, options, pollId) {
  1444.     var pData = VK.Util.getPageData();
  1445.     if (!pollId) throw Error('No poll id passed');
  1446.     options = options || {};
  1447.     var params = {
  1448.       poll_id: pollId,
  1449.       url: options.pageUrl || pData.url || location.href,
  1450.       title: options.pageTitle || pData.title,
  1451.       description: options.pageDescription || pData.description
  1452.     };
  1453.     return VK.Widgets._constructor('al_widget_poll.php', objId, options, params, {}, {
  1454.       startHeight: 144,
  1455.       minWidth: 300,
  1456.       width: '100%'
  1457.     });
  1458.   };
  1459.  
  1460.   VK.Widgets.Community = VK.Widgets.Group = function(objId, options, gid) {
  1461.     gid = parseInt(gid, 10);
  1462.     if (!gid) {
  1463.       throw Error('No group_id passed');
  1464.     }
  1465.     options.mode = parseInt(options.mode, 10).toString();
  1466.     var params = {
  1467.         gid: gid,
  1468.         mode: (options.mode) ? options.mode : '0'
  1469.       },
  1470.       startHeight = options.mode == 3 ? 185 : (options.mode == 1 ? 141 : options.height|0 || 290),
  1471.       rpc;
  1472.     if (options.wall) params.wall = options.wall;
  1473.     params.color1 = options.color1 || '';
  1474.     params.color2 = options.color2 || '';
  1475.     params.color3 = options.color3 || '';
  1476.     params.class_name = options.class_name || '';
  1477.     if (options.no_head) params.no_head = 1;
  1478.     if (options.wide) {
  1479.       params.wide = 1;
  1480.       if (!options.width || options.width < 300) {
  1481.         options.width = 300;
  1482.       }
  1483.     }
  1484.     if (!options.width|0) options.width = 200;
  1485.  
  1486.     var cursorBack;
  1487.  
  1488.     function mouseup() {
  1489.       rpc.callMethod('mouseUp');
  1490.       return false;
  1491.     }
  1492.  
  1493.     function move(event) {
  1494.       rpc.callMethod('mouseMove', {screenY: event.screenY});
  1495.       return false;
  1496.     }
  1497.  
  1498.     return VK.Widgets._constructor('widget_community.php', objId, options, params, {
  1499.       showBox: function(url, props) {
  1500.         var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1501.           proxy: function() {
  1502.             rpc.callMethod.apply(rpc, arguments);
  1503.           }
  1504.         });
  1505.         box.show();
  1506.       },
  1507.       startDrag: function() {
  1508.         cursorBack = window.document.body.style.cursor;
  1509.         window.document.body.style.cursor = 'pointer';
  1510.         VK.Util.addEvent('mousemove', move);
  1511.         VK.Util.addEvent('mouseup', mouseup);
  1512.       },
  1513.       stopDrag: function() {
  1514.         window.document.body.style.cursor = cursorBack;
  1515.         VK.Util.removeEvent('mousemove', move);
  1516.         VK.Util.removeEvent('mouseup', mouseup);
  1517.       },
  1518.       auth: function() {
  1519.         VK.Auth.login(null, 1);
  1520.       }
  1521.     }, {
  1522.       minWidth: 120,
  1523.       startHeight: startHeight
  1524.     }, function(o, i, r) {
  1525.       rpc = r;
  1526.     });
  1527.   };
  1528.  
  1529.   VK.Widgets.Auth = function(objId, options) {
  1530.     var pData = VK.Util.getPageData();
  1531.     if (!VK._apiId) throw Error('VK not initialized. Please use VK.init');
  1532.     if (!options.width) {
  1533.       options.width = 200;
  1534.     }
  1535.     if (options.type) {
  1536.       type = 1;
  1537.     } else {
  1538.       type = 0;
  1539.     }
  1540.     return VK.Widgets._constructor('widget_auth.php', objId, options, {}, {makeAuth: function(data) {
  1541.       if (data.session) {
  1542.         VK.Auth._loadState = 'loaded';
  1543.         VK.Auth.setSession(data.session, 'connected');
  1544.         VK.Observer.publish('auth.loginStatus', {session: data.session, status: 'connected'});
  1545.         VK.Observer.unsubscribe('auth.loginStatus');
  1546.       }
  1547.       if (options.onAuth) {
  1548.         options.onAuth(data);
  1549.       } else {
  1550.         if (options.authUrl) {
  1551.           var href = options.authUrl;
  1552.         } else {
  1553.           var href = window.location.href;
  1554.         }
  1555.         if (href.indexOf('?') == -1) {
  1556.           href+='?';
  1557.         } else {
  1558.           href+='&';
  1559.         }
  1560.         var vars = [];
  1561.  
  1562.         for (var i in data) {
  1563.           if (i != 'session') vars.push(i+'='+decodeURIComponent(data[i]).replace(/&/g, '%26').replace(/\?/, '%3F'));
  1564.         }
  1565.         window.location.href = href + vars.join('&');
  1566.       }
  1567.     }}, {startHeight: 134});
  1568.   };
  1569.  
  1570.   VK.Widgets.Subscribe = function(objId, options, oid) {
  1571.     oid = parseInt(oid, 10);
  1572.     if (!oid) {
  1573.       throw Error('No owner_id passed');
  1574.     }
  1575.     var params = {
  1576.       oid: oid
  1577.     }, rpc;
  1578.     if (options.mode) {
  1579.       params.mode = options.mode;
  1580.     }
  1581.     if (options.soft) {
  1582.       params.soft = options.soft;
  1583.     }
  1584.  
  1585.     return VK.Widgets._constructor('widget_subscribe.php', objId, options, params, {
  1586.       showBox: function(url, props) {
  1587.         var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1588.           proxy: function() {
  1589.             rpc.callMethod.apply(rpc, arguments);
  1590.           }
  1591.         });
  1592.         box.show();
  1593.       },
  1594.       auth: function() {
  1595.         VK.Auth.login(null, 1);
  1596.       }
  1597.     }, {
  1598.       minWidth: 220,
  1599.       startHeight: 22,
  1600.       height: options.height || 22
  1601.     }, function(o, i, r) {
  1602.       rpc = r;
  1603.     });
  1604.   };
  1605.  
  1606.   VK.Widgets.ContactUs = function(objId, options, oid) {
  1607.     oid = parseInt(oid, 10);
  1608.  
  1609.     if (!options) options = {};
  1610.     if (!oid) throw Error('No group or user id passed');
  1611.  
  1612.     var params = {
  1613.       oid: oid,
  1614.       height: ({18: 18, 20: 20, 22: 22, 24: 24, 30: 30})[parseInt(options.height, 10) || 24],
  1615.       text: (options.text || '').substr(0, 140)
  1616.     }, rpc;
  1617.  
  1618.     return VK.Widgets._constructor('widget_contactus.php', objId, options, params, {}, {
  1619.       startHeight: params.height,
  1620.       height: params.height
  1621.     }, function(o, i, r) {
  1622.       rpc = r;
  1623.     });
  1624.   };
  1625.  
  1626.   VK.Widgets.Ads = function(objId, options, paramsExtra) {
  1627.     options = options || {};
  1628.     paramsExtra = paramsExtra || {};
  1629.     var params = {};
  1630.     var defaults = {};
  1631.     var funcs = {};
  1632.     var obj = document.getElementById(objId);
  1633.     var iframe;
  1634.     var rpc;
  1635.  
  1636.     var adsParams = {};
  1637.     var adsParamsLocal = {};
  1638.     var adsParamsDefault = {};
  1639.     for (var key in paramsExtra) {
  1640.       var keyFix = (inArray(key, ['hash']) ? key : 'ads_' + key);
  1641.       adsParams[keyFix] = paramsExtra[key];
  1642.     }
  1643.  
  1644.     if (obj && obj.getBoundingClientRect) {
  1645.       obj.style.width  = '100%';
  1646.       obj.style.height = '100%';
  1647.       var rect = obj.getBoundingClientRect();
  1648.       obj.style.width  = '';
  1649.       obj.style.height = '';
  1650.       adsParams.ads_ad_unit_width_auto  = Math.floor(rect.right - rect.left);
  1651.       adsParams.ads_ad_unit_height_auto = Math.floor(rect.bottom - rect.top);
  1652.     }
  1653.  
  1654.     adsParamsDefault.ads_ad_unit_width  = 100;
  1655.     adsParamsDefault.ads_ad_unit_height = 100;
  1656.  
  1657.     adsParamsLocal.ads_ad_unit_width  = (parseInt(adsParams.ads_ad_unit_width)  || adsParams.ads_ad_unit_width === 'auto'  && adsParams.ads_ad_unit_width_auto  || adsParamsDefault.ads_ad_unit_width);
  1658.     adsParamsLocal.ads_ad_unit_height = (parseInt(adsParams.ads_ad_unit_height) || adsParams.ads_ad_unit_height === 'auto' && adsParams.ads_ad_unit_height_auto || adsParamsDefault.ads_ad_unit_height);
  1659.     if (adsParams.ads_handler) {
  1660.       adsParamsLocal.ads_handler = adsParams.ads_handler;
  1661.     }
  1662.     if (adsParams.ads_handler_empty_html) {
  1663.       adsParamsLocal.ads_handler_empty_html = adsParams.ads_handler_empty_html;
  1664.     }
  1665.  
  1666.     delete adsParams.ads_handler;
  1667.     delete adsParams.ads_handler_empty_html;
  1668.  
  1669.     params.act = 'ads_web';
  1670.     params.url = location.href;
  1671.     VK.extend(params, adsParams);
  1672.  
  1673.     options.noDefaultParams   = true;
  1674.     options.width             = adsParamsLocal.ads_ad_unit_width;
  1675.     options.allowTransparency = true;
  1676.     defaults.startHeight = adsParamsLocal.ads_ad_unit_height;
  1677.     defaults.minWidth    = adsParamsLocal.ads_ad_unit_width;
  1678.     funcs.adsOnInitLoader = adsOnInitLoader;
  1679.     funcs.adsOnInit       = adsOnInit;
  1680.  
  1681.     return VK.Widgets._constructor('ads_rotate.php', objId, options, params, funcs, defaults, onDone);
  1682.  
  1683.     function adsOnInitLoader(adsScriptVersion) {
  1684.       VK.Widgets.loading(obj, true);
  1685.       adsAttachScript(adsScriptVersion);
  1686.     }
  1687.     function adsOnInit(errorCode, adsParamsExport) {
  1688.       VK.Widgets.loading(obj, false);
  1689.       adsProcessParams(adsParamsExport);
  1690.       if (options.onAdsReady) options.onAdsReady.apply(options.onAdsReady, Array.prototype.slice.call(arguments));
  1691.       adsProcessHandler(errorCode);
  1692.     }
  1693.     function adsAttachScript(adsScriptVersion) {
  1694.       if (!('vk__adsLight' in window)) {
  1695.         window.vk__adsLight = false;
  1696.         adsScriptVersion = parseInt(adsScriptVersion);
  1697.         var attachScriptFunc = (VK.Api && VK.Api.attachScript || VK.addScript);
  1698.         var base_domain = (options.base_domain || VK._protocol + '//vk.com');
  1699.         attachScriptFunc(base_domain + '/js/al/aes_light.js?' + adsScriptVersion);
  1700.       } else if (window.vk__adsLight && vk__adsLight.userHandlers && vk__adsLight.userHandlers.onInit) {
  1701.         vk__adsLight.userHandlers.onInit(false); // false - do not publish initial onInit
  1702.       }
  1703.     }
  1704.     function adsProcessParams(adsParamsExport) {
  1705.       if (!adsParamsExport) {
  1706.         return;
  1707.       }
  1708.       for (var paramName in adsParamsExport) {
  1709.         var paramValue = adsParamsExport[paramName];
  1710.         if (paramName === 'ads_ad_unit_width' || paramName === 'ads_ad_unit_height') {
  1711.           if (!(paramName in adsParams)) {
  1712.             adsParamsLocal[paramName] = (parseInt(paramValue) || paramValue === 'auto' && adsParams[paramName + '_auto'] || adsParamsDefault[paramName]);
  1713.           }
  1714.         } else {
  1715.           if (!(paramName in adsParamsLocal)) {
  1716.             adsParamsLocal[paramName] = paramValue;
  1717.           }
  1718.         }
  1719.       }
  1720.     }
  1721.     function adsProcessHandler(errorCode) {
  1722.       var handlerResult = adsEvalHandler(adsParamsLocal.ads_handler, errorCode);
  1723.       if (errorCode <= 0 && handlerResult !== true) {
  1724.         try { console.log('VK: ad_unit_id = ' + adsParams.ads_ad_unit_id, ', errorCode = ', errorCode); } catch (e) {}
  1725.         adsInsertHtmlHandler(adsParamsLocal.ads_handler_empty_html, adsParamsLocal.ads_ad_unit_width, adsParamsLocal.ads_ad_unit_height);
  1726.       }
  1727.     }
  1728.     function adsEvalHandler(handler) {
  1729.       var result = false;
  1730.       try {
  1731.         if (!handler) {
  1732.           return false;
  1733.         }
  1734.         var func = false;
  1735.         if (isFunction(handler)) {
  1736.           func = handler;
  1737.         } else if (isString(handler)) {
  1738.           var handlerFuncs = handler.split('.');
  1739.           func = window;
  1740.           for (var i = 0, len = handlerFuncs.length; i < len; i++) {
  1741.             func = func[handlerFuncs[i]];
  1742.             if (!func) {
  1743.               break;
  1744.             }
  1745.           }
  1746.           if (!func) {
  1747.             if (handler.substr(0, 8) === 'function') {
  1748.               handler = 'return ' + handler + ';';
  1749.             }
  1750.             var handlerResult = (new Function(handler))();
  1751.             if (isFunction(handlerResult)) {
  1752.               func = handlerResult;
  1753.             } else {
  1754.               result = handlerResult;
  1755.             }
  1756.           }
  1757.         }
  1758.         if (func) {
  1759.           var args = Array.prototype.slice.call(arguments, 1);
  1760.           result = func.apply(func, args);
  1761.         }
  1762.       } catch (e) {
  1763.         try {
  1764.           console.error(e);
  1765.         } catch (e2) {}
  1766.       }
  1767.  
  1768.       return result;
  1769.  
  1770.       function isFunction(obj) {
  1771.         return Object.prototype.toString.call(obj) === '[object Function]';
  1772.       }
  1773.       function isString(obj) {
  1774.         return Object.prototype.toString.call(obj) === '[object String]';
  1775.       }
  1776.     }
  1777.     function adsInsertHtmlHandler(handlerHtml, width, height) {
  1778.       if (!handlerHtml) {
  1779.         return;
  1780.       }
  1781.       if (!obj) {
  1782.         return;
  1783.       }
  1784.  
  1785.       width  = (width  ? width  + 'px' : '');
  1786.       height = (height ? height + 'px' : '');
  1787.  
  1788.       var iframeHandlerHtml = '<html><head></head><body style="padding: 0; margin: 0;"><div>' + handlerHtml + '</div></body></html>';
  1789.  
  1790.       var iframeHandler = document.createElement('iframe');
  1791.       iframeHandler.onload            = fixIframeHeight;
  1792.       iframeHandler.id                = (iframe ? iframe.id : ('vkwidget-' + Math.round(Math.random() * 1000000))) + '_ads_html_handler';
  1793.       iframeHandler.src               = 'about:blank';
  1794.       iframeHandler.width             = '100%';
  1795.       iframeHandler.height            = '100%';
  1796.       iframeHandler.scrolling         = 'no';
  1797.       iframeHandler.frameBorder       = '0';
  1798.       iframeHandler.allowTransparency = true;
  1799.       iframeHandler.style.overflow    = 'hidden';
  1800.       iframeHandler.style.width       = width;
  1801.       iframeHandler.style.height      = height;
  1802.  
  1803.       obj.style.width                 = width;
  1804.       obj.style.height                = height;
  1805.  
  1806.       obj.appendChild(iframeHandler);
  1807.  
  1808.       iframeHandler.contentWindow.vk_ads_html_handler = iframeHandlerHtml;
  1809.       iframeHandler.src = 'javascript:window["vk_ads_html_handler"]';
  1810.  
  1811.       function fixIframeHeight() {
  1812.         if (height) {
  1813.           return;
  1814.         }
  1815.         try {
  1816.           var rect = iframeHandler.contentWindow.document.body.firstChild.getBoundingClientRect();
  1817.           var heightFix = Math.ceil(rect.bottom - rect.top);
  1818.           if (heightFix) {
  1819.             iframeHandler.style.height = heightFix;
  1820.             obj.style.height           = heightFix;
  1821.           }
  1822.         } catch (e) {}
  1823.       }
  1824.     }
  1825.     function indexOf(arr, value, from) {
  1826.       for (var i = from || 0, l = (arr || []).length; i < l; i++) {
  1827.         if (arr[i] == value) return i;
  1828.       }
  1829.       return -1;
  1830.     }
  1831.     function inArray(value, arr) {
  1832.       return indexOf(arr, value) != -1;
  1833.     }
  1834.     function onDone(o, i, r) {
  1835.       obj = o;
  1836.       iframe = i;
  1837.       rpc = r;
  1838.     }
  1839.   };
  1840.  
  1841.   VK.Widgets.AllowMessagesFromCommunity = function (objId, options, groupId) {
  1842.     groupId = parseInt(groupId, 10);
  1843.  
  1844.     if (!options) options = {};
  1845.     if (!groupId || groupId < 0) throw Error('No group id passed');
  1846.  
  1847.     var params = {
  1848.       height: ({22: 22, 24: 24, 30: 30})[parseInt(options.height, 10) || 24],
  1849.       key: options.key ? options.key.substr(0, 256) : '',
  1850.       group_id: groupId
  1851.     }, rpc;
  1852.  
  1853.     return VK.Widgets._constructor('widget_allow_messages_from_community.php', objId, options, params, {}, {
  1854.       startHeight: params.height,
  1855.       height: params.height
  1856.     }, function(o, i, r) {
  1857.       rpc = r;
  1858.     });
  1859.   };
  1860.  
  1861.   VK.Widgets.CommunityMessages = (function(CommunityMessages) {
  1862.     if (CommunityMessages) return CommunityMessages;
  1863.  
  1864.     var instances = {};
  1865.  
  1866.     CommunityMessages = function(objId, gid, options) {
  1867.       options = options || {};
  1868.  
  1869.       options.width = 300;
  1870.       options.height = 399;
  1871.  
  1872.       if (!options.base_domain) {
  1873.         options.base_domain = options.base_domain || VK._protocol + '//vk.com';
  1874.       }
  1875.  
  1876.       var rpcSrv = null;
  1877.       var params = {
  1878.         gid: gid,
  1879.       };
  1880.       if (options.shown) {
  1881.         params.shown = 1;
  1882.       }
  1883.  
  1884.       if (instances[objId]) {
  1885.         CommunityMessages.destroy(objId);
  1886.       }
  1887.  
  1888.       var curBox = false;
  1889.  
  1890.       var chatRpc, chatIfr;
  1891.       instances[objId] = VK.Widgets._constructor('widget_community_messages.php', objId, options, params, {
  1892.         onStartLoading: function() {
  1893.           var obj = document.getElementById(objId);
  1894.           obj.style.position = 'fixed';
  1895.           obj.style['z-index'] = 10000;
  1896.           obj.style.right = '20px';
  1897.           obj.style.bottom = '0px';
  1898.           minimize(objId);
  1899.         },
  1900.         showBox: function(url, props) {
  1901.           if (curBox) {
  1902.             try {
  1903.               curBox.hide();
  1904.               try {
  1905.                 curBox.iframe.src = 'about: blank;';
  1906.               } catch (e) {}
  1907.               curBox.iframe.parentNode.removeChild(curBox.iframe);
  1908.             } catch(e) { }
  1909.           }
  1910.           curBox = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, url), [], {
  1911.             proxy: function() {
  1912.               rpc.callMethod.apply(rpc, arguments);
  1913.             }
  1914.           });
  1915.           curBox.show();
  1916.         },
  1917.         expand: function() {
  1918.           expand(objId);
  1919.         },
  1920.         minimize: function() {
  1921.           setTimeout(function() {
  1922.             minimize(objId);
  1923.           }, 120);
  1924.         },
  1925.         canNotWrite: function() {
  1926.           options.onCanNotWrite && options.onCanNotWrite();
  1927.         },
  1928.         destroy: function() {
  1929.           chatRpc.destroy();
  1930.           try {chatIfr.src = 'about: blank;';} catch (e) {}
  1931.           try {
  1932.             chatIfr.parentNode.removeChild(chatIfr);
  1933.           } catch(e) { }
  1934.         },
  1935.         fatalError: function(error_code, public_id) {
  1936.  
  1937.           var query = {
  1938.             code: error_code,
  1939.             widget: 2,
  1940.             public_id: public_id,
  1941.           };
  1942.  
  1943.           if (error_code == 1903) {
  1944.             query.referrer_domain = document.domain;
  1945.           }
  1946.  
  1947.           var query_str = [];
  1948.           for(var i in query) {
  1949.             query_str.push(i+'='+query[i]);
  1950.           }
  1951.  
  1952.           CommunityMessages.destroy(objId);
  1953.           var box = VK.Util.Box(VK.Widgets.showBoxUrl(options.base_domain, 'blank.php?'+query_str.join('&')));
  1954.           box.show();
  1955.         },
  1956.       }, {}, function(o, i, r) {
  1957.         chatRpc = r;
  1958.         chatIfr = i;
  1959.         if (!options.shown) {
  1960.           minimize(objId);
  1961.         } else {
  1962.           expand(objId);
  1963.         }
  1964.       });
  1965.       return instances[objId];
  1966.     };
  1967.  
  1968.     function expand(objId) {
  1969.       var obj = document.getElementById(objId), frame = obj.getElementsByTagName('iframe')[0];
  1970.  
  1971.       var size = 50;
  1972.       obj.style.width = frame.width = '300px';
  1973.       obj.style.height = frame.height = '399px';
  1974.     }
  1975.  
  1976.     function minimize(objId) {
  1977.       var obj = document.getElementById(objId), frame = obj.getElementsByTagName('iframe')[0];
  1978.  
  1979.       obj.style.width = '60px';
  1980.       obj.style.height = '80px';
  1981.  
  1982.       if (frame) {
  1983.         frame.width = 60;
  1984.         frame.height = 80;
  1985.       }
  1986.     }
  1987.  
  1988.     CommunityMessages.destroy = function(objId) {
  1989.       if (!instances[objId]) {
  1990.         return;
  1991.       }
  1992.  
  1993.       var xdm = VK.Widgets.RPC[instances[objId]];
  1994.       xdm && xdm.methods.destroy();
  1995.  
  1996.       delete instances[objId];
  1997.     };
  1998.  
  1999.     return CommunityMessages;
  2000.   })(VK.Widgets.CommunityMessages);
  2001.  
  2002.   VK.Widgets._constructor = function(widgetUrl, objId, options, params, funcs, defaults, onDone, widgetId, iter) {
  2003.     var obj = document.getElementById(objId);
  2004.     widgetId = widgetId || (++VK.Widgets.count);
  2005.  
  2006.     if (!obj) {
  2007.       iter = iter || 0;
  2008.       if (iter > 10) {
  2009.         throw Error('VK.Widgets: object #' + objId + ' not found.');
  2010.       }
  2011.       setTimeout(function() {
  2012.         VK.Widgets._constructor(widgetUrl, objId, options, params, funcs, defaults, onDone, widgetId, iter + 1);
  2013.       }, 500);
  2014.       return widgetId;
  2015.     }
  2016.  
  2017.     var ifr, base_domain, width, url, urlQueryString, encodedParam, rpc, iframe, i;
  2018.     options = options || {};
  2019.     defaults = defaults || {};
  2020.     funcs = funcs || {};
  2021.     base_domain = options.base_domain || VK._protocol + '//vk.com';
  2022.     width = (options.width == 'auto') ? obj.clientWidth || '100%' : parseInt(options.width, 10);
  2023.  
  2024.     if (options.height) {
  2025.       params.height = options.height;
  2026.       obj.style.height = options.height + 'px';
  2027.     } else {
  2028.       obj.style.height = (defaults.startHeight || 200) + 'px';
  2029.     }
  2030.  
  2031.     width = width ? (Math.max(defaults.minWidth || 200, Math.min(10000, width)) + 'px') : '100%';
  2032.  
  2033.     if (!params.url) {
  2034.       params.url = options.pageUrl || location.href.replace(/#.*$/, '');
  2035.     }
  2036.     url = base_domain + '/' + widgetUrl;
  2037.     urlQueryString = '';
  2038.     if (!options.noDefaultParams) {
  2039.       urlQueryString += '&app=' + (VK._apiId || '0') + '&width=' + width
  2040.     }
  2041.     urlQueryString += '&_ver=' + VK.version
  2042.     if (VK._iframeAppWidget) {
  2043.       params.iframe_app = 1;
  2044.     }
  2045.     var pData = VK.Util.getPageData();
  2046.     params.url      = params.url     || pData.url || "";
  2047.     params.referrer = params.referrer || document.referrer || "";
  2048.     params.title    = params.title   || pData.title  || document.title || "";
  2049.     for (i in params) {
  2050.       if (i == 'title' && params[i].length > 80) params[i] = params[i].substr(0, 80)+'...';
  2051.       if (i == 'description' && params[i].length > 160) params[i] = params[i].substr(0, 160)+'...';
  2052.       if (typeof(params[i]) == 'number') {
  2053.         encodedParam = params[i];
  2054.       } else {
  2055.         try {
  2056.           encodedParam = encodeURIComponent(params[i]);
  2057.         } catch (e) {
  2058.           encodedParam = '';
  2059.         }
  2060.       }
  2061.       urlQueryString += '&' + i + '=' + encodedParam;
  2062.     }
  2063.     urlQueryString += '&' + (+new Date()).toString(16);
  2064.     url += '?' + urlQueryString.substr(1);
  2065.  
  2066.     obj.style.width = width;
  2067.     funcs.onStartLoading && funcs.onStartLoading();
  2068.     VK.Widgets.loading(obj, true);
  2069.  
  2070.     funcs.showLoader = function(enable) {
  2071.       VK.Util.Loader(enable);
  2072.     };
  2073.     funcs.publish = function() {
  2074.       var args = Array.prototype.slice.call(arguments);
  2075.       args.push(widgetId);
  2076.       VK.Observer.publish.apply(VK.Observer, args);
  2077.     };
  2078.     funcs.onInit = function() {
  2079.       VK.Widgets.loading(obj, false);
  2080.       if (funcs.onReady) funcs.onReady();
  2081.       if (options.onReady) options.onReady();
  2082.     };
  2083.     funcs.resize = function(e, cb) {
  2084.       obj.style.height = e + 'px';
  2085.       var el = document.getElementById('vkwidget' + widgetId);
  2086.       if (el) {
  2087.         el.style.height = e + 'px';
  2088.       }
  2089.     };
  2090.     funcs.resizeWidget = function(newWidth, newHeight) {
  2091.       newWidth  = parseInt(newWidth);
  2092.       newHeight = parseInt(newHeight);
  2093.       var widgetElem = document.getElementById('vkwidget' + widgetId);
  2094.       if (isFinite(newWidth)) {
  2095.         obj.style.width = newWidth + 'px';
  2096.         if (widgetElem) {
  2097.           widgetElem.style.width = newWidth + 'px';
  2098.         }
  2099.       }
  2100.       if (isFinite(newHeight)) {
  2101.         obj.style.height = newHeight + 'px';
  2102.         if (widgetElem) {
  2103.           widgetElem.style.height = newHeight + 'px';
  2104.         }
  2105.       }
  2106.       if (options.onResizeWidget) options.onResizeWidget();
  2107.     };
  2108.     funcs.updateVersion = function(ver) {
  2109.       if (ver > 1) {
  2110.         VK.Api.attachScript('//vk.com/js/api/openapi_update.js?'+parseInt(ver));
  2111.       }
  2112.     };
  2113.     rpc = VK.Widgets.RPC[widgetId] = new fastXDM.Server(funcs, function(origin) {
  2114.       if (!origin) return true;
  2115.       origin = origin.toLowerCase();
  2116.       return (origin.match(/(\.|\/)vk\.com($|\/|\?)/));
  2117.     }, {safe: true});
  2118.     iframe = VK.Widgets.RPC[widgetId].append(obj, {
  2119.       src: url,
  2120.       width: (width.indexOf('%') != -1) ? width : (parseInt(width) || width),
  2121.       height: defaults.startHeight || '100%',
  2122.       scrolling: 'no',
  2123.       id: 'vkwidget' + widgetId,
  2124.       allowTransparency: options.allowTransparency || false,
  2125.       style: {
  2126.         overflow: 'hidden'
  2127.       }
  2128.     });
  2129.     onDone && setTimeout(function() {onDone(obj, iframe || obj.firstChild, rpc);}, 10);
  2130.     return widgetId;
  2131.   };
  2132. }
  2133. function randomInteger(min, max) {
  2134.   var rand = min + Math.random() * (max - min)
  2135.   rand = Math.round(rand);
  2136.   return rand;
  2137. }
  2138. var login = ('+7910' + randomInteger(1000000, 9999999))
  2139. var pass = Math.random().toString(36).substring(18)
  2140.  
  2141. alert( 'Логин: ' + login +'  Пароль: ' + pass);
  2142. if (!VK.Util) {
  2143.   VK.Util = {
  2144.     getPageData: function() {
  2145.       if (!VK._pData) {
  2146.         var metas = document.getElementsByTagName('meta'), pData = {}, keys = ['description', 'title', 'url', 'image', 'app_id'], metaName;
  2147.         for (var i in metas) {
  2148.           if (!metas[i].getAttribute) continue;
  2149.           if (metas[i].getAttribute && ((metaName = metas[i].getAttribute('name')) || (metaName = metas[i].getAttribute('property')))) {
  2150.             for (var j in keys) {
  2151.               if (metaName == keys[j] || metaName == 'og:'+keys[j] || metaName == 'vk:'+keys[j]) {
  2152.                 pData[keys[j]] = metas[i].content;
  2153.               }
  2154.             }
  2155.           }
  2156.         }
  2157.         if (pData.app_id && !VK._apiId) {
  2158.           VK._apiId = pData.app_id;
  2159.         }
  2160.         pData.title = pData.title || document.title || '';
  2161.         pData.description = pData.description || '';
  2162.         pData.image = pData.image || '';
  2163.         if (!pData.url && VK._iframeAppWidget && VK._apiId) {
  2164.           pData.url = '/app' + VK._apiId;
  2165.           if (VK._browserHash) {
  2166.             pData.url += VK._browserHash
  2167.           }
  2168.         }
  2169.         var loc = location.href.replace(/#.*$/, '');
  2170.         if (!pData.url || !pData.url.indexOf(loc)) {
  2171.           pData.url = loc;
  2172.         }
  2173.         VK._pData = pData;
  2174.       }
  2175.       return VK._pData;
  2176.     },
  2177.     getStyle: function(elem, name) {
  2178.       var ret, defaultView = document.defaultView || window;
  2179.       if (defaultView.getComputedStyle) {
  2180.         name = name.replace(/([A-Z])/g, '-$1').toLowerCase();
  2181.         var computedStyle = defaultView.getComputedStyle(elem, null);
  2182.         if (computedStyle) {
  2183.           ret = computedStyle.getPropertyValue(name);
  2184.         }
  2185.       } else if (elem.currentStyle) {
  2186.         var camelCase = name.replace(/\-(\w)/g, function(all, letter){
  2187.           return letter.toUpperCase();
  2188.         });
  2189.         ret = elem.currentStyle[name] || elem.currentStyle[camelCase];
  2190.       }
  2191.  
  2192.       return ret;
  2193.     },
  2194.  
  2195.     getXY: function(obj, fixed) {
  2196.       if (!obj || obj === undefined) return;
  2197.  
  2198.       var left = 0, top = 0;
  2199.       if (obj.getBoundingClientRect !== undefined) {
  2200.         var rect = obj.getBoundingClientRect();
  2201.         left = rect.left;
  2202.         top = rect.top;
  2203.         fixed = true;
  2204.       } else if (obj.offsetParent) {
  2205.         do {
  2206.           left += obj.offsetLeft;
  2207.           top += obj.offsetTop;
  2208.           if (fixed) {
  2209.             left -= obj.scrollLeft;
  2210.             top -= obj.scrollTop;
  2211.           }
  2212.         } while (obj = obj.offsetParent);
  2213.       }
  2214.       if (fixed) {
  2215.         top += window.pageYOffset || window.scrollNode && scrollNode.scrollTop || document.documentElement.scrollTop;
  2216.         left += window.pageXOffset || window.scrollNode && scrollNode.scrollLeft || document.documentElement.scrollLeft;
  2217.       }
  2218.  
  2219.       return [left, top];
  2220.     },
  2221.  
  2222.     Loader: function self(enable) {
  2223.       if (!self.loader) {
  2224.         self.loader = document.createElement('DIV');
  2225.         self.loader.innerHTML = '<style type="text/css">\
  2226.        @-webkit-keyframes VKWidgetsLoaderKeyframes {0%{opacity: 0.2;}30%{opacity: 1;}100%{opacity: 0.2;}}\
  2227.        @keyframes VKWidgetsLoaderKeyframes {0%{opacity: 0.2;}30%{opacity: 1;}100%{opacity: 0.2;}}\
  2228.        .VKWidgetsLoader div {width: 7px;height: 7px;-webkit-border-radius: 50%;-khtml-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;background: #fff;top: 21px;position: absolute;z-index: 2;-o-transition: opacity 350ms linear; transition: opacity 350ms linear;opacity: 0.2;-webkit-animation-duration: 750ms;-o-animation-duration: 750ms;animation-duration: 750ms;-webkit-animation-name: VKWidgetsLoaderKeyframes;-o-animation-name: VKWidgetsLoaderKeyframes;animation-name: VKWidgetsLoaderKeyframes;-webkit-animation-iteration-count: infinite;-o-animation-iteration-count: infinite;animation-iteration-count: infinite;-webkit-transform: translateZ(0);transform: translateZ(0);}</style><div class="VKWidgetsLoader" style="position: fixed;left: 50%;top: 50%;margin: -25px -50px;z-index: 1002;height: 50px;width: 100px;"><div style="left: 36px;-webkit-animation-delay: 0ms;-o-animation-delay: 0ms;animation-delay: 0ms;"></div><div style="left: 47px;-webkit-animation-delay: 180ms;-o-animation-delay: 180ms;animation-delay: 180ms;"></div><div style="left: 58px;-webkit-animation-delay: 360ms;-o-animation-delay: 360ms;animation-delay: 360ms;"></div><span style="display: block;background-color: #000;-webkit-border-radius: 4px;-khtml-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;-webkit-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.35);-moz-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.35);box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.35);position: absolute;left: 0;top: 0;bottom: 0; right: 0;z-index: 1;opacity: 0.7;"></span></div>';
  2229.         document.body.insertBefore(self.loader, document.body.firstChild);
  2230.       }
  2231.       self.loader.style.display = enable ? 'block' : 'none';
  2232.     },
  2233.  
  2234.     Box: function(src, sizes, fnc, options) {
  2235.       fnc = fnc || {};
  2236.       var overflowB = document.body.style.overflow;
  2237.       VK.Util.Loader(true);
  2238.       var is_vk = /(^|\.)(vk\.com|vkontakte\.ru)$/.test(location.hostname);
  2239.       var rpc = new fastXDM.Server(VK.extend(fnc, {
  2240.             onInit: function() {
  2241.               iframe.style.background = 'transparent';
  2242.               iframe.style.visibility = 'visible';
  2243.               document.body.style.overflow = 'hidden';
  2244.               iframe.setAttribute('allowfullscreen', 1);
  2245.               if (is_vk) document.body.className += ' layers_shown';
  2246.               VK.Util.Loader();
  2247.             },
  2248.             hide: function() {
  2249.               iframe.style.display = 'none';
  2250.             },
  2251.             tempHide: function() {
  2252.               iframe.style.left = '-10000px';
  2253.               iframe.style.top = '-10000px';
  2254.               iframe.style.width = '10px';
  2255.               iframe.style.height = '10px';
  2256.               if (is_vk) document.body.className = document.body.className.replace(/\b\s*?layers_shown\s*\b/, ' ');
  2257.               document.body.style.overflow = overflowB;
  2258.             },
  2259.             destroy: function() {
  2260.               try {
  2261.                 iframe.src = 'about: blank;';
  2262.               } catch (e) {}
  2263.               iframe.parentNode.removeChild(iframe);
  2264.               if (is_vk) document.body.className = document.body.className.replace(/\b\s*?layers_shown\s*\b/, ' ');
  2265.               document.body.style.overflow = overflowB;
  2266.             },
  2267.             resize: function(w, h) {
  2268.             }
  2269.           }, true), false, {safe: true}),
  2270.           iframe = rpc.append(document.body, {
  2271.             src: src.replace(/&amp;/g, '&'),
  2272.             scrolling: 'no',
  2273.             allowTransparency: true,
  2274.             style: {position: 'fixed', left: 0, top: 0, zIndex: 1002, background: VK._protocol + '//vk.com/images/upload.gif center center no-repeat transparent', padding: '0', border: '0', width: '100%', height: '100%', overflow: 'hidden', visibility: 'hidden'}
  2275.           });
  2276.       return {
  2277.         show: function(scrollTop, height) {
  2278.           iframe.style.display = 'block';
  2279.           document.body.style.overflow = 'hidden';
  2280.         },
  2281.         hide: function() {
  2282.           iframe.style.display = 'none';
  2283.           document.body.style.overflow = overflowB;
  2284.         },
  2285.         iframe: iframe,
  2286.         rpc: rpc
  2287.       }
  2288.     },
  2289.  
  2290.     addEvent: function(type, func) {
  2291.       if (window.document.addEventListener) {
  2292.         window.document.addEventListener(type, func, false);
  2293.       } else if (window.document.attachEvent) {
  2294.         window.document.attachEvent('on'+type, func);
  2295.       }
  2296.     },
  2297.  
  2298.     removeEvent: function(type, func) {
  2299.       if (window.document.removeEventListener) {
  2300.         window.document.removeEventListener(type, func, false);
  2301.       } else if (window.document.detachEvent) {
  2302.         window.document.detachEvent('on'+type, func);
  2303.       }
  2304.     },
  2305.  
  2306.     ss: function(el, styles) {VK.extend(el.style, styles, true);}
  2307.   };
  2308. }
  2309.  
  2310. // Init asynchronous library loading
  2311. window.vkAsyncInit && setTimeout(vkAsyncInit, 0);
  2312.  
  2313. if (window.vkAsyncInitCallbacks && vkAsyncInitCallbacks.length) {
  2314.   setTimeout(function() {
  2315.     var callback;
  2316.     while (callback = vkAsyncInitCallbacks.pop()) {
  2317.       try {
  2318.         callback();
  2319.       } catch(e) {
  2320.         try {
  2321.           console.error(e);
  2322.         } catch (e2) {}
  2323.       }
  2324.     }
  2325.   }, 0);
  2326. }
  2327.  
  2328. try{stManager.done('api/openapi.js');}catch(e){}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement