window.onload = hideblurbs;

function hideblurbs(){
	if (document.getElementById("candidates")){// if 'candidates' list exists
		var candidateList = document.getElementById("candidates");// grab 'candidates'
		var candidates = candidateList.getElementsByTagName("li");// grab all 'li's in 'candidates'
		for (i=0;i<candidates.length;i++){
			var candidate = candidates[i];
			// test to make sure 'li' is immediate child of 'candidates'
			if (candidate.parentNode.getAttribute("id") == "candidates"){
				// hide blurb
				var blurb = candidate.getElementsByTagName("div")[0];
				blurb.style.display = "none";
				// create link to show blurb
				var showLink = document.createElement("p");
				var showAnchor = document.createElement("a");
				showLink.appendChild(showAnchor);
				showAnchor.appendChild(document.createTextNode("show statement"));
				showAnchor.setAttribute("href","#");
				showAnchor.setAttribute("class","showlink");
				showAnchor.onclick = function(){
					if (blurb.style.display != "none"){
						showLink = this.parentNode;
						candidate = showLink.parentNode;
						blurb = candidate.getElementsByTagName("div")[0];
						blurb.style.display = "none";
						this.firstChild.nodeValue = "show statement";// change link text
						return false;
					}
					else{
						showLink = this.parentNode;
						candidate = showLink.parentNode;
						blurb = candidate.getElementsByTagName("div")[0];
						blurb.style.display = "block";
						this.firstChild.nodeValue = "hide statement";// change link text
						return false;
					}
				}
				candidate.insertBefore(showLink,blurb);
			}
		}
	}
}

/*function externalLink(url){
	extWin = window.open(''+url+'', 'extWin', 'width=650,height=500,resizable=yes,toolbar=no,scrollbars=yes,left=0,top=0')
	extWin.focus()
}*/
