function toggleOff() {
	/*
	// close all the parent category navs
	var divsTcClose = document.getElementsByTagName('DIV');
	if (divsTcClose != null) {
		for (var i=0; i < divsTcClose.length; i++) {
			if (divsTcClose[i].className == "polls-nav") {
				divsTcClose[i].className = "polls-nav-closed";
			}
		}
	}
	*/
	
	// remove all the red
	var lisToBlack = document.getElementsByTagName('LI');
	if (lisToBlack != null) {
		for (var i=0; i < lisToBlack.length; i++) {
			if (lisToBlack[i].className == "selected") {
				lisToBlack[i].className = "unselected";
			}
		}
	}

	/*
	// make all the carrat arrows right
	var carratsToRight = document.getElementsByName('pCatCarrat');
	if (carratsToRight != null) {
		for (var i=0; i < carratsToRight.length; i++) {
			carratsToRight[i].src = "http://assets.espn.go.com/i/sportsnation/poll/index/carrat_right.gif";
		}
	}
	*/

	// set the src of the twin iframe
	var iframeElemTwin = document.getElementById('twinFrame');
	iframeElemTwin.src = '/sportsnation/poll/format/twin?pCat=null&sCat=null';
	
}

function toggleNavRed() {
	document.getElementById('featured2').className = "selected";
}

function toggleNav(pCat,sCat) {
	// turn stuff off
	toggleOff();

	/*
	// open the selected parent category nav
	document.getElementById('pCatDiv'+pCat).className = "polls-nav";
	*/

	// set the selected item to be red
	if (sCat != null) {
		document.getElementById('sCatLi'+sCat).className = "selected";
	}

	/*
	// change the carret graphic
	document.getElementById('pCatCarrat'+pCat).src = "http://assets.espn.go.com/i/sportsnation/poll/index/carrat_down.gif";
	*/

	// set the src of the center iframe
	var iframeElem = document.getElementById('centerFrame');
	iframeElem.src = '/sportsnation/poll/format/otherPolls?pCat='+pCat+'&sCat='+sCat;
	
	// set the src of the twin iframe
	var iframeElemTwin = document.getElementById('twinFrame');
	iframeElemTwin.src = '/sportsnation/poll/format/twin?pCat='+pCat+'&sCat='+sCat;
	
}

var cookies = document.cookie.split("; ");
function getCookie(name) {
	for (var i=0; i < cookies.length; i++) {
	  cookie = cookies[i].split("=");
	  if (cookie[0] == name)
		return cookie[1];
	  }
	  return null;
}

function getPollHasVoted(poll) {
	var hasVoted = false;
	var voted = "voted=0";
	var pollBit = poll % 256 % 64 % 4;
	bitArray = new Array();
	bitArray[0] = 8;
	bitArray[1] = 1;
	bitArray[2] = 2;
	bitArray[3] = 4;
	var cookieId = (poll - (poll % 256)) / 256;
	var CookieIdasString = new String(cookieId);
	var cookieName = "POLL" + CookieIdasString;
	pollCookie = getCookie(cookieName)
	if (pollCookie != null) {
		cookiePosition = pollCookie.length - Math.ceil((poll % 256 )/ 4);
		cookieValue = pollCookie.substring(cookiePosition, cookiePosition + 1);
		cookieAsHex = "0x" + cookieValue.toString(1);
		if ((bitArray[pollBit] & cookieAsHex) == bitArray[pollBit]) {
			var hasVoted = true;
		}
		if (hasVoted) {
			voted = "voted=1";
		}
		return voted;
	}
}