if(!"app" in window){var app={}}app.sites=(function(){var k=null;var g=null;var G=("undefined"!=typeof SITE_configuration)?SITE_configuration:null;$(window).height();$(window).width();var I={bgiframe:true,autoOpen:false,modal:true,dialogClass:"siteOverlay",width:640,height:320,resizable:false,draggable:false};var B={};function A(){if(null==G){return}$.each(G.sites,function(){B[this.id]=this});m();if(G.activeSiteId=="EU"&&G.activeLocale=="default"){G.activeLocale=g}app.geoip.getGeoipCountryCode();if($(".disableCheckSites").length==0){if(!app.geoip.checkSite()){f()}}l()}function f(){if(null==k){return}if(!app.sites.isPreferredActive()){h(G.mismatchAction,{overlayUrl:G.mismatchDialogUrl})}}function n(){return k==G.activeSiteId&&g==G.activeLocale}function h(K,J){if(app.geoip.runAction(K,J)){return}if("nothing"==K){return}if("redirectPreferred"==K){r(d(),g);return}if("redirectMaster"==K){location.href=G.masterUrl;return}if("overlay"==K){app.sites.showOverlay(J.overlayUrl);return}}function C(J){if(!q()){$(document.body).append('<div id="gwsitesoverlay"></div>');$("#gwsitesoverlay").dialog(I);$(".siteOverlay.ui-dialog").css({position:"fixed"})}$("#gwsitesoverlay").load(J,{},function(){$("#gwsitesoverlay").dialog("option","title",$("#gwsitesoverlay .dialogTitle").text());l($("#gwsitesoverlay"));$("#gwsitesoverlay .dialogTitle").remove();$("#gwsitesoverlay").dialog("open");$("#gwsitesoverlay form").submit(D)})}function q(){return $("#gwsitesoverlay").length>0}function D(){var J=window.location.href;if(J!=null){$(this).append('<input type="hidden" name="originurl" value="'+escape(J)+'" id="d_originurl" checked="checked" />')}var K=$('input[name="site"]:checked',this).val();while(1){var L=/^\[(\w+)\]$/.exec(K);if(!L){break}siteName=L[1];K=$('input[name="'+siteName+'"]',this).val()}var M=y().id+"/"+b().id;if(K==M){$.post($(this).attr("action"),$(this).serialize());$("#gwsitesoverlay").dialog("close");return false}}function r(L,J){var N=L.id;if(null==J){J=L.locales[0].locale||L.locales[0].id}var K=window.location.href;var M="";if(K!=null){M="&originurl="+escape(K)}location.href=G.gatewayUrl+"?q=leave&site="+N+"&locale="+J+M}function m(){var J=document.cookie.split(";");$.each(J,function(){var M=this.split("=");var L=M[0].replace(/^\s+|\s+$/g,"");if(L=="sSite"||(L=="pSite"&&null==k)){var N=M[1].replace(/^\s+|\s+$/g,"");var K=N.split("/");if(K[0] in B){k=K[0];g=K[1]}}})}function y(){return G.activeSiteId in B?B[G.activeSiteId]:{id:G.activeSiteId,locales:[],hostname:G.activeHostname}}function b(){var J=y();var K=$.grep(J.locales,function(L){return L.locale===G.activeLocale||L.id===G.activeLocale});return K.length>0?K[0]:{id:"default",language:"<NotConfigured>",countryCode:"",country:"<Not Configured>"}}function d(){return k!=null&&(k in B)?B[k]:null}function j(){var K=d();if(null==K||null==g){return null}var J=$.grep(K.locales,function(L){return L.locale==g||L.id==g});return J.length>0?J[0]:null}function F(){var J=j();return J!=null?J.country:""}function c(){var J=j();return null!=J?J.language:""}function x(){var J=d();return J!=null?J.id:""}function E(){var J=j();return null!=J?J.id:""}function l(K){if(!K){K=$("body")[0]}$(".activeCountryText",K).text(b().country);$(".activeLanguageText",K).text(b().language);$(".preferredCountryText",K).text(F());$(".preferredLanguageText",K).text(c());$(".activeLocaleIdValue",K).val(y().id+"/"+b().id);$(".preferredLocaleIdValue",K).val(x()+"/"+E());var J=y().id;if(J=="EU"){J=b().countryCode}if(J==""){J="EU"}b().countryCode;$(".activeCountryClass",K).addClass("country_"+J);$(".activeLocaleIdClass",K).addClass("locale_"+y().id+"_"+b().id);if(null==d()){$(".showPreferredExists").remove()}else{if(app.sites.isPreferredActive()){$(".showPreferredMismatch").remove()}else{$(".showPreferredMatch").remove()}}$("select.countrySelectorOptions",K).each(app.sites.constructSelectorOptions);$(".selectFirstRadio :radio:first",K).click();$(".showCountrySelectFilled",K).each(e);app.geoip.updateContent(K);app.sites.updateContentHook(K);o(K)}function o(J){$(".siteSelectorLink",J).click(app.sites.showDialog)}function e(){if($("select.countrySelectorOptions option",this).length==0){$(this).remove()}}function z(){var J=[];$.each(G.sites,function(L,K){$.each(K.locales,function(N,M){J.push({hostName:K.hostname,siteId:K.id,localeId:M.id,localelocale:M.locale,name:M.country,language:M.language,countryCode:M.countryCode})})});return J}function H(J,M,L){if(""==M){return J}var K=[];$.each(J,function(N,O){if(O.siteId==M&&O.localeId==L){K.push(N)}});$.each(K,function(O,N){J.splice(O+N,1)});return J}function i(J){return H(J,y().id,b().id)}function w(J){return H(J,x(),E())}function v(){var J=$(this);var K=app.sites.getAllCountries();if(J.hasClass("skipPreferredCountry")){w(K)}if(J.hasClass("skipActiveCountry")){i(K)}if(J.hasClass("skipGeoipCountry")&&"geoip" in app){app.geoip.filterGeoipCountry(K)}$.each(K,function(L,M){app.sites.constructSelectorOption(J,L,M)})}function u(J,K,M){var L=$("<option/>");L.val(M.siteId+"/"+M.localeId);L.text(M.name+" ("+M.language+")");J.append(L)}var p=null;function a(){if(null==p){p={};$.each(SITE_configuration.sites,function(){var J=this;$.each(J.locales,function(){p[this.countryCode]=J})})}return p}function t(J){var K=a();return(J in K)?K[J]:null}function s(){var J=$(this).attr("data-dialogUrl");app.sites.showOverlay(J);return false}return{init:A,updateContent:l,getActiveLocale:b,getPreferredLocale:j,showOverlay:C,overlayConfig:I,isOverlayActive:q,showDialog:s,updateContentHook:function(){},constructSelectorOptions:v,constructSelectorOption:u,getSiteForCountryCode:t,redirect:r,runAction:h,getActiveSiteConfig:y,getActiveLocaleConfig:b,getPreferredSiteConfig:d,getPreferredLocaleConfig:j,isPreferredActive:n,getAllCountries:z,filterCountries:H}})();app.geoip=(function(){var t=("undefined"!=typeof GEOIP_configuration)?GEOIP_configuration:null;var b=null;var l=null;var g=null;function o(w,v){document.cookie=escape(w)+"="+escape(v)+"; path=/";return true}function m(){if(null==t||null!=l){return}if(null==b||""==b){l="failed"}else{g=app.sites.getSiteForCountryCode(b);l=null==g?"notFound":"success"}}function n(){if(typeof geoip_country_code=="function"){GEOIP_countryCode=geoip_country_code();if(GEOIP_countryCode!=null){o("geoSite",GEOIP_countryCode)}}b=("undefined"!=typeof GEOIP_countryCode)?GEOIP_countryCode:null}function h(){m();return l}function a(){m();return g}function j(){var v=a();if(null==v){return null}var w=$.grep(v.locales,function(x){return x.countryCode==b});return w.length>0?w[0]:null}function d(w,v){if(null==t){return false}if("redirectGeoIP"==w){app.sites.redirect(a());return true}if("redirectPreferred"==w){var x=app.sites.getPreferredSiteConfig();if(null==x){app.sites.runAction(t.redirectFailedAction,{overlayUrl:t.redirectFailedDialogUrl});return true}}return false}function u(){var v=app.sites.getActiveLocaleConfig();return v.countryCode==b}function q(){var v=app.sites.getPreferredLocaleConfig();return v==null||v.countryCode==b}function r(){if(null==t){return false}if(c()){return true}m();if(app.sites.isPreferredActive()){return true}if("failed"==l){app.sites.runAction(t.failedAction,{overlayUrl:t.failedDialogUrl})}else{if("notFound"==l){app.sites.runAction(t.notFoundAction,{overlayUrl:t.notFoundDialogUrl})}else{if(u()){if(null==app.sites.getPreferredLocaleConfig()){app.sites.runAction(t.matchAction,{overlayUrl:t.matchDialogUrl})}else{return false}}else{if(q()&&(app.sites.getPreferredLocaleConfig()!=null)){app.sites.runAction(t.matchPreferredAction,{overlayUrl:t.matchPreferredDialogUrl})}else{app.sites.runAction(t.mismatchAction,{overlayUrl:t.mismatchDialogUrl})}}}}return true}function s(){var v=j();return v!=null?v.country:""}function i(){var v=j();return v!=null?v.language:""}function k(){var v=a();return v!=null?v.id:""}function p(){var v=j();return v!=null?v.id:""}function c(){if(typeof(t.excludedAgents)=="undefined"){return false}var x=navigator.userAgent;for(var w=0,v=t.excludedAgents.length;w<v;w++){if(x.indexOf(t.excludedAgents[w])>-1){return true}}return false}function e(v){$(".geoipCountryText",v).text(s());$(".geoipLanguageText",v).text(i());$(".geoipLocaleIdValue",v).val(k()+"/"+p());if(null==a()){$(".showGeoipExists").remove()}else{if(u()){$(".showGeoipMismatch").remove()}else{$(".showGeoipMatch").remove()}if(q()){$(".showGeoipNotPreferred").remove()}else{$(".showGeoipPreferred").remove()}}}function f(v){return app.sites.filterCountries(v,k(),p())}return{getStatus:h,getSite:a,getGeoipCountryCode:n,checkSite:r,runAction:d,updateContent:e,filterGeoipCountry:f,getLocale:j}})();$(function(){app.sites.init()});
