/**
 * @author Peter Hoose (C) 2007
 */

function buildEvents() {
  if (!document.getElementById("secondaryColumn")) return true;
  var secCol = document.getElementById("secondaryColumn");

  var moreLinks = secCol.getElementsByTagName("a");
  for (var i=0; i < moreLinks.length; i++) {
  	
  	if (moreLinks[i].getAttribute("title") == "moreLink")
	
  	moreLinks[i].onclick = function() {
	  return toggleDes(this.id);
	}
  }
}

function toggleDes(id) {	
  if (!document.getElementById(id + "Full")) return true;  
  var fullDes = document.getElementById(id + "Full");
  var shortDes = document.getElementById(id + "Short");
  if (fullDes.style.display == "none" || !fullDes.style.display) {
  	      	
	// Here we loop through all the paragraphs in the
	// Secondary Column, any time we find a "shortDes"
	// we display it, any time we find a "fullDes" we
	// hide it. This way only one news article or quote
	// is open at once to avoid the content spilling out
	// of the container.
	
  	var secCol = document.getElementById("secondaryColumn");
    var paras  = secCol.getElementsByTagName("p");
	for (var i = 0; i< paras.length; i ++) {
		
	  if (paras[i].getAttribute("title") == "fullDes") {
	    paras[i].style.display = "none"; 		
	  }
	  else if (paras[i].getAttribute("title") == "shortDes") {
	    paras[i].style.display = "block";	
	  }
	}
  	shortDes.style.display = "none";
	fullDes.style.display = "block";
  }
  else {
  	fullDes.style.display = "none";
	shortDes.style.display = "block";
  }
  return false;
}

window.addEvent('domready', function(){      
  buildEvents();
});     