var a;
function overlayInit(){YAHOO.ballhype.addModulePanel=new YAHOO.widget.Panel("add_module",{width:"630px",underlay:"shadow",close:true,visible:false,draggable:true,effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25}});YAHOO.ballhype.addModulePanel.setHeader("Choose "+YAHOO.ballhype.siNa+" Content");var b=new YAHOO.util.KeyListener(document,{keys:27},{fn:YAHOO.ballhype.addModulePanel.hide,scope:YAHOO.ballhype.addModulePanel,correctScope:true});YAHOO.ballhype.addModulePanel.cfg.queueProperty("keylisteners",b);
YAHOO.ballhype.addModulePanel.render()}
function showPanel(){if(YAHOO.ballhype.uli){var b=document.getElementById("addModuleBody"),c=YAHOO.ballhype.addModulePanel.cfg.getProperty("x");c=YAHOO.ballhype.addModulePanel.cfg.getProperty("y");YAHOO.ballhype.addModulePanel.moveTo(150,c);YAHOO.ballhype.addModulePanel.show();b={success:function(d){d.argument[0].innerHTML=d.responseText;d=new YAHOO.widget.TabView("left_tab_set",{orientation:"left"});setupButton()},failure:function(d){},argument:[b]};b=YAHOO.util.Connect.asyncRequest("GET","/module/panel/",
b,null)}else showLoginOverlay(1,"wideright.","customizing your dashboard")}function loadComponent(b,c){var d=b[c],e=document.getElementById(d.id);b={success:function(f){f.argument[0].innerHTML=f.responseText;f.argument[2].onload&&f.argument[2].onload.call();c+1<f.argument[1].length&&loadComponent(f.argument[1],c+1)},failure:function(f){},argument:[e,b,d]};d=YAHOO.util.Connect.asyncRequest("GET",d.path+"?max="+d.max_items,b,null)}
YAHOO.ballhype.DDList=function(b,c,d){if(b){this.init(b,c,d);this.initFrame()}b=this.getDragEl().style;b.borderColor="transparent";b.backgroundColor="#f6f5e5";b.opacity=0.76;b.filter="alpha(opacity=76)"};YAHOO.extend(YAHOO.ballhype.DDList,YAHOO.util.DDProxy);YAHOO.ballhype.DDList.prototype.startDrag=function(){var b=this.getDragEl(),c=this.getEl();b.innerHTML=c.innerHTML;b.className=c.className;b.style.color=c.style.color;b.style.border="1px solid blue";c.className="dragged"};
function checkBoundaryHeight(){YAHOO.util.Dom.getElementsByClassName("sortListWrapper","div",document.getElementById("col.0")).length===0?YAHOO.util.Dom.setStyle("col.0.bottom","height","300px"):YAHOO.util.Dom.setStyle("col.0.bottom","height","50px");YAHOO.util.Dom.getElementsByClassName("sortListWrapper","div",document.getElementById("col.1")).length===0?YAHOO.util.Dom.setStyle("col.1.bottom","height","300px"):YAHOO.util.Dom.setStyle("col.1.bottom","height","50px")}a=YAHOO.ballhype.DDList.prototype;
a.endDrag=function(){this.getEl().className=this.getDragEl().className;if(!YAHOO.util.Event.isIE){var b=YAHOO.util.Dom.getXY(this.getEl());YAHOO.util.DDM.moveToEl(this.getEl(),this.getDragEl());(new YAHOO.util.Motion(this.id,{points:{to:b}},0.3,YAHOO.util.Easing.easeOut)).animate()}b=[document.getElementById("col.0"),document.getElementById("col.1")];for(var c="?",d=0;d<b.length;d++)for(var e=0,f=0;f<b[d].childNodes.length;f++)if(b[d].childNodes[f].nodeType===1&&b[d].childNodes[f].className==="sortListWrapper"){c+=
b[d].childNodes[f].id+"="+d+"."+e+"&";e++}checkBoundaryHeight();YAHOO.ballhype.uli&&YAHOO.util.Connect.asyncRequest("GET","/component/update/"+c,null,null)};a.b4MouseDown=function(b){this.clickValidator(b)&&YAHOO.ballhype.DDList.superclass.b4MouseDown.call(this,b)};a.onDrag=function(){};
a.onDragOver=function(b,c){c="string"===typeof c?YAHOO.util.DDM.getElement(c):YAHOO.util.DDM.getBestMatch(c).getEl();var d=YAHOO.util.DDM.getPosY(c)+Math.floor(c.offsetTop/2);if(this.getEl().parentNode!==c.parentNode||YAHOO.util.Event.getPageY(b)<d){b=this.getEl();d=c.parentNode;d.insertBefore(b,c)}};a.onDragEnter=function(){this.getDragEl().style.border="1px solid #0f0"};a.onDragOut=function(){this.getDragEl().style.border="1px solid #f00"};a.toString=function(){return"DDList "+this.id};
YAHOO.ballhype.DDListBoundary=function(b,c,d){if(b){this.init(b,c,d);this.isBoundary=true}};YAHOO.extend(YAHOO.ballhype.DDListBoundary,YAHOO.util.DDTarget);YAHOO.ballhype.DDListBoundary.prototype.toString=function(){return"DDListBoundary "+this.id};
function updateStatus(b){var c=document.getElementById("south");c.innerHTML=b+' successfully added.  <a href="javascript:YAHOO.ballhype.addModulePanel.hide();">[finished]</a>';c.style.color="#fff";c.style.backgroundColor="#F90";b=setTimeout("unhighlight()",500)}function getMaxLink(b,c,d){return c===d?"<b>"+c+"</b>":'<a href="javascript:setMaxItems('+b+", "+c+');">'+c+"</a>"}
function getMaxLinkContent(b,c){var d="Max Items: "+getMaxLink(b,5,c)+" | ";d+=getMaxLink(b,10,c)+" | "+getMaxLink(b,20,c);return d}function getComponentOnload(b){return b==="/component/sports/"?YAHOO.ballhype.autoComplete.init:setupHovers}
function showNewItem(b,c,d){b=document.getElementById("licontent."+b);b={success:function(e){e.argument[0].innerHTML=e.responseText;(e=getComponentOnload(e.argument[1]))&&e.call()},failure:function(e){},argument:[b,c]};c=YAHOO.util.Connect.asyncRequest("GET",c+"?max="+d,b,null)}
function addItem(b,c,d,e,f,l){var k=document.getElementById("col.0");k={success:function(i){var g=eval("("+i.responseText+")");updateStatus(g.title);var h='<div class="sortList"><div id="lihandle.'+g.id+'" class="sortHandle">\n';h+='<div class="right"><a href="javascript:removeComponent('+g.id+');" title="Remove Component"><img src="/media/img/icon/close.png" width="17" height="17" alt="Remove"/></a></div>\n';h+='<a href="'+g.path+'">'+g.title+"</a></div>\n";h+='<div id="licontent.'+g.id+'" class="sortBody"><div class="center"><img src="/media/img/loading.gif" width="32" height="32" alt="Loading" class="loading"></div></div>\n';
h+='<div class="componentFooterLeft" id="max.'+g.id+'">'+getMaxLinkContent(g.id,g.max_items)+"</div>\n";h+='<div class="componentFooterRight"><a href="'+g.path+'">More</a></div>\n';h+='<div class="clearer"></div></div>';var j=document.createElement("div");j.className="sortListWrapper";j.id="li."+g.id;i.argument[0].insertBefore(j,i.argument[0].firstChild);j.innerHTML=h;i=new YAHOO.ballhype.DDList("li."+g.id);i.setHandleElId("lihandle."+g.id);showNewItem(g.id,"/component"+g.path,g.max_items)},failure:function(i){},
argument:[k]};b=YAHOO.util.Connect.asyncRequest("GET","/component/add/?path="+encodeURI(b)+"&league="+c+"&profile="+d+"&blog="+e+"&entity="+f+"&location="+l,k,null)}function addFavoriteBlogs(b,c){var d="/favorites/blogs/";if(c.length>0)d="/blog";addItem(d,"",b,c,"","")}function addFavoriteUserStories(b,c){c.length>0?addItem("/activity/stories/","",c,"","",""):addItem("/friends/stories/","",b,"","","")}
function addFavoriteUserVotes(b,c){c.length>0?addItem("/activity/votes/","",c,"","",""):addItem("/friends/votes/","",b,"","","")}function addFavoriteTagStories(b,c){c.length>0?addItem("/news/","","","",c,""):addItem("/favorites/","",b,"","","")}function addFavoriteTagBuckets(b,c){c.length>0?addItem("/buckets/","","","",c,""):addItem("/favorites/buckets/","",b,"","","")}function addFavoriteTagLatest(b,c){c.length>0?addItem("/new/","","","",c,""):addItem("/favorites/new/","",b,"","","")}
function addFavoriteTagFeed(b,c){c.length>0?addItem("/blog_posts/","","","",c,""):addItem("/favorites/blog_posts/","",b,"","","")}
function setMaxItems(b,c){if(YAHOO.ballhype.uli){var d={success:function(e){var f=document.getElementById("licontent."+e.argument[0]);f.innerHTML=e.responseText;f=document.getElementById("max."+e.argument[0]);f.innerHTML=getMaxLinkContent(e.argument[0],e.argument[1])},failure:function(e){},argument:[b,c]};b=YAHOO.util.Connect.asyncRequest("GET","/component."+b+"/set_max_items/?max_items="+c,d,null)}else showLoginOverlay(b,"max.","customizing your dashboard")}
function addScoreboard(b,c){var d="/scoreboard/",e=b,f="";if(e==="myteams"){d="/myteams/scoreboard/";e=""}else if(c<-1){e="";f=b}addItem(d,e,"","","",f)}function addLeagueLocationItem(b,c,d){d<0?addItem(b,"","","","",c):addItem(b,c,"","","","")}function unhighlight(){var b=document.getElementById("south");b=new YAHOO.util.ColorAnim(b,{color:{from:"#fff",to:"#F90"},backgroundColor:{from:"#F90",to:"#fff"}},1.5);b.animate()}
function removeComponent(b,c){if(confirm("Are you sure you would like to remove this component?")){c=document.getElementById("li."+b);if(YAHOO.ballhype.uli){c={success:function(d){hideComponent(d.argument[0])},failure:function(d){},argument:[c]};b=YAHOO.util.Connect.asyncRequest("GET","/component."+b+"/delete/",c,null)}else hideComponent(c)}}function removeElement(){var b=this.getEl();b.parentNode.removeChild(b);checkBoundaryHeight()}
function hideComponent(b){b=new YAHOO.util.Anim(b,{opacity:{to:0},height:{to:0}},1,YAHOO.util.Easing.easeOut);b.onComplete.subscribe(removeElement);b.animate()}
function setupButtonGroup(){function b(d){var e;if(d.newValue.get("id")==="wideleft"){d=new YAHOO.util.Anim("col.0",{width:{to:585}},0.8,YAHOO.util.Easing.backOut);e=new YAHOO.util.Anim("col.1",{width:{to:350}},0.8,YAHOO.util.Easing.backOut);d.animate();e.animate();document.getElementById("col.0").className="customColumnWide";document.getElementById("col.1").className="customColumnNarrow";d=0}else if(d.newValue.get("id")==="balanced"){d=new YAHOO.util.Anim("col.0",{width:{to:467}},0.8,YAHOO.util.Easing.backOut);
e=new YAHOO.util.Anim("col.1",{width:{to:467}},0.8,YAHOO.util.Easing.backOut);d.animate();e.animate();document.getElementById("col.0").className="customColumnBalanced";document.getElementById("col.1").className="customColumnBalanced";d=1}else{d=new YAHOO.util.Anim("col.0",{width:{to:350}},0.8,YAHOO.util.Easing.backOut);e=new YAHOO.util.Anim("col.1",{width:{to:585}},0.8,YAHOO.util.Easing.backOut);d.animate();e.animate();document.getElementById("col.1").className="customColumnWide";document.getElementById("col.0").className=
"customColumnNarrow";d=2}YAHOO.ballhype.uli&&YAHOO.util.Connect.asyncRequest("GET","/custom/update/?layout="+d,null,null)}var c=new YAHOO.widget.ButtonGroup("layoutbuttons");c.addListener("checkedButtonChange",b)}YAHOO.util.Event.onDOMReady(setupButtonGroup);
