YUI.add("i13n",function(G){var y="TS",q="&",AC="=",a="-",E="sports|cache|uk-api|content|content-cache|tc|labs|horseracing|greyhounds|forum|community|rugbyunion|mobile|basketball|tennis|cricket|darts|betting|mulitples|extras|casino|politics|volleyball|accountservices|account|golf|poker|games|arcade|casino|ausracing|thetote|uktotezone|irishtote|rsatote",t="body",AB="node",v="keys",s="keysMapping",V="server",h="params",n="file",b="class",J="eventClass",j="i13n",H="defaultKeys",F="events",B="direct",i="bubbleToParent",L="toParent",O="listenOn",I="delegateOn",r="attached",AD="unloaded",C="bubble",m="postCreateCall",K="initialEvent",e="createTransportNode",Z="doCall",Q="wat.betfair.com",z="1x1.gif",AE="attr",p="targetattr",d="query",c="cookie",D="ref",u="screensize",P="viewportsize",l="preCall",x="postCall",f="preParam",o="postParam",X="preSignal",N="postSignal",T="isValidTarget",R="childBroadcast",AA="childUnload",w=[l,x,f,o,X,N,T],U=[R],S={},k={},M={},g=null,A={},W;G.i13n=function(){var Y,AF;G.i13n.superclass.constructor.apply(this,arguments);S[G.stamp(this)]=this;this._create();if(this.get(m)){Y=this.get(m)[AB]||this.get(AB);AF=this.get(m)[h]||{};this.makeCall(Y,AF);}};G.i13n.NAME="i13n";G.i13n.ATTRS={"node":{value:G.one(t),validator:function(Y){return !this.get(r);}},"postCreateCall":{value:null},"initialEvent":{value:null},"server":{value:Q,setter:function(Y){this.url=null;return Y;}},"file":{value:z,setter:function(Y){this.url=null;return Y;}},"class":{value:j,writeOnce:true,validator:function(Y){return(Y.indexOf("-")>=-1);}},"eventClass":{value:j,writeOnce:true,validator:function(Y){return(Y.indexOf(":")>=-1);}},"keys":{value:{"int":"I","interactive":"I","log":"Log","ver":"Ver","pkg":"G","package":"G","ltxt":"X","link":"X","pg":"P","page":"P","pos":"N","position":"N","sec":"S","section":"S","tab":"T","li":"L","user":"U","module":"M","platform":"pl","test":"A","gen":"Z","sport":"Sp","ref":"dr","referrer":"dr","product":"prod","locale":"loc","brand":"brnd","theme":"thm","user_search_term":"Ust","user_screen_size":"Us","user_viewport_size":"Uvs"},readOnly:true},"keysMapping":{value:true},"defaultKeys":{value:{"ver":"2.1.0","log":"1"},setter:function(Y){return G.merge(G.i13n.ATTRS.defaultKeys.value,Y);}},"events":{value:["click"]},"listenOn":{value:"a"},"delegateOn":{value:"a"},"direct":{value:false},"bubbleToParent":{value:true},"toParent":{value:true},"attached":{value:false,readOnly:true},"version":{value:"2.1.0",readOnly:true},"createTransportNode":{value:function(){return document.createElement("img");},validator:function(Y){return typeof Y==="function"?true:false;}},"doCall":{value:function(Y,AF){Y.setAttribute("src",AF);},validator:function(Y){return typeof Y==="function"?true:false;}}};G.i13n._create=function(AG,AF){if(true===AG.get(r)||!AG){return;}this._makeAttrBackwardCompatible(AG,i,L,true);this._makeAttrBackwardCompatible(AG,m,K,null);this._makeAttrBackwardCompatible(AG,O,I,"a");var Y=AG.get(AB),AH=AG.get(J);this._createEvents(AH);G.Array.each(AG.get(F),function(AI){AG.handles.push(Y.delegate(AI,AF,AG.get(O),AG));},this);G.Global.on(AH+":"+R,this._onChildEvent,null);AG._set(r,true);};G.i13n._makeAttrBackwardCompatible=function(AG,Y,AF,AH){if(AG.get(AF)!==AH){AG.set(Y,AG.get(AF));}else{AG.set(AF,AG.get(Y));}AG.after(Y+"Change",function(AI){AG.set(AF,AI.newVal);});AG.after(AF+"Change",function(AI){AG.set(Y,AI.newVal);});};G.i13n._getTransportNode=function(Y){if(typeof(Y._cachedTransNode)==="undefined"){Y._cachedTransNode=Y.get(e)();}return Y._cachedTransNode;};G.i13n._generateRequestURL=function(AF,AG){var Y=AF.url;AG=this.generateParams(AF,AG);if(!Y){Y="//"+AF.get(V)+"/"+AF.get(n)+"?";AF.url=Y;}return Y+AG;};G.i13n._onEvent=function(AG){var AI={},Y=this.get(b),AH=this.get(J),AF=function(AJ){if(AJ.hasClass(Y)){return true;}return false;};if((AG.target.hasClass(Y)||AG.target.ancestor(AF))&&G.fire(AH+":"+T,AG)){G.fire(AH+":"+l,AG,AI);G.i13n.makeCall(this,AG,AG.target,AI);G.fire(AH+":"+x,AG);}};G.i13n._onChildEvent=function(AK,AM,AJ,AF,AG,AL){var AN,AH,Y=false,AI=new G.Node(AF);if(C===AK){for(AN in S){if(S.hasOwnProperty(AN)){AH=S[AN];if(AH.get(AB).contains(AI)){Y=true;if(true===AH.get(B)){G.i13n.makeCall(AH,AJ,AH.get(AB),AG);}else{G.i13n.makeCall(AH,AJ,AI,AG);}}}}if(Y===false){G.i13n.makeCall(AH,AJ,G.one(t),AG);}}else{if(AD===AK){G.fire(AM+":"+AA);}}};G.i13n._createEvents=function(AH){if(AH in k){return false;}var AF,Y,AG;for(AF=0,Y=w.length;AF<Y;AF++){AG=w[AF];k[AH+"_"+AG]=G.publish(AH+":"+AG);}for(AF=0,Y=U.length;AF<Y;AF++){AG=U[AF];k[AH+"_"+AG]=G.publish(AH+":"+AG,{broadcast:2});}k[AH]=true;return true;};G.i13n._getParentYUI=function(AK){var AG,AI,AJ=true,Y=AK+":"+R;AG=window;if(typeof M[AK]==="undefined"){do{AI=AG;AG=AI.parent;try{M[AK]=AG.YUI||false;if(M[AK]&&!(M[AK].Env.mods.i13n&&M[AK].Env.globalEvents&&(Y in M[AK].Env.globalEvents._yuievt.events))){M[AK]=null;}try{g=AI.frameElement;if(!g){AJ=false;}}catch(AH){AJ=false;}}catch(AF){AJ=false;}if(M[AK]===YUI||(AG===AG.parent&&!M[AK])){AJ=false;}}while(true===AJ&&!M[AK]);}else{if(window==window.parent||M[AK]===false){AJ=false;}}return AJ;};G.i13n._onUnload=function(){if(this.dynKeyValueRegExp){this.dynKeyValueRegExp=null;}if(this.referrerTestRegExp){this.referrerTestRegExp=null;}if(this.classMatchRegExp){this.classMatchRegExp=null;}M=null;k=null;S=null;g=null;};G.i13n._checkDynamicValue=function(AF,AH,AJ){var AI,AG,Y;if(false===G.Lang.isArray(AF)){AF=[AF];}for(AG=0,Y=AF.length;AG<Y;++AG){if(typeof AF[AG]!=="string"){AF[AG]=AF[AG]+"";}}if(AF[0].substr(0,1)==="@"){AI=this._dynamicValue(AF,AH,AJ);}else{AI=AF.join(a);}return AI;};G.i13n._dynamicValue=function(AH,AI,AJ){var AG,AF=null,Y=null;if(!this.dynKeyValueRegExp){this.dynKeyValueRegExp=/^@([\w]+)(-([\w]+))?$/;}AG=AH[0].match(this.dynKeyValueRegExp);if(AG[3]!==undefined){AF=AG[1];Y=AG[3];}else{if(AG[1]!==undefined){AF=AG[1];Y=AH[1]||null;}}if(AF!==null){switch(AF){case AE:return(Y&&AI)?AI.getAttribute(Y):AH.join(a);case p:return(Y&&AJ)?AJ.getAttribute(Y):AH.join(a);case d:return(Y)?this._getQueryParamValue(Y):AH.join(a);
case c:return(Y)?this._getCookie(Y):AH.join(a);case D:return this._getReferrer();case u:return window.screen.width+"x"+window.screen.height;case P:return this._getViewportSize();default:return AH.join(a);}}};G.i13n._getReferrer=function(){if(!this.referrerTestRegExp){this.referrerTestRegExp=new RegExp("/(.*\\.)*("+E+")\\.betfair.com(:\\d*)*/");}return(!this.referrerTestRegExp.test(document.referrer))?document.referrer:"";};G.i13n._getQueryParamValue=function(AF){var AG=null,Y=null,AH=null;if(AF in A){AG=A[AF];}else{AH=AF.replace(/\[/,"\\[").replace(/\]/,"\\]");AG=new RegExp("[\\?&#]"+AH+"=([^&#]*)");A[AF]=AG;}Y=AG.exec(window.location.search);if(Y===null){Y=AG.exec(window.location.hash);}return(Y!==null)?Y[1]:null;};G.i13n._getViewportSize=function(){var Y=0,AF=0;if(typeof top.innerWidth!="undefined"){Y=top.innerWidth;AF=top.innerHeight;}else{if(typeof top.document.documentElement!="undefined"&&typeof top.document.documentElement.clientWidth!="undefined"&&top.document.documentElement.clientWidth!==0){Y=top.document.documentElement.clientWidth;AF=top.document.documentElement.clientHeight;}else{Y=top.document.getElementsByTagName("body")[0].clientWidth;AF=top.document.getElementsByTagName("body")[0].clientHeight;}}return Y+"x"+AF;};G.i13n._getCookie=function(AI){var AG=AI+"=",Y=document.cookie.split(";"),AH,AF;for(AF=0;AF<Y.length;++AF){AH=Y[AF];while(AH.charAt(0)==" "){AH=AH.substring(1,AH.length);}if(AH.indexOf(AG)===0){return AH.substring(AG.length,AH.length);}}return null;};G.i13n.getDynamicParamValue=function(Y){return this._dynamicValue([Y]);};G.i13n.destroy=function(AH){var AG,Y,AF=AH.handles;for(AG=0,Y=AF.length;AG<Y;AG++){AF.pop().detach();}AH._set(r,false);};G.i13n.collectParams=function(AL,AG,AJ){var Y=AL.get(AB),AI="",AK,AF=false,AH=AG,AO,AM,AN;if(!AL.classMatchRegExp){AL.classMatchRegExp=new RegExp("^"+AL.get(b)+"(-.*){2,}");}do{if(AH===Y){AF=true;}AI=AH.get("className").split(/\s+/);for(AK=AI.length-1;AK>=0;--AK){if(AL.classMatchRegExp.test(AI[AK])){AO=AI[AK].split(a);AO.shift();AN=AO.shift();if(!AJ[AN]){AM=this._checkDynamicValue(AO,AH,AG);AJ[AN]=AM;}}}AH=AH.get("parentNode");}while(AG!==Y&&AF===false);return AJ;};G.i13n.makeCall=function(AI,AJ,AH,AL){var AG=null,AK=AI.get(J),Y=null,AF=AK+":"+R;if(!AL){AL={};}G.fire(AK+":"+f,AJ,AH,AL);AL=this.collectParams(AI,AH,AL);G.fire(AK+":"+o,AJ,AH,AL);if(true===AI.get(i)){AI.set(i,G.i13n._getParentYUI(AK));}if(false===AI.get(i)){AG=this._generateRequestURL(AI,AL);Y=this._getTransportNode(AI);G.fire(AK+":"+X,AJ,AH,AG);AG=k[AK+"_"+X].firedWith[2];AI.get(Z)(Y,AG);G.fire(AK+":"+N,AJ,AH,Y);}else{M[AK].Env.globalEvents.fire(AF,C,AK,AJ,g,AL);}};G.i13n.generateParams=function(AG,AF){var AJ=[],AM=null,AH=null,AK,AL,AN=AG.get(v),Y=AG.get(H),AI=new Date().getTime();AJ.push(y+AC+AI);AF=G.merge(Y,AF);for(AM in AF){if(AF.hasOwnProperty(AM)&&AF[AM]!==undefined&&AF[AM]!==null&&AF[AM]!==""&&typeof(AF[AM])!=="function"){AK=this._checkDynamicValue(AF[AM],null,null);if(AK){AH=encodeURIComponent(AK);AL=(AG.get(s))?(AN[AM]||AM):AM;AJ.push(q+AL+AC+AH);}}}return AJ.join("");};W={handles:[],url:"",collectParams:function(Y,AF){G.i13n.collectParams(this,Y,AF);return this;},generateParams:function(Y){return G.i13n.generateParams(this,Y);},makeCall:function(Y,AF){G.i13n.makeCall(this,null,Y,AF);return this;},_create:function(){G.i13n._create(this,this._onEvent);return this;},_onEvent:function(){G.i13n._onEvent.apply(this,arguments);}};G.extend(G.i13n,G.Base,W);},"2.1.0",{requires:["base-base","event-base","event-delegate","node-base","node-style","node-event-delegate"]});
