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