var roundSelector={totalWidth:0,left_pos:0,roundId:0,visibleArea:0,init:function(){this.left_pos=parseInt($("#roundNumberScrollWrapper").css("left"));this.visibleArea=parseInt($("#roundNumberContainer").innerWidth());this.setWrapperWidth();$("#roundsScrollLeft").bind("click",function(){$(this).blur();roundSelector.scrollLeft();return false;});$("#roundsScrollRight").bind("click",function(){$(this).blur();roundSelector.scrollRight();return false;});$("#roundNumberScrollWrapper div.rndDiv a").bind("click",function(){$(this).blur();var c=parseInt($(this).attr("title"));var a=parseInt($("#roundSelectorScroll").attr("class").replace("league",""));var b=self.location.pathname.replace(new RegExp("^/([^/]+).*$"),"$1");$.getJSON("/"+b+"/scores/json-round-results",{leagueId:a,round:c},function(d){roundSelector.populateResultsTable(d.matches);roundSelector.setSelectedRound(parseInt(d.roundNum),d.roundName);});return false;});if($("#roundNumberScrollWrapper").hasClass("scrollLast")){this.scrollLast();}},scrollLast:function(){while(this.visibleArea+((-1)*this.left_pos)<this.totalWidth){this.scrollRight();}},clearSelectedRound:function(){$("#roundNumberScrollWrapper div.currentRound a").each(function(){$(this).text($(this).attr("title"));});$("#roundNumberScrollWrapper div.currentRound").removeClass("currentRound");},setSelectedRound:function(b,a){a=(a==="")?b:a;this.clearSelectedRound();$("#rndDiv"+b).addClass("currentRound");$("#rndDiv"+b+" a").text(a);this.setWrapperWidth();},scrollRight:function(){if(this.visibleArea+((-1)*this.left_pos)<this.totalWidth){this.left_pos=(this.left_pos-24);$("#roundNumberScrollWrapper").css("left",this.left_pos+"px");}},scrollLeft:function(){if(this.left_pos<0){this.left_pos=((this.left_pos+24)<0)?this.left_pos+24:0;$("#roundNumberScrollWrapper").css("left",this.left_pos+"px");}},setWrapperWidth:function(){roundSelector.totalWidth=0;$("#roundNumberScrollWrapper div.rndDiv").each(function(){roundSelector.totalWidth+=$(this).outerWidth();});$("#roundNumberScrollWrapper").width(roundSelector.totalWidth+2);},populateResultsTable:function(a){var b=$("#roundResultsTable tr");b.remove();for(i in a){dataRow=document.createElement("tr");opponentsCell=document.createElement("td");opponentsCell.className="matchClubs";matchLink=document.createElement("a");matchLink.href=a[i].url;matchLink.appendChild(document.createTextNode(a[i].team1_name+" - "+a[i].team2_name));opponentsCell.appendChild(matchLink);dataRow.appendChild(opponentsCell);scoreCell=document.createElement("td");scoreCell.appendChild(document.createTextNode(a[i].team1_result+" - "+a[i].team2_result));scoreCell.className="matchScore";dataRow.appendChild(scoreCell);timeDateCell=document.createElement("td");timeDateCell.appendChild(document.createTextNode(a[i].date));timeDateCell.className="matchDateTime";dataRow.appendChild(timeDateCell);liveCell=document.createElement("td");liveCell.appendChild(document.createTextNode(" "));liveCell.className="matchLiveIndicator";dataRow.appendChild(liveCell);$("#roundResultsTable tbody").append(dataRow);}}};jQuery(document).ready(function(){roundSelector.init();});