function IsCNL(){var r=window.location.pathname,n="",t="",i=CNLSites();if(window.location.pathname.split("/")[2]!="undefined"||window.location.pathname.split("/")[2]!=null||window.location.pathname.split("/")[2]!="")try{n=window.location.pathname.split("/")[1].trim()+"/"+window.location.pathname.split("/")[2].trim()}catch(u){n=""}else n="";return(window.location.hostname.split(".")[2]=="cn"||window.location.hostname.split(".")[3]=="cn"||window.location.hostname.split(".")[3]=="ru"||window.location.hostname.split(".")[4]=="ru")&&(window.location.hostname.split(".")[2]=="cn"||window.location.hostname.split(".")[3]=="cn"?t="cn":(window.location.hostname.split(".")[3]=="ru"||window.location.hostname.split(".")[4]=="ru")&&(t="ru")),$.inArray(window.location.pathname.split("/")[1].trim(),i)!=-1||$.inArray(n,i)!=-1?!0:window.location.hostname.split(".")[2]=="cn"||window.location.hostname.split(".")[3]=="cn"||window.location.hostname.split(".")[3]=="ru"||window.location.hostname.split(".")[4]=="ru"?$.inArray(t,i)?!0:!1:!1}function IsProperUrl(n){var t=new XMLHttpRequest,i=URLRedirection(n);t.open("HEAD",i,!1);try{return t.send(),t.status===200?!0:!1}catch(r){return!1}}function URLRedirection(n){var t="",i="",u=window.location.protocol+"//"+window.location.hostname+"/esolCnlConfig/esolredirectionconfig.xml",r=$.ajax({url:u,async:!1}).responseText,r=$.parseHTML($.parseHTML(r)[2].innerHTML)[1].innerHTML.trim();return $.each($.parseHTML(r),function(r,u){if(u!="undefined"||u!=null)try{i=u.attributes[0].value.indexOf("stgtest.esol.ucles.cn")!=-1||u.attributes[0].value.indexOf("uat-www.cambridgeenglish.cn")!=-1||u.attributes[0].value.indexOf("www.cambridgeenglish.cn")!=-1||u.attributes[0].value.indexOf("www.cambridgeenglish.org.ru")!=-1?window.location.protocol+"//"+u.attributes[0].value:window.location.protocol+"//"+window.location.hostname+u.attributes[0].value;i[i.length-1]=="/"&&(i=i.slice(0,-1));var f=n;f[f.length-1]=="/"&&(f=f.slice(0,-1));i==f&&(t=f.indexOf("stgtest.esol.ucles.cn")!=-1||f.indexOf("uat-www.cambridgeenglish.cn")!=-1||f.indexOf("www.cambridgeenglish.cn")!=-1||f.indexOf("www.cambridgeenglish.org.ru")!=-1?window.location.protocol+"//"+u.attributes[1].value:window.location.protocol+"//"+window.location.hostname+u.attributes[1].value)}catch(e){}}),t==""&&(t=HandlePermanenetRedirection(n),(t==""||t=="undefined")&&(t=n)),t}function HandlePermanenetRedirection(n){var t,i="",r=$.ajaxSettings.xhr;return $.ajaxSettings.xhr=function(){return t=r()},$.ajax({url:n,async:!1,success:function(){i=t.responseURL}}),i}function CNLSites(){var t=window.location.protocol+"//"+window.location.hostname+"/esolCnlConfig/esolcnlconfig.xml",i=$.ajax({url:t,async:!1}).responseText,n=i.split("value=");return n=n[1].match(/'(.*?)'/),n[1].split(",")}function GetLangCode(n){var t=new XMLHttpRequest,i="",r="";t.open("HEAD",n,!1);try{return t.send(),t.status===200?(r=$.ajax({url:n,async:!1,success:function(){}}).responseText,$.each($.parseHTML(r),function(n,t){t.className=="inner"&&(i=t.lang)}),i):""}catch(u){return""}}var CCDLTSites=!1;$(window).load(function(){"use strict";var i=CNLSites(),t=[],n="",u=window.location.protocol+"//"+window.location.hostname+window.location.pathname,o;u[u.length-1]=="/";var f="",e="",r="";window.location.hostname.split(".")[2]=="cn"||window.location.hostname.split(".")[3]=="cn"||window.location.hostname.split(".")[3]=="ru"||window.location.hostname.split(".")[4]=="ru"?(CCDLTSites=!0,f="",e="",window.location.hostname.split(".")[2]=="cn"?r=window.location.hostname.split(".")[2]:window.location.hostname.split(".")[3]=="cn"?r=window.location.hostname.split(".")[3]:window.location.hostname.split(".")[3]=="ru"?r=window.location.hostname.split(".")[3]:window.location.hostname.split(".")[4]=="ru"&&(r=window.location.hostname.split(".")[4])):(f=window.location.pathname.split("/")[1],e=window.location.pathname.split("/")[1]+"/"+window.location.pathname.split("/")[2]);n=GetLangCode(u);o="";t.push(o);$.each(i,function(u,o){var s,h;IsCNL()?(s="",h="",CCDLTSites?CCDLTSites&&(window.location.hostname.split(".")[2]=="cn"||window.location.hostname.split(".")[3]=="cn"?s=window.location.hostname.indexOf("stgtest")!=-1?window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+".internal/"+window.location.pathname.split("/").slice(1).join("/"):window.location.hostname.indexOf("uat")!=-1?window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+".org/"+window.location.pathname.split("/").slice(1).join("/"):window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+".org/"+window.location.pathname.split("/").slice(1).join("/"):(window.location.hostname.split(".")[3]=="ru"||window.location.hostname.split(".")[4]=="ru")&&(s=window.location.hostname.indexOf("stgtest")!=-1?window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+".internal/"+window.location.pathname.split("/").slice(1).join("/"):window.location.hostname.indexOf("uat")!=-1?window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+"/"+window.location.pathname.split("/").slice(1).join("/"):window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+"/"+window.location.pathname.split("/").slice(1).join("/"))):o.indexOf("/")!=-1?$.inArray(f.trim(),i)!=-1?s=window.location.protocol+"//"+window.location.hostname+"/"+window.location.pathname.split("/").slice(2).join("/"):$.inArray(e.trim(),i)!=-1&&(s=window.location.protocol+"//"+window.location.hostname+"/"+window.location.pathname.split("/").slice(3).join("/")):s=window.location.protocol+"//"+window.location.hostname+"/"+window.location.pathname.split("/").slice(2).join("/"),s[s.length-1]=="/",IsProperUrl(s)&&(s=URLRedirection(s),n=GetLangCode(s),t.push("")),CCDLTSites?$.inArray(r.trim(),i)!=-1&&(h=o.trim()=="cn"?s.split("/")[0]+"//"+s.split("/")[2].split(".").slice(0,-1).join(".")+"."+o.trim()+"/"+window.location.pathname.split("/").slice(2).join("/"):o.trim()=="ru"?s.split("/")[0]+"//"+s.split("/")[2]+"."+o.trim()+"/"+window.location.pathname.split("/").slice(2).join("/"):s.split("/")[0]+"//"+s.split("/")[2]+"/"+o.trim()+window.location.pathname):CCDLTSites||($.inArray(f.trim(),i)!=-1?h=o.trim()=="cn"?s.split("/")[0]+"//"+s.split("/")[2].split(".").slice(0,-1).join(".")+"."+o.trim()+"/"+window.location.pathname.split("/").slice(2).join("/"):o.trim()=="ru"?s.split("/")[0]+"//"+s.split("/")[2]+"."+o.trim()+"/"+window.location.pathname.split("/").slice(2).join("/"):s.split("/")[0]+"//"+s.split("/")[2]+"/"+o.trim()+"/"+window.location.pathname.split("/").slice(2).join("/"):$.inArray(e.trim(),i)!=-1&&(h=o.trim()=="cn"?s.split("/")[0]+"//"+s.split("/")[2].split(".").slice(0,-1).join(".")+"."+o.trim()+"/"+window.location.pathname.split("/").slice(3).join("/"):o.trim()=="ru"?s.split("/")[0]+"//"+s.split("/")[2]+"."+o.trim()+"/"+window.location.pathname.split("/").slice(3).join("/"):s.split("/")[0]+"//"+s.split("/")[2]+"/"+o.trim()+"/"+window.location.pathname.split("/").slice(3).join("/"))),IsProperUrl(h)&&(h[h.length-1]=="/",h=URLRedirection(h),n=GetLangCode(h),t.push(""))):(h="",h=o.trim()=="cn"?window.location.protocol+"//"+window.location.hostname.split(".").slice(0,-1).join(".")+"."+o.trim()+window.location.pathname:o.trim()=="ru"?window.location.protocol+"//"+window.location.hostname+"."+o.trim()+window.location.pathname:window.location.protocol+"//"+window.location.hostname+"/"+o.trim()+window.location.pathname,h[h.length-1]=="/",IsProperUrl(h)&&(h=URLRedirection(h),n=GetLangCode(h),t.push("")))});t=$.unique(t);$(".inner").replaceWith(t.join(" "))})