var xmlLoc="/nuggetv2/12";var xmlhttp;function loadXMLDoc(b){xmlhttp=null;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}}if(xmlhttp!=null){xmlhttp.onreadystatechange=stateChange;xmlhttp.open("GET",b,true);xmlhttp.send(null);
}else{alert("Your browser does not support XMLHTTP.");}return true;}function stateChange(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){setGames();}else{}}}var preGames;var games;function setGames(){try{games=xmlhttp.responseXML.documentElement.getElementsByTagName("game");getGames();}catch(b){console.warn("NHL Scoreboard AJAX Error: "+b);
}}function checkGames(){loadXMLDoc(xmlLoc);var c="";for(var b=0;b<games.length;b++){if(games[b].getAttribute("gamestate")=="In-Progress"||games[b].getAttribute("gamestate")=="Pre-Game"){c="gameOn";}}if(c==""){runGames=window.clearInterval(runGames);}}loadXMLDoc(xmlLoc);var gBehaviorsArray=[];function CancelBehavior(b){if(gBehaviorsArray[b]){gBehaviorsArray[b].cancel();
gBehaviorsArray[b]=null;}}var thisGame=new Array();var thisPreGame=new Array();function getGames(){if(preGames){for(i=0;i<games.length;i++){getGame(games[i].getAttribute("gameId"));thisGame.getGameState();thisGame.getScores({who:"home"});thisGame.getScores({who:"away"});thisGame.getLeaders({who:"home"});
thisGame.getLeaders({who:"away"});thisGame.addClock();}}try{preGames=xmlhttp.responseXML.documentElement.getElementsByTagName("game");}catch(b){console.warn("NHL Scoreboard AJAX Error: "+b);}}function addData(c,b,e,d){table=document.getElementById("board_"+c);if(table){thead=table.getElementsByTagName("THEAD")[0];
tbody=table.getElementsByTagName("TBODY")[0];theadrow=thead.getElementsByTagName("TR")[0];rowLength=theadrow.getElementsByTagName("TH").length-1;if(d){if(theadrow.getElementsByTagName("TH")[rowLength].innerHTML!=d){theadcell=document.createElement("TH");theadcell.innerHTML=d;theadrow.insertBefore(theadcell,theadrow.getElementsByClassName("total")[0]);
thead.appendChild(theadrow);}}tbodyrow=tbody.getElementsByTagName("TR")[0];cell=document.createElement("TD");cell.id=b;cell.innerHTML=e;tbodyrow.insertBefore(cell,tbodyrow.getElementsByClassName("total")[0]);tbody.appendChild(tbodyrow);}}var clockAdded="";var tabStuff;var isCurrentDateInDaylightTime=false;
function addClock(c){var c=c||{};var h=this.state||"Pre-Game";var f=c.gameId||this.id;var g=c.startTime||this.countDownStartTime;if(h=="Pre-Game"&&clockAdded.indexOf(f)==-1){var e=new FSFlashTag("/component/flash/countdownClock",163,116);e.setId("counter_"+f);e.setFlashvars("useDaylightSavings="+isCurrentDateInDaylightTime+"&amp;countdownTime="+g+"&amp;myID=clockHolder_"+f);
e.setWmode("transparent");e.setWmodeFF("transparent");var d=document.createElement("div");d.id="clockHolder_"+f;d.className="clock";d.innerHTML=e;var b=document.getElementById("gameData_"+f);b.insertBefore(d,document.getElementById("gameLeaders_"+f));clockAdded+=f+",";document.getElementById("gameCalls_"+f).style.visibility="hidden";
return;}}function removeClock(b){document.getElementById(b).style.display="none";gc=b.split("_");document.getElementById("gameCalls_"+gc[1]).style.visibility="visible";}function ordinal(d,c){var c=c||{};var g=c.sScript||false;var f=d%100;var e=d%10;var b;if((f-e)==10){b="th";}else{switch(e){case 1:b="st";
break;case 2:b="nd";break;case 3:b="rd";break;default:b="th";break;}}switch(g){case"sub":return d+"<sub>"+b+"</sub>";break;case"sup":return d+"<sup>"+b+"</sup>";break;default:return d+b;break;}}function showAlert(c){var c=c||{};var f=c.notification||null;var e=c.id||this.id;var b=c.boxKey||null;var d;
if(f=="score"){document.getElementById("gameAlert_"+e).className=document.getElementById("gameAlert_"+e).className+" gameScore";if(document.getElementById("gameCalls_"+e).className!="gameScore gameCallsScore"){d=document.getElementById("gameCalls_"+e).innerHTML;document.getElementById("gameCalls_"+e).className=document.getElementById("gameCalls_"+e).className+" gameCallsScore";
document.getElementById("gameAlert_"+e).style.opacity="100";var g=function(){gBehaviorsArray["update"]=Spry.Effect.DoFade("gameAlert_"+e,{duration:3000,from:100,to:0});};setTimeout(g,5000);}}if(b){gBehaviorsArray["update"]=Spry.Effect.DoHighlight(b,{duration:9000,from:"#FB9A00",to:"#fff",restoreColor:"#fff",finish:function(){if(f=="score"){document.getElementById("gameAlert_"+e).className="gameAlert";
document.getElementById("gameCalls_"+e).className="gameCalls";document.getElementById("gameCalls_"+e).innerHTML=d;}}});}}var scoreToggle="score";function getScores(f){var f=f||{};var h=f.who||null;var d=f.what||scoreToggle;var b=f.toggle||scoreToggle;var j=0;switch(h){case"away":var c=this.awayLineScores;
var g=thisPreGame.awayLineScores;break;case"home":var c=this.homeLineScores;var g=thisPreGame.homeLineScores;break;}for(l=0;l<c.length;l++){period=c[l].getAttribute("period");nameKey=h+"Quarter_"+period+"_"+this.id;lastPlay=this.lastPlay;if(!document.getElementById(nameKey)){if(h=="home"){addData(this.id,nameKey,c[l].getAttribute(d),period);
}else{addData(this.id,nameKey,c[l].getAttribute(d));}}else{try{for(a=1;a<=2;a++){tabKey=document.getElementById("ssToggle"+a+"_"+this.id);if(tabKey){if(tabKey.className=="tabScore_on"){d=tabKey.innerHTML.toLowerCase();}}}}catch(k){}try{if(g[l].getAttribute(d)){if(g[l].getAttribute(d)!=c[l].getAttribute(d)){document.getElementById(nameKey).innerHTML=c[l].getAttribute(d);
showAlert({notification:d,id:this.id,boxKey:nameKey});if(d=="score"){document.getElementById("gameCalls_"+this.id).innerHTML=this.whoScored.getAttribute("alias")+" Goal: "+this.whoScored.getAttribute("firstname")+" "+this.whoScored.getAttribute("lastname");}}}}catch(k){}if(document.getElementById(nameKey)){document.getElementById(nameKey).innerHTML=c[l].getAttribute(d);
}}j=j+parseFloat(c[l].getAttribute(d));}if(this.state=="Final"){getWinners({id:this.id,sHome:this.homeTotalScore,sAway:this.awayTotalScore});}document.getElementById(h+"Quarter_to_"+this.id).innerHTML=j;}function addLinks(b,d){var d=d||{};var g=d.node||"";var f=d.attribute||"url";var j=d.display||"";
var c=d.get||false;var h=d.target||false;if(links[b].getElementsByTagName(g)[0]){if(c==false){if(links[b].getElementsByTagName(g)[0].getAttribute(f)==""){return"";}else{var e="<a href='"+links[b].getElementsByTagName(g)[0].getAttribute(f)+"' ";if(h){e+="target='"+h+"' ";}e+="title='"+j+"'>"+j+"</a> | ";
return e;}}else{return links[b].getElementsByTagName(g)[0].getAttribute(f);}}else{return"";}}function getWinners(m){try{var m=m||{};var k=m.id;var b=m.sHome||this.homeTotalScore;var h=m.sAway||this.awayTotalScore;var d=document.getElementById("board_"+k).getElementsByTagName("TD");var c=new Array();var j=0;
for(var g=0;g<d.length;g++){if(d[g].className=="teams"){c[j]=d[g];j++;}}if(b<h&&d[0].className!="teams winner"){c[0].className="teams winner";return;}if(b>h&&d[0].className!="teams winner"){c[1].className="teams winner";return;}if(b==h){c[0].className="teams winner";c[1].className="teams winner";return;
}}catch(f){}}function getGameState(){try{gameState=this.state;gameStatus="";gameSeriesStanding=this.seriesStanding;gameTimeKey="gameStateInfo_"+this.id;gameLeaderStatus="gameLeaderStats_"+this.id;gameCalls="gameCalls_"+this.id;gameCallsHolder=document.getElementById(gameCalls);gameLinksHolder=document.getElementById("gameLinks_"+this.id);
holder=document.getElementById("holder_"+this.id);links=this.links;linkTags="";var b=document.getElementById("gameLeaders_"+this.id).getElementsByTagName("A");if(b){for(var h=0;h<b.length;h++){if(b[h].className=="completeStats"){b=b[h];}}}switch(gameState){case"Final":gameStatus=this.state;document.getElementById(gameLeaderStatus).innerHTML="Game Stats";
document.getElementById("tab1leaders_"+this.id).innerHTML="Points";document.getElementById("tab2leaders_"+this.id).innerHTML="SOG";document.getElementById("tab3leaders_"+this.id).innerHTML="Saves";for(l=0;l<links.length;l++){linkTags+=addLinks(l,{node:"recap",display:"Recap"});linkTags+=addLinks(l,{node:"gametracker",display:"GameTrax"});
linkTags+=addLinks(l,{node:"boxscore",display:"Box Score"});linkTags+=addLinks(l,{node:"playbyplay",display:"Play-By-Play"});linkTags+=addLinks(l,{node:"depthchart",display:"Depth Chart"});linkTags+=addLinks(l,{node:"statMatchup",display:"Head-to-Head"});b.href=addLinks(l,{get:true,node:"boxscore",attribute:"url"});
}break;case"In-Progress":gameStatus=this.segmentTime+" - "+ordinal(this.segmentNumber)+" Period";document.getElementById(gameLeaderStatus).innerHTML="Game Stats";document.getElementById("tab1leaders_"+this.id).innerHTML="Points";document.getElementById("tab2leaders_"+this.id).innerHTML="SOG";document.getElementById("tab3leaders_"+this.id).innerHTML="Saves";
for(l=0;l<links.length;l++){linkTags+=addLinks(l,{node:"gametracker",display:"GameTrax"});linkTags+=addLinks(l,{node:"boxscore",display:"Box Score"});linkTags+=addLinks(l,{node:"playbyplay",display:"Play-By-Play"});linkTags+=addLinks(l,{node:"depthchart",display:"Depth Chart"});linkTags+=addLinks(l,{node:"statMatchup",display:"Head-to-Head"});
b.href=addLinks(l,{get:true,node:"boxscore",attribute:"url"});}break;case"Pre-Game":gameStatus=this.startTime;document.getElementById(gameLeaderStatus).innerHTML="Team Leaders";document.getElementById("tab1leaders_"+this.id).innerHTML="Goals";document.getElementById("tab2leaders_"+this.id).innerHTML="Points";
document.getElementById("tab3leaders_"+this.id).innerHTML="GAA";for(l=0;l<links.length;l++){linkTags+=addLinks(l,{node:"preview",display:"Preview"});linkTags+=addLinks(l,{node:"gametracker",display:"GameTrax"});linkTags+=addLinks(l,{node:"depthchart",display:"Depth Chart"});linkTags+=addLinks(l,{node:"statMatchup",display:"Head-to-Head"});
linkTags+=addLinks(l,{node:"buytickets",display:"Buy Tickets",attribute:"homeUrl",target:"_blank"});linkTags+=addLinks(1,{node:"odds",display:"Odds",attribute:"url"});b.href="/nhl/stats";}break;}if(gameState=="Halftime"){if(gameCallsHolder.innerHTML!=gameState){gameCallsData=gameCallsHolder.innerHTML;
gameCallsHolder.innerHTML=gameState;}}else{if(thisPreGame.state=="Halftime"&&gameState!="Halftime"){gameCallsHolder.innerHTML=gameCallsData;gameCallsData="";}}holder.className="gamesBox "+gameState;if(gameStatus){var g=document.getElementById(gameTimeKey);var d=function(){g.className="left";};var m=this.segmentTime;
if(m!=thisPreGame.segmentTime){g.className="left on";g.innerHTML=gameStatus;if(gameSeriesStanding!=""){g.innerHTML+="&nbsp;&nbsp;-&nbsp;&nbsp;"+gameSeriesStanding;}setTimeout(d,2000);}else{g.innerHTML=gameStatus;if(gameSeriesStanding!=""){g.innerHTML+="&nbsp;&nbsp;-&nbsp;&nbsp;"+gameSeriesStanding;}}}var j="gamePlays_"+this.id;
var k=this.lastPlay;var f=document.getElementById(j);if(f&&k){f.className="";if(k!=thisPreGame.lastPlay){try{gBehaviorsArray["lp"]=Spry.Effect.DoFade(j,{duration:500,from:100,to:0,finish:function(){f.innerHTML=k;gBehaviorsArray["lp"]=Spry.Effect.DoFade(j,{duration:500,from:0,to:100});}});}catch(c){}}else{f.innerHTML=k;
}}if(linkTags!=""){gameLinksHolder.innerHTML=linkTags.substr(0,linkTags.length-2);}}catch(c){}}function getLeaders(m){try{var m=m||{};var k=m.who||null;var f=m.toggle||false;var j=m.what||thisPreGame.leadersToggle;var h;if(!j){switch(this.state){case"Final":this.leadersToggle="points";thisPreGame.leadersToggle="points";
break;case"Pre-Game":this.leadersToggle="goals";thisPreGame.leadersToggle="goals";break;case"In-Progress":this.leadersToggle="points";thisPreGame.leadersToggle="points";break;}}else{this.leadersToggle=thisPreGame.leadersToggle;thisPreGame.leadersToggle=j;}if(k){switch(k){case"away":var c=this.awayLeaders;
var d=this.awayAlias;break;case"home":var c=this.homeLeaders;var d=this.homeAlias;break;}}for(var b=0;b<c.length;b++){switch(c[b].getAttribute("type")){case"points":lPoints=c[b].getAttribute("stat");if(this.leadersToggle=="points"){lGoals=c[b].getAttribute("goals");lAssists=c[b].getAttribute("assists");
}break;case"assists":if(this.leadersToggle!="points"){lAssists=c[b].getAttribute("stat");}break;case"goals":if(this.leadersToggle!="points"){lGoals=c[b].getAttribute("stat");}break;case"saves":lSaves=c[b].getAttribute("stat");break;case"GAA":lGaa=c[b].getAttribute("stat");break;case"SV%":lSV=c[b].getAttribute("stat");
lSVSaves=c[b].getAttribute("saves");break;case"SOG":lSog=c[b].getAttribute("stat");break;}}for(b=0;b<c.length;b++){nameKey=k+"PlayerName_"+this.id;nameAtt=thisPreGame.leadersToggle;for(a=1;a<4;a++){tabKey=document.getElementById("tab"+a+"leaders_"+this.id);if(tabKey){if(tabKey.className=="tlTabs_on"){if(c[b].getAttribute("type").toLowerCase()==tabKey.innerHTML.toLowerCase()){if(document.getElementById(nameKey)){if(c[b].getAttribute("lastname").indexOf("Tied")!=-1||c[b].getAttribute("lastname")==""){h="";
}else{h=". "+c[b].getAttribute("lastname");}document.getElementById(nameKey).innerHTML=c[b].getAttribute("firstname").substring(0,1)+h;}if(document.getElementById(k+"Alias_"+this.id)){document.getElementById(k+"Alias_"+this.id).innerHTML=d;type=tabKey.innerHTML.substring(0,1).toUpperCase()+tabKey.innerHTML.substr(1);
}switch(tabKey.innerHTML.toLowerCase()){case"points":if(this.state=="Pre-Game"){document.getElementById(k+"Goals_"+this.id).innerHTML=lPoints+" "+type;}else{lGoals=lGoals|"0";lAssists=lAssists|"0";document.getElementById(k+"Goals_"+this.id).innerHTML=lGoals+"G, "+lAssists+"A";}if(lPoints==""){document.getElementById(k+"Goals_"+this.id).innerHTML="No Points Scored";
}if(c[b].getAttribute("lastname").indexOf("Tied")!=-1&&lPoints==0){document.getElementById(nameKey).innerHTML="";document.getElementById(k+"Goals_"+this.id).innerHTML="No Points Scored";}break;case"goals":if(lGoals==""){document.getElementById(k+"Goals_"+this.id).innerHTML="No Goals Scored";}else{document.getElementById(k+"Goals_"+this.id).innerHTML=lGoals+" "+type;
}if(c[b].getAttribute("lastname").indexOf("Tied")!=-1&&lGoals==0){document.getElementById(nameKey).innerHTML="";document.getElementById(k+"Goals_"+this.id).innerHTML="No Goals Scored";}break;case"saves":if(lSaves==""){document.getElementById(k+"Goals_"+this.id).innerHTML="0 SV, 1.000 SV%";}else{document.getElementById(k+"Goals_"+this.id).innerHTML=lSVSaves+" SV, "+lSV+" SV%";
}break;case"gaa":document.getElementById(k+"Goals_"+this.id).innerHTML=lGaa+" GAA";break;case"sog":if(lSog==""){document.getElementById(k+"Goals_"+this.id).innerHTML="No Shots on Goal";}else{document.getElementById(k+"Goals_"+this.id).innerHTML=lSog+" SOG";}if(c[b].getAttribute("lastname").indexOf("Tied")!=-1&&lSog==0){document.getElementById(nameKey).innerHTML="";
document.getElementById(k+"Goals_"+this.id).innerHTML="No Shots on Goal";}break;}}}}}}}catch(g){}}function getPreGame(b){try{for(i=0;i<preGames.length;i++){if(preGames[i].getAttribute("gameId")==b){thisPreGame[preGames[i].getAttribute("gameId")]=new Object();thisPreGame.id=preGames[i].getAttribute("gameId");
thisPreGame.state=preGames[i].getAttribute("gamestate");thisPreGame.seriesStanding=preGames[i].getAttribute("seriesStanding");thisPreGame.segmentTime=preGames[i].getAttribute("segment-time");thisPreGame.lastPlay=preGames[i].getElementsByTagName("lastPlay")[0].getAttribute("description");thisPreGame.homeLineScores=preGames[i].getElementsByTagName("gamestats")[0].getElementsByTagName("home")[0].getElementsByTagName("linescores")[0].getElementsByTagName("linescore");
thisPreGame.awayLineScores=preGames[i].getElementsByTagName("gamestats")[0].getElementsByTagName("away")[0].getElementsByTagName("linescores")[0].getElementsByTagName("linescore");return thisPreGame;}}return;}catch(c){}}function getGame(b){thisPreGame=getPreGame(b);for(i=0;i<games.length;i++){if(games[i].getAttribute("gameId")==b){thisGame[games[i].getAttribute("gameId")]=new Object();
thisGame.id=games[i].getAttribute("gameId");thisGame.state=games[i].getAttribute("gamestate");thisGame.status=games[i].getAttribute("status");thisGame.seriesStanding=games[i].getAttribute("seriesStanding");thisGame.countDownStartTime=games[i].getAttribute("countdownStartTime");thisGame.date=games[i].getAttribute("date");
thisGame.gameDate=games[i].getAttribute("YYYYMMDD");thisGame.startTime=games[i].getAttribute("startTime");thisGame.segmentTime=games[i].getAttribute("segment-time");thisGame.segmentNumber=games[i].getAttribute("segment-number");thisGame.lastPlay=games[i].getElementsByTagName("lastPlay")[0].getAttribute("description");
thisGame.whoScored=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("lastgoal")[0];thisGame.links=games[i].getElementsByTagName("links");thisGame.homeAlias=games[i].getElementsByTagName("home")[1].getAttribute("alias");thisGame.homeLeaders=games[i].getElementsByTagName("home")[1].getElementsByTagName("leader");
thisGame.homeLineScores=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("home")[0].getElementsByTagName("linescores")[0].getElementsByTagName("linescore");thisGame.homeTotalScore=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("home")[0].getElementsByTagName("linescores")[0].getAttribute("totalscore");
thisGame.homeTotalShots=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("home")[0].getElementsByTagName("linescores")[0].getAttribute("shots");thisGame.awayLineScores=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("away")[0].getElementsByTagName("linescores")[0].getElementsByTagName("linescore");
thisGame.awayTotalScore=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("away")[0].getElementsByTagName("linescores")[0].getAttribute("totalscore");thisGame.awayTotalShots=games[i].getElementsByTagName("gamestats")[0].getElementsByTagName("away")[0].getElementsByTagName("linescores")[0].getAttribute("shots");
thisGame.awayLeaders=games[i].getElementsByTagName("away")[1].getElementsByTagName("leader");thisGame.awayAlias=games[i].getElementsByTagName("away")[1].getAttribute("alias");thisGame.getLeaders=getLeaders;thisGame.getScores=getScores;thisGame.addClock=addClock;thisGame.getWinners=getWinners;thisGame.getGameState=getGameState;
return thisGame;}}return false;}function infoToggle(k,m){var m=m||{};var h=m.what||k.innerHTML.toLowerCase();var f=m.other||false;var c=k.parentNode.getElementsByTagName("A");var j=k.className.split("_");for(var e=0;e<c.length;e++){if(c[e].className==j[0]+"_on"){c[e].className=j[0]+"_off";}}k.className=j[0]+"_on";
elemId=k.id.split("_");if(f==false){var b=getGame(elemId[1]);if(h){if(h=="score"||h=="shots"){scoreToggle=h;thisGame.getScores({who:"home",what:h,toggle:h});thisGame.getScores({who:"away",what:h,toggle:h});}else{b.getLeaders({who:"home",what:h});b.getLeaders({who:"away",what:h});}}}else{var d=document.getElementById("board_"+elemId[1]).getElementsByTagName("TBODY");
switch(h){case"score":d[1].className="off";d[0].className="";break;case"shots":d[1].className="";d[0].className="off";break;}if(j[0]=="tlTabs"){var g=k.parentNode.getElementsByTagName("DIV");for(var e=0;e<g.length;e++){if(g[e].className.indexOf("teamGameLeaders on")!=-1){g[e].className=g[e].className.replace(" on","");
}if(g[e].id=="team"+k.innerHTML.replace(" ","")+"Leaders_"+elemId[1]){g[e].className=g[e].className+" on";}}}}}function showTab(f,g){var h=f.parentNode.parentNode.childNodes;var c=f.parentNode.parentNode.parentNode.childNodes;var b=document.getElementById(g);var e;for(var d=0;d<c.length;d++){if(c[d].className=="info on"){c[d].className="info";
b.className="info on";}if(c[d].className=="teamGameLeaders on"){c[d].className="teamGameLeaders";b.className="teamGameLeaders on";}}for(var d=0;d<h.length;d++){if(h[d].className=="on"){h[d].className="";f.parentNode.className="on";return;}}}function loadAds(){dapMgr.enableACB("ad300x250box",false);dapMgr.renderAd("ad300x250box",adCode300x250,300,250);
dapMgr.enableACB("ad728x90box",false);dapMgr.renderAd("ad728x90box",adCode728x90,728,90);}function pageRefresh(){location.reload(true);}var pageTimer=setTimeout("pageRefresh()",600000);setInterval(serveAdRefreshViaMSFT,60000);function serveAdRefreshViaMSFT(){dapMgr.trackEvent(eventType.click);fsAnalytics(this,{type:"keepAlive",description:"NHL AJAX Scoreboard",pageView:true});
}
