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