(function(){var k="";var q={ticket:"xdlogin",login:"tlogin",permanent:"plogin",username:"xdusername",numTests:"xdtest",time:"xdtime",timeout:"xdtimeout"};var f="";var c=2000;var l=3;var h=7*60*1000;var s=15*60*1000;var a=false;var b="";var p=false;var t={login:"xdLogin",registration:"xdRegistration",logout:"xdLogout"};var m={init:function(){if(arguments.length<6){return}f=arguments[0]+(arguments[0].charAt(arguments[0].length-1)!="/"?"/":"");k=arguments[1];q.ticket=arguments[2];switch(arguments.length){case 6:q.permanent=arguments[3];q.login=arguments[4];c=arguments[5];var v=function(){u(function(){return i(f,"head")},g);e(q.login,"login");e(q.permanent,"permanent")};break;case 7:t.login=arguments[3];t.registration=arguments[4];t.logout=arguments[5];c=arguments[6];var v=function(){var w=window.onload;window.onload=function(){if(w!=null&&typeof(w)=="function"){w()}var x=r(q.ticket);var y=r(q.username);if(!d()&&x!==""&&y!==""){m.username(y,x)}else{o();window.setTimeout(m.username,c)}}};break;default:return}if(window.location!=null&&window.location.host!=null&&(k.indexOf(window.location.host)!=-1)||(window.location.host.indexOf(k)!=-1)){v()}},login:function(v){a=true;if(""!==v){j(q.ticket,encodeURIComponent(v),0);window.location=window.location}},username:function(z,x){if(a){return}a=true;if(z!=null&&z!=""&&x!=null&&x!==""){j(q.ticket,encodeURIComponent(x),0);j(q.username,encodeURIComponent(z),0);var v=document.getElementById(t.login);if(v!=null){v.innerHTML=z;var y=document.getElementById(t.registration);if(y!=null){y.style.display="none"}var w=document.getElementById(t.logout);if(w!=null){w.style.display="inline"}}window.setTimeout(function(){a=false;j(q.ticket,null);o()},s)}},logout:function(v){if(v==null){j(q.numTests,null);j(q.time,null);j(q.timeout,null);j(q.username,null);window.location=b}else{b=v;window.setTimeout(function(){m.logout()},c);i(f+"logout","body")}return false},permanent:function(){a=true;j(q.permanent,null)},logged:function(){a=true;j(q.login,null)}};window.JyxoCrossDomain=m;function g(v){if(v==null){v=true}var w=r(q.numTests);if(w==""){w=0}if(!a&&w<l){j(q.numTests,++w,0);j(q.timeout,1,0);if(v){window.location=window.location}}}function u(y,x){if(!d()&&""===r(q.ticket)){var v=r(q.time);var w=new Date();if(v==""||parseInt(v)<(w.getTime()-h)){if(y()){j(q.time,w.getTime(),0);window.setTimeout(x,c)}else{window.setTimeout(arguments.callee,100)}}}}function o(){u(function(){return i(f+"username","body")},function(){g(false)})}function e(w,x){var v=r(w);if(!d()&&v!==""){if(i(f+x+"/"+v,"head")){window.setTimeout(g,c)}else{window.setTimeout(arguments.callee,100)}}}function r(v){if(document.cookie&&""!==document.cookie){var y=document.cookie.split(";");var x;for(var w=0;w<y.length;w++){x=n(y[w]);if(0===x.indexOf(v+"=")){return n(decodeURIComponent(x.substring(v.length+1)))}}}return""}function j(y,A,w){if(w==null){if(A==null){w=-1}else{var x=new Date();x.setTime(x.getTime()+5*60*60*1000);w=x.toUTCString()}}var v=(w===0?"":"; expires="+w);var C="; path=/";var z="; domain="+k;var B="";document.cookie=[y,"=",A,v,C,z,B].join("")}function n(v){return v.replace(/^\s+|\s+$/g,"")}function i(y,x){var v=document.getElementsByTagName(x);if(v.length>0){var w=document.createElement("script");w.src=y;v[0].appendChild(w);return true}return false}function d(){if(p){return true}var v=r(q.timeout);if(v==""){p=false}else{p=true;j(q.timeout,null)}return p}})();