setHttps();var width=800,height=600,query={},tmp=location.search.substr(1).split("&"),tmp2,i;for(i=0;i<tmp.length;i++)tmp2=tmp[i].split("="),query[tmp2[0]]=tmp2[1];
var uloginWindow=!1,interval=0,network=!1,socket=!1,supportStorage=!!("localStorage"in window&&null!==window.localStorage&&"JSON"in window&&null!==window.JSON&&"undefined"!==typeof window.JSON.parse&&"undefined"!==typeof window.JSON.stringify),lang=query.lang?query.lang:(navigator.language?navigator.language:navigator.userLanguage).substr(0,2);"ru"!=lang&&"en"!=lang&&(PROVIDERS[lang]=PROVIDERS.en);
function setHttps(){location.href.match(/^https/i)||(location.href="https"+location.href.substr(4))}function isIE(){return/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&8>=Number(RegExp.$1)?!0:!1}function getById(a){return document.getElementById(a)}function addEvent(a,c,b){a.addEventListener?a.addEventListener(c,function(c){b(a,c)},!1):a.attachEvent?a.attachEvent("on"+c,function(c){b(a,c)}):a["on"+c]=function(c){b(a,c)}}function childProcessing(a,c){for(var b=0;a[b];)c(a[b]),b++}
function getWeights(){try{return JSON.parse(localStorage.providers_weight)}catch(a){return{}}}function setWeight(a){function c(a){var b=[],c={};for(i in a)b.push([i,a[i]]);b=b.sort(function(a,b){return a[1]-b[1]});for(i in b)c[b[i][0]]=b[i][1];return c}if(this.supportStorage){var b=getWeights();b[a]=b[a]?b[a]+1:1;localStorage.providers_weight=JSON.stringify(c(b))}}function inArray(a,c){if(!a||!c)return!1;for(var b=0,d=c.length;b<d;b++)if(a==c[b])return b;return-1}
function mergeWeights(a){if(this.supportStorage){var c=getWeights(),b;for(b in c)c=this.inArray(b,a),-1!==c&&(a.splice(c,1),a.splice(0,0,b))}return a}
function popup(a,c){setWeight(a);if(network){var b=getById(network);childProcessing(b.childNodes?b.childNodes:[],function(a){a.parentNode.className=""});clearInterval(interval)}network=a;b=getById(a);childProcessing(b.childNodes?b.childNodes:[],function(a){a.parentNode.className="process"});b.style&&(b.style.filter="alpha(opacity=55) progid:DXImageTransform.Microsoft.AlphaImageLoader(src=transparent.png, sizingMethod='crop'",b.style.opacity="0.55");b="width="+width+",height="+height+",left="+(screen.width-
width)/2+",top="+(screen.height-height)/2;"steam"==a&&(b="width="+screen.width+", height="+screen.height+", top=0, left=0, fullscreen=yes, scrollbar=auto");var d="/",d=("webmoney"!=a&&"livejournal"!=a&&"openid"!=a?d+"auth":d+"url")+(".php?name="+network+"&window=0&lang="+query.lang+"&client="+query.client+"&fields="+query.fields+"&force_fields="+query.force_fields+"&mobile="+query.mobile+"&optional="+query.optional+"&redirect_uri="+query.redirect_uri+"&callback="+query.callback+"&screen="+screen.width+
"x"+screen.height+"&host="+query.host+"&page="+query.page+"&verify="+query.verify+"&othprov="+query.othprov+"&providers="+query.providers+"&altway="+query.altway+"&m="+query.m+"&q="+encodeURIComponent(location.toString()));"undefined"!=typeof query.altway?sendMessage("https://ulogin.ru"+d):(sendMessage("open"),uloginWindow=window.open(d,"uloginWindow",b),interval=setInterval(check,1E3));return!1}function check(){uloginWindow&&uloginWindow.closed&&(sendMessage("close"),clearNetwork())}
function clearNetwork(){var a=getById(network);childProcessing(a.childNodes?a.childNodes:[],function(a){a.parentNode.className=""});if(a.style){a.style.color="#777";for(var c=a.parentNode;"a"!=c.className;)c=c.parentNode;c.style.backgroundColor="#e6e6e6";a.style.filter="";a.style.opacity=""}clearInterval(interval);network=!1}
function receiver(a,c,b,d){c?((c.match(/^https/i)?"https":"http")!=query.protocol&&(c=c.split(":"),c.splice(0,1),c=query.protocol+":"+c.join(":")),sendMessage("receive:"+a),window.location.href=c+"?token="+a+"&callback="+b+"&q="+encodeURIComponent(d)):(sendMessage(a),sendMessage("receive:"+a))}
function redirect(a,c){if(c.match(/^https/i)){var b=document.createElement("form");b.action=c;b.method="post";b.target="_top";b.style.display="none";var d=document.createElement("input");d.type="hidden";d.name="token";d.value=a;b.appendChild(d);document.body.appendChild(b);b.submit()}else sendMessage("receive"),window.location.href="https://ulogin.ru/http.html?redirect_uri="+encodeURIComponent(c)+"&token="+a+"&q="+encodeURIComponent(location.href)}
function over(a,c){var b=a?a:c.srcElement;network||(b.style&&(b.style.backgroundColor="#ffffff"),childProcessing(b.childNodes?b.childNodes:[],function(a){a.style&&(a.style.color="#333")}))}function out(a,c){var b=a?a:c.srcElement;network||(b.style&&(b.style.backgroundColor="#e6e6e6"),childProcessing(b.childNodes?b.childNodes:[],function(a){a.style&&(a.style.color="#777")}))}
function sendMessage(a){if(query.xdm_c&&query.xdm_e&&query.xdm_p)if(socket)try{socket.postMessage(a)}catch(c){window.setTimeout(function(){socket.postMessage(a)},200)}else socket=new easyXDM.Socket({swf:isIE()?"https://ulogin.ru/js/easyxdm.swf":"",onReady:function(){try{socket.postMessage(a)}catch(c){window.setTimeout(function(){socket.postMessage(a)},200)}}})}
window.onload=function(){sendMessage("ready");var a=query.providers,a=a.split(",");"relevant"===query.sort&&(a=mergeWeights(a));var c=getById("list"),b=0;c.style&&(b=23*a.length-2,c.style.height=b+"px");query.theme||(query.theme="classic");b=query.icons_16?decodeURIComponent(query.icons_16):"/version/2.0/img/providers-16-"+query.theme+".png?version=img.2.0.0";for(i=0;i<a.length;i++){var d=document.createElement("div");d.innerHTML='<div id="a'+(i+1)+'" class="a"><a id="'+a[i]+'"><span style="background-image: url('+
b+"); background-position:0 -"+(17*PROVIDERS_POSITION[a[i]]+1)+'px" class="no-processing"></span><span style="background: url(/version/2.0/img/presmall.gif) 0 0 no-repeat; background-size: 16px;" class="processing"></span>'+PROVIDERS[lang][a[i]]+"</a></div>";addEvent(d.firstChild,"mouseover",over);addEvent(d.firstChild,"mouseout",out);addEvent(d.firstChild,"click",function(a,b){if("disable-click"==c.className)return!1;var d=a?a:b.srcElement;d&&popup(d.childNodes[0].getAttribute("id"))});c.appendChild(d.firstChild)}!1===
isIE()?(a=new IScroll("#wrapper",{mouseWheel:!0,scrollbars:"custom",click:!0}),a.on("scrollStart",function(){c.className="disable-click"}),a.on("scrollEnd",function(){setTimeout(function(){c.className=""},100)})):(getById("wrapper").style.overflowX="hidden",getById("wrapper").style.overflowY="scroll")};
