var BaynoteJSVersion="$Revision: 3.19 $";var BaynoteIgnored=false;var BN_READY_SIGNAL="ReadySignal";var Strategy={ScriptDOMInject:2,OnLoadInject:3};if(typeof(baynote_globals)=="undefined"){var baynote_globals=new Object()}baynote_globals.CommonResourceURL="/baynote/tags3/common";baynote_globals.CommonResourceID="Common";baynote_globals.PolicyResourceID="Policy";baynote_globals.CustomerStatus="/baynote/customerstatus2";baynote_globals.CommonScriptId="commonScriptId";if(typeof(baynote_inject_strategy)!="undefined"){baynote_globals.DefaultInjectStrategy=baynote_inject_strategy}else{baynote_globals.DefaultInjectStrategy=Strategy.ScriptDOMInject}if(typeof(baynote_server_timeout)!="undefined"){baynote_globals.ServerTimeout=baynote_server_timeout}else{baynote_globals.ServerTimeout=undefined}if(typeof(baynote_use_window_name)!="undefined"){baynote_globals.UseWindowName=baynote_use_window_name}else{baynote_globals.UseWindowName=false}baynote_globals.waitForReady=false;baynote_globals.checkStatus=false;baynote_globals.keepTrail=false;baynote_globals.trailLength=5;bnIsOpera=(navigator.userAgent.indexOf("Opera")>=0);bnIsSafari=(navigator.userAgent.indexOf("AppleWebKit")>=0);bnIsKonqueror=(navigator.userAgent.indexOf("Konqueror")>=0);bnIsKHTML=(bnIsSafari||bnIsKonqueror||navigator.userAgent.indexOf("KHTML")>=0);bnIsIE=(navigator.userAgent.indexOf("compatible")>=0&&navigator.userAgent.indexOf("MSIE")>=0&&!bnIsOpera);bnIsMozilla=(navigator.userAgent.indexOf("Gecko")>=0&&!bnIsKHTML);function BNLog(){this.timeBase=new Date().getTime();this.lines=new Array();this.lastLine="";this.repCount=0}BNLog.prototype.log=function(b){if(b==this.lastLine){++this.repCount;return}if(this.repCount>0){this.lines.push("___ ABOVE REPEATED "+this.repCount+" TIME"+((this.repCount>1)?"S":""))}this.lastLine=b;this.repCount=0;var a=new Date().getTime()-this.timeBase;this.lines.push(a+": "+b)};BNLog.prototype.toString=function(){if(this.repCount>0){this.lines.push("___ ABOVE REPEATED "+this.repCount+" TIME"+((this.repCount>1)?"S":""));this.lastLine="";this.repCount=0}return this.lines.join("\n")};if(typeof(bnLog)=="undefined"){var bnLog=new BNLog()}function BNCriticalSectionQueue(){this.waitList=new Object();this.lastId=0}BNCriticalSectionQueue.prototype.issueId=function(){return ++this.lastId};BNCriticalSectionQueue.prototype.enqueue=function(b,a){this.waitList[b]=a};BNCriticalSectionQueue.prototype.getWaiter=function(a){return(a==null)?null:this.waitList[a]};BNCriticalSectionQueue.prototype.firstWaiter=function(){return this.getWaiter(this.nextWaiterKeyAfter(null))};BNCriticalSectionQueue.prototype.nextWaiterAfter=function(a){return this.getWaiter(this.nextWaiterKeyAfter(a))};BNCriticalSectionQueue.prototype.nextWaiterKeyAfter=function(b){for(var a in this.waitList){if(typeof(this.waitList[a])!="object"){continue}if(b==null){return a}if(b==a){b=null}}return null};BNCriticalSectionQueue.prototype.nextPredecessor=function(b,c){for(var a=c;a!=null;a=this.nextWaiterAfter(a.id)){if(a.enter||(a.number!=0&&(a.number<b.number||(a.number==b.number&&a.id<b.id)))){return a}}return null};function BNCriticalSection(a){this.csQueue=a;this.debug=1}BNCriticalSection.prototype.enter=function(a){this.enterFunc=a;this.id=this.csQueue.issueId();this.csQueue.enqueue(this.id,this);this.enter=true;this.number=(new Date()).getTime();this.enter=false;this.attempt(this.csQueue.firstWaiter())};BNCriticalSection.prototype.leave=function(){if(this.debug){bnLog.log("LEAVE "+this.id)}this.number=0};BNCriticalSection.prototype.attempt=function(c){var a=this.csQueue.nextPredecessor(this,c);if(a!=null){if(this.debug){bnLog.log("WAIT "+this.id)}var b=this;return setTimeout(function(){b.attempt(a)},50)}if(this.debug){bnLog.log("ENTER "+this.id)}this.enterFunc()};function BNResourceManager(a){this.csQueue=new BNCriticalSectionQueue();this.critSec=null;this.debug=1;this.resources=new Object();this.waiting=new Object();this.onloadInjected=false;if(typeof(a)!="undefined"){this.strategy=a}else{this.strategy=Strategy.ScriptDOMInject}}BNResourceManager.prototype.getResource=function(a){return this.resources[a]};BNResourceManager.prototype.loadResource=function(e,f,c,d,b){if(typeof(this.resources[e])!="undefined"){return}this.resources[e]=null;var a=new BNCriticalSection(this.csQueue);a.enter(function(){bnResourceManager.inject(e,f,c,a,d,b)})};BNResourceManager.prototype.inject=function(e,f,c,b,d,a){this.critSec=b;if(this.debug){bnLog.log("INJECT "+this.critSec.id+" ("+e+")")}if(typeof(c)!="undefined"&&c!="script"&&c!="img"){bnLog.log("Unexpected resource type to loadResource: "+c);return}this.defaultInject(e,f,c,d,a)};BNResourceManager.prototype.defaultInject=function(a,i,b,h,c){if(BaynoteIgnored){return}if(!b||b=="script"){if(this.strategy==Strategy.OnLoadInject){if(a==baynote_globals.CommonResourceID||a==baynote_globals.PolicyResourceID){if(!this.onloadInjected){var g=function(){bnResourceManager.injectHandler(a,i,h,c)};if(window.addEventListener){window.addEventListener("load",g,false)}else{if(window.attachEvent){window.attachEvent("onload",g)}else{window.onload=g}}this.onloadInjected=true;return}}}this.injectHandler(a,i,h,c)}else{if(b=="img"){var e=document.createElement("IMG");var j=function(){bnResourceManager.registerAndAddResource(a,e)};if(e.addEventListener){e.addEventListener("load",j,false)}else{if(e.attachEvent){e.attachEvent("onload",j)}else{e.onload=j}}e.src=i;e.style.display="none";var d=document.getElementsByTagName("body");var f=d[0];setTimeout(function(){if(f!=null){f.appendChild(e)}},5)}}};BNResourceManager.prototype.injectHandler=function(d,f,c,a,b){if(!this.resources[d]){if(typeof b!="undefined"){b.src="";if(typeof a=="function"){a()}BaynoteIgnored=true;bnLog.log("FATAL: Treating Baynote as down. Resource '"+d+"' took more than "+c+" mSec");return}var e=document.createElement("script");setTimeout(function(){var g=document.getElementsByTagName("head");e.language="javascript";e.src=f;g[0].appendChild(e)},50);if(c===undefined||c===null){c=baynote_globals.ServerTimeout}if(typeof c!="undefined"){setTimeout(function(){bnResourceManager.injectHandler(d,f,c,a,e)},c)}}};BNResourceManager.prototype.waitForResource=function(rId,callbackCode,rAddress,rType,timeout,failureFunc){with(this){if(getResource(rId)){this.runCallback(callbackCode)}else{if(typeof(waiting[rId])=="undefined"){waiting[rId]=new Array()}var waitingList=waiting[rId];waitingList[waitingList.length]=callbackCode;if(rAddress){this.loadResource(rId,rAddress,rType,timeout,failureFunc)}}}};BNResourceManager.prototype.wakeUpWaiting=function(rId){with(this){var waitingList=waiting[rId];if(!waitingList){return}for(var i=0;i<waitingList.length;i++){if(waitingList[i]){var codeToEval=waitingList[i];waitingList[i]=null;if(this.debug&&codeToEval){bnLog.log("CALLBACK "+rId+": "+codeToEval)}this.runCallback(codeToEval)}}}};BNResourceManager.prototype.registerAndAddResource=function(b,a){if(this.debug){bnLog.log("REGISTER "+(this.critSec?this.critSec.id:"")+" ("+b+")")}this.resources[b]=a;this.wakeUpWaiting(b);if(this.critSec){this.critSec.leave()}setTimeout("bnResourceManager.wakeUpWaiting('"+b+"')",5000)};BNResourceManager.prototype.registerResource=function(a){this.registerAndAddResource(a,true)};BNResourceManager.prototype.removeResource=function(a){this.resources[a]=null;delete (this.resources[a])};BNResourceManager.prototype.runCallback=function(callback){if(typeof(callback)=="string"){eval(callback)}else{if(typeof(callback)=="function"){callback()}else{alert("Invalid callback, type="+typeof(callback))}}};if(typeof(bnResourceManager)=="undefined"){var bnResourceManager=new BNResourceManager(baynote_globals.DefaultInjectStrategy)}function BNSystem(){this.testServer=null}BNSystem.prototype.getCookieValue=function(d,b){if(!b){b=baynote_globals.cookieSubDomain}if(b){d+=("-"+b)}var c="(?:; )?"+d+"=([^;]*);?";var a=new RegExp(c);if(a.test(document.cookie)){return decodeURIComponent(RegExp["$1"])}else{return null}};BNSystem.prototype.setCookie=function(h,g,d,e,a,f){g=encodeURIComponent(g);if(e=="NEVER"){var b=new Date();b.setFullYear(b.getFullYear()+500);e=b.toGMTString()}else{if(e=="SESSION"){e=""}}if(d!=""){d=";Path="+d}if(e!=""){e=";expires="+e}if(!a){a=(baynote_globals.cookieDomain)?baynote_globals.cookieDomain:""}if(a!=""){a=";domain="+a}if(!f){f=baynote_globals.cookieSubDomain}if(f){h+=("-"+f)}var c=h+"="+g+e+d+a;if(c.length>4096){return false}document.cookie=c;return true};BNSystem.prototype.removeCookie=function(b,a){this.setCookie(b,"","/","Mon, 1 Jan 1990 00:00:00",a)};BNSystem.prototype.getURLParam=function(c,b){if(!b){var b=window.location.href}var d=new RegExp("[\\?&]"+c+"=([^&#]*)");var a=d.exec(b);if(!a){return null}else{return a[1]}};BNSystem.prototype.getTestServer=function(){if(this.testServer!=null){return this.testServer}var a=this.getURLParam("bn_test");if(a){this.setCookie("bn_test",a,"/","SESSION")}else{if(a==""){this.removeCookie("bn_test")}else{a=this.getCookieValue("bn_test");if(!a){a=""}}}this.testServer=a;return a};if(typeof(bnSystem)=="undefined"){var bnSystem=new BNSystem()}function BNTag(a){if(a){this.id=a.id+1;this.server=a.server;this.customerId=a.customerId;this.code=a.code}else{this.id=0}this.attrs=new Object();this.docAttrs=new Object();this.css=new Object()}BNTag.prototype.getCommonResourceId=function(){return baynote_globals.CommonResourceID};BNTag.prototype.getCommonResourceAddress=function(d){var b="?";for(var c in d){if(c!="server"){b+=c+"="+encodeURIComponent(d[c])+"&"}}var a=b.substring(0,b.length-1);var e=this.server+baynote_globals.CommonResourceURL+a;return e};BNTag.prototype.getFailsafeResourceId=function(){return"Failsafe"};BNTag.prototype.getFailsafeResourceAddress=function(){var a=BaynoteJSVersion.split(" ")[1];var b=bnSystem.getCookieValue("bn_u");return(this.server+baynote_globals.CustomerStatus+"?customerId="+this.customerId+"&code="+this.code+"&v="+a+"&u="+b)};BNTag.prototype.getParam=function(b,a){var c=this[b];if(typeof(c)=="undefined"||c==null){return a}else{return c}};if(typeof(baynote_tag)=="undefined"){window.bn_tags=new Array();var baynote_tag=new BNTag(null)}function bnReadySignal(){bnResourceManager.registerResource(BN_READY_SIGNAL)}function bnCall(a,c,b){var d=bnResourceManager.getResource(a);if(!d){bnResourceManager.waitForResource(a,function(){bnCall(a,c,b)});return}if(typeof(d)!="object"){return}var e=d[c];if(typeof(e)!="function"){return}e.call(d,b)}function bnWaitForCustomerStatus(a){if(!bnCheckCustomerStatus()){var b=baynote_tag.getFailsafeResourceId();bnResourceManager.waitForResource(b,function(){bnWaitForCustomerStatus(a)},baynote_tag.getFailsafeResourceAddress(),"img");return}bnResourceManager.runCallback(a)}function bnCheckCustomerStatus(){var a=baynote_tag.getFailsafeResourceId();if(bnResourceManager.getResource(a)){return true}else{return false}}var BaynoteAPI={};BaynoteAPI.getURLParam=function(b,a){return bnSystem.getURLParam(b,a)};BaynoteAPI.init=function(d){if(!d||!d.server||!d.customerId||!d.code){bnLog.log("ERROR: init called with insufficient arguments - needs server, customerId, code");return}if(!d.timeout){d.timeout=baynote_globals.ServerTimeout}if(!d.onFailure){d.onFailure=baynote_globals.onFailure}var c=bnSystem.getTestServer();if(c){var a=new RegExp("^https?://[^/]*.baynote.(com|net)(:\d+)?(/.*)?");if(a.test(c)){d.server=c}else{bnLog.log('Ignoring invalid test server "'+c+'"')}}if(d.server){baynote_tag.server=d.server}if(d.customerId){baynote_tag.customerId=d.customerId}if(d.code){baynote_tag.code=d.code}var b=baynote_tag.getCommonResourceId();if(!bnResourceManager.getResource(b)){bnResourceManager.waitForResource(b,function(){BaynoteAPI.init(d)},baynote_tag.getCommonResourceAddress(d),"script",d.timeout,d.onFailure)}else{if(!BaynoteIgnored){bnCommon.completePreload(d)}}};BaynoteAPI.execute=function(a,c){var b=baynote_tag.getCommonResourceId();if(typeof(bnResourceManager.getResource(b))=="undefined"){bnLog.log("WARN: common not loaded - exiting execute; consider calling init first");return}else{if(typeof bnCommon=="undefined"){bnResourceManager.waitForResource(b,function(){BaynoteAPI.execute(a,c)});return}}bnCommon.waitAndExecute(a,c)};BaynoteAPI.executeAll=function(b){var a=baynote_tag.getCommonResourceId();if(typeof(bnResourceManager.getResource(a))=="undefined"){bnLog.log("WARN: common not loaded - exiting executeAll; consider calling init first");return}else{if(typeof bnCommon=="undefined"){bnResourceManager.waitForResource(a,function(){BaynoteAPI.executeAll(b)});return}}bnCommon.waitAndExecuteAll(b)};BaynoteAPI.call=function(b,e,a,c){var d=baynote_tag.getCommonResourceId();if(typeof(bnResourceManager.getResource(d))=="undefined"){bnLog.log("WARN: common not loaded - exiting call; consider calling init first");return}else{if(typeof bnCommon=="undefined"){bnResourceManager.waitForResource(d,function(){BaynoteAPI.call(b,e,a,c)});return}}bnCommon.finishCall(b,e,a,c)};BaynoteAPI.isBaynoteIgnored=function(){return BaynoteIgnored};BaynoteAPI.getCookieDomain=function(){var g="";var h=window.location.href;var f=h.indexOf("//");var e=h.substring(f+2);var d=e.indexOf("/");if(d<0){var c=e}else{var c=e.substring(0,d)}var b=c.indexOf(".");var a=c.substring(b+1);a;return g=a};baynote_globals.cookieDomain=BaynoteAPI.getCookieDomain();var preLoadObj={};var bn_locHref=window.location.href;if(bn_locHref.indexOf("https://")==0){preLoadObj.server="https://jjb-sports.baynote.net"}else{preLoadObj.server="http://jjb-sports.baynote.net"}preLoadObj.customerId="jjb";preLoadObj.code="sports";BaynoteAPI.init(preLoadObj);if(typeof(baynoteObserver)=="undefined"||typeof(baynoteObserver)!="boolean"||baynoteObserver){BaynoteAPI.execute("observer")}if(typeof(baynoteGuide)=="undefined"||typeof(baynoteGuide)!="boolean"||baynoteGuide){BaynoteAPI.execute("recommendation")}if(typeof(baynoteDisableAjax)!="undefined"&&typeof(baynoteDisableAjax)=="boolean"&&!baynoteDisableAjax){BaynoteAPI.execute("ajax")};
