var BaynoteJSVersion="$Revision: 1.28 $";var BN_READY_SIGNAL="ReadySignal";if(typeof(baynote_globals)=="undefined"){var baynote_globals=new Object()}baynote_globals.waitForReady=false;baynote_globals.checkStatus=false;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(){this.csQueue=new BNCriticalSectionQueue();this.critSec=null;this.debug=1;this.resources=new Object();this.waiting=new Object()}BNResourceManager.prototype.getResource=function(a){return this.resources[a]};BNResourceManager.prototype.loadResource=function(c,d,b){if(typeof(this.resources[c])!="undefined"){return}this.resources[c]=null;var a=new BNCriticalSection(this.csQueue);a.enter(function(){bnResourceManager.inject(c,d,b,a)})};BNResourceManager.prototype.inject=function(b,g,c,h){this.critSec=h;if(this.debug){bnLog.log("INJECT "+this.critSec.id+" ("+b+")")}if(!c||c=="script"){var a=document.createElement("script");a.language="javascript";a.src=g;var f=document.getElementsByTagName("head");f[0].appendChild(a)}else{if(c=="img"){var d=document.createElement("IMG");var i=function(){bnResourceManager.registerAndAddResource(b,d)};if(d.addEventListener){d.addEventListener("load",i,false)}else{if(d.attachEvent){d.attachEvent("onload",i)}else{d.onload=i}}d.src=g;d.style.display="none";var e=document.getElementById("bn_placeholder_global");if(e!=null){e.appendChild(d)}}else{alert("Unexpected resource type to loadResource: "+c)}}};BNResourceManager.prototype.waitForResource=function(rId,callbackCode,rAddress,rType){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)}}}};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);this.critSec.leave();setTimeout("bnResourceManager.wakeUpWaiting('"+b+"')",5000)};BNResourceManager.prototype.registerResource=function(a){this.registerAndAddResource(a,true)};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()}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()}if(typeof(BNTag)=="undefined"){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"Common"};BNTag.prototype.getCommonResourceAddress=function(a){return(this.server+"/baynote/tags2/common.js")};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/customerstatus2?customerId="+this.customerId+"&code="+this.code+"&x="+this.id+(new Date().getTime())+"&v="+a+"&u="+b)};BNTag.prototype.show=function(b){if(this.id==0){document.write("<span id='bn_placeholder_global'></span>")}this.placeHolderId="bn_placeholder"+this.id;var c;if(this.placeHolderElement){c=this.placeHolderElement}else{c=this.popup?"span":"div"}if(b){var d=document.createElement(c);d.id=this.placeholderId;document.getElementById(b).appendChild(d)}else{document.write("<"+c+" id='"+this.placeHolderId+"'></"+c+">")}window.bn_tags[this.id]=this;var e=bnSystem.getTestServer();if(e){var a=new RegExp("^https?://[^/]*.baynote.(com|net)(:\d+)?(/.*)?");if(a.test(e)){this.server=e}else{alert('Ignoring invalid test server "'+e+'"')}}this.showWhenReady(this);baynote_tag=new BNTag(this)};BNTag.prototype.showWhenReady=function(a){if(baynote_globals.waitForReady&&!bnResourceManager.getResource(BN_READY_SIGNAL)){bnResourceManager.waitForResource(BN_READY_SIGNAL,function(){a.showWhenReady(a)});return}if(baynote_globals.checkStatus){if(!bnCheckCustomerStatus()){bnWaitForCustomerStatus(function(){a.showWhenReady(a)});return}}var b=this.getCommonResourceId();if(!bnResourceManager.getResource(b)){bnResourceManager.waitForResource(b,function(){a.showWhenReady(a)},this.getCommonResourceAddress(),"script");return}bnTagManager.show(a.id)};BNTag.prototype.noshow=function(){window.bn_tags[this.id]=this;baynote_tag=new BNTag(this)};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}};