if(d.getElementById("sectionCat")) { switchStoryDisplay(d.getElementById("sectionCat")); }

/* NB: section Cat switcher */
function switchStoryDisplay(nObj){
	if(1>nObj.getElementsByTagName("DIV").length || d.getElementById("switchStory")) { return; }
	var linkObj,x;
	var swObj = d.createElement("div");
	swObj.id = "switchStory";

	var btnTxt = ["Headlines","Top Story + Headlines","Summaries"];
	var btnTitle = ["View just the headlines","View the top story with a summary, the others with headlines","View summaries for all stories"];
	var btnClass = ["headline","top","summary"];
	for(x=0;btnTxt.length>x;x++){
		btnObj = d.createElement("span");
		btnObj.appendChild(d.createTextNode(btnTxt[x]));
		btnObj.title  = btnTitle[x];
		if(btnClass[x]!="") { btnObj.className = btnClass[x]; }
		addEvent(btnObj,"click",function(){doCatSwitch(this);});
		addEvent(btnObj,"mouseover",likeLinkOver);
		addEvent(btnObj,"mouseout",likeLinkOut);
		swObj.appendChild(btnObj);
	}
	nObj.insertBefore(swObj,nObj.firstChild);
	
	var catCookie = getCatCookie();
	if(!catCookie || catCookie=="") { 
		nObj.className = "headline"; 
		doCatSwitch(swObj.getElementsByTagName("SPAN")[1])
	} else {
		nObj.className = catCookie;
		doCatSwitch(getElementsByClassName(swObj, "SPAN", catCookie)[0])
	}
	
	function doCatSwitch(nObj){
		parObj = nObj.parentNode.parentNode;
		spanObjs = parObj.getElementsByTagName("SPAN");
		parObj.className = (nObj.className!="") ? nObj.className : ""; 
		setCatCookie(parObj.className);
		var menuObj = d.getElementById("switchStory");
	}
	
	function getCatCookie(){
		var hubClass = getHub();
		if(hubClass){ return getCookie("TGAM-sectionCat-"+hubClass); }
	}
	
	function setCatCookie(btnClass){
		var hubClass = getHub();
		if(hubClass){ setCookie("TGAM-sectionCat-"+hubClass,btnClass); }
	}
}		