var init=function(){getMyData();};var dataLoaded=function(){if(global.temp.myData.Categories){global.myData.child.Categories=global.temp.myData.Categories;delete global.temp.myData.Categories;}else{global.myData.child.Categories={};}global.temp.location=global.myData;if(global.myData.child.Leagues){for(var l in global.myData.child.Leagues){for(var c in global.myData.child.Leagues[l].child.Conferences){var thisTeams={};for(var d in global.myData.child.Leagues[l].child.Conferences[c].child.Divisions){for(var t in global.myData.child.Leagues[l].child.Conferences[c].child.Divisions[d].child.Teams){thisTeams[t]=global.myData.child.Leagues[l].child.Conferences[c].child.Divisions[d].child.Teams[t];}}if(global.myData.child.Leagues[l].child.Conferences[c].child.Divisions){global.myData.child.Leagues[l].child.Conferences[c].child.Teams=thisTeams;delete global.myData.child.Leagues[l].child.Conferences[c].child.Divisions;}}if(!global.myData.child.Categories[l]){global.myData.child.Categories[l]={child:{Feeds:{Teams:{}}}};}global.myData.child.Categories[l].child.Feeds.Teams={child:{Conferences:global.myData.child.Leagues[l].child.Conferences}};}delete global.myData.child.Leagues;}global.config.myCnt=document.getElementById("rssContainer");if(!global.temp.loggedIn){document.getElementById("viewSwitch").innerHTML="";}createPanel(0);};var getHTTPObject=function(){try{return new XMLHttpRequest();}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}return false;};var getMyData=function(){var http=new getHTTPObject();var url=encodeURI("http://"+global.config.host+"/data/getAllLeagueData?as=json&filters=customize=teams&r="+Math.floor(Math.random()*new Date().getTime()));http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var data=eval("("+http.responseText+")");global.myData=data.content;dataLoaded();}};http.open("GET",url,true);http.send(null);};var switchView=function(viewSwitch){global.temp.showAll=!(global.temp.showAll);viewSwitch.innerHTML=(viewSwitch.innerHTML=="+ Show All Teams")?"+ Show My Teams Only":"+ Show All Teams";createPanel(global.temp.showPanel,global.temp.selectedCat,global.temp.selectedItem);};var rebuildLocation=function(showPanel,selectedCat,selectedItem){var location=global.myData;global.temp.hierarchy[showPanel-1]=selectedItem;global.temp.hierarchyMap[showPanel-1]=selectedCat;for(var h=0;h<showPanel;h++){var thisPanel=document.getElementById(showPanel+":"+selectedCat+":"+selectedItem);location=location.child[global.temp.hierarchyMap[h]][global.temp.hierarchy[h]];}return location;};var createPanel=function(showPanel,selectedCat,selectedItem){var myPanel=document.getElementById("panel"+showPanel);if(selectedItem){global.temp.location=rebuildLocation(showPanel,selectedCat,selectedItem);}for(var i=showPanel;i<global.config.hPanels;i++){var thisPanel=document.getElementById("panel"+i);thisPanel.innerHTML='<li class="section"></li>';thisPanel.style.display="none";if(i>showPanel){delete global.temp.hierarchy[i];}delete global.temp.lastSelected[i];}if(!global.temp.location.child){showPanel=global.config.hPanels;myPanel=document.getElementById("panel"+showPanel);}if(showPanel==global.config.hPanels||!global.temp.location.child){var output="";var thisLabel=global.temp.location.label;var thisURL=global.temp.location.url;var thisIcon=(global.temp.location.icon!="")?global.temp.location.icon:"http://images.cbssports.com/images/spacer.gif";var thisId=global.temp.hierarchy.join(":");if(document.getElementById("feedLine-"+thisId)){return 1;}output+='<div class="feedLine" id="feedLine-'+thisId+'">';output+=' <div class="data"><img class="icon" src="'+thisIcon+'"> '+thisLabel+"</div>";output+=' <div class="feeds">';for(var i=0;i<global.config.readers.length;i++){var readerClass=global.config.readers[i]["class"];var readerLabel=global.config.readers[i].label;var readerURL=global.config.readers[i].url.replace(/::URL::/,thisURL);output+='  <a href="'+readerURL+'" class="feed '+readerClass+'"><img src="http://images.cbssports.com/images/spacer.gif" class="icon"> '+readerLabel+"</a>";}output+=" </div>";output+=' <div class="closeBtn">';output+='  <a href="javascript: void(0);" id="'+thisId+'" onclick="closeFeed(this); return false;" class="close"><img src="http://images.cbssports.com/images/xml/rss/x-close.gif" class="icon" width="11" height="13"></a>';output+=" </div>";output+="</div>";myPanel.innerHTML+=output;}else{global.temp.showPanel=showPanel;global.temp.selectedCat=selectedCat;global.temp.selectedItem=selectedItem;myPanel.style.display="block";var output=" ";var numItems=0;for(var c in global.temp.location.child){output+='<li class="section">'+c+"</li>";var thisKeys=[];for(var d in global.temp.location.child[c]){thisKeys.push(d);}thisKeys.sort();for(var d in thisKeys){var customText="";if(!global.temp.showAll&&global.temp.location.child[c][thisKeys[d]].customization){if(global.temp.location.child[c][thisKeys[d]].customization=="none"){continue;}else{customText='<span class="customText">('+global.temp.location.child[c][thisKeys[d]].customization+")</span>";}}var thisName=(global.temp.location.child[c][thisKeys[d]].name)?global.temp.location.child[c][thisKeys[d]].name:thisKeys[d];var arrow=(global.temp.location.child[c][thisKeys[d]].child)?'<span class="subArrow"><img src="http://images.cbssports.com/images/xml/rss/arrow.gif" width="8" height="8" border="0"></span>':"";output+='<li class="item"><a href="javascript: void(0);" id="'+showPanel+":"+c+":"+thisKeys[d]+'" onclick="myOnChange(this); return false;">'+thisName+" "+customText+" "+arrow+"</a></li>";numItems++;}}if(numItems){myPanel.innerHTML=output;}else{myPanel.style.display="none";}}return 1;};var isInArray=function(item,arr){for(var i in arr){if(arr[i]==item){return true;}}return false;};var myOnChange=function(theItem){var thisId=theItem.id.split(":");var thisPanel=thisId[0];var thisCat=thisId[1];var thisItem=thisId[2];if(global.temp.lastSelected[thisPanel]){document.getElementById(global.temp.lastSelected[thisPanel]).className="";}theItem.className="selected";theItem.blur();global.temp.lastSelected[thisPanel]=theItem.id;thisPanel++;createPanel(thisPanel,thisCat,thisItem);};var closeFeed=function(el){var id=document.getElementById("feedLine-"+el.id);(id.parentNode).removeChild(id);return 1;};