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