function toggleSwitch(a)
{
    var t = this.parentNode.parentNode.parentNode.parentNode.childNodes;
    var vis = '';

    if (this.innerHTML === 'View Response') {
      vis = 'visible';
	  this.innerHTML = 'Hide Response';
    } else if (this.innerHTML === 'Hide Response') {
      vis = 'collapse';
	  this.innerHTML = 'View Response';
    }
    for (c in t) {
      if (t[c].nodeName === 'TR' && t[c].className === 'response')
        t[c].style.visibility = vis;
    }
}

function get_responses(a)
{
  for (i in a) {
    if (a[i].className === 'responseSwitch')
      a[i].onclick = toggleSwitch;
  }
}

window.onload = function() { get_responses(document.getElementsByTagName('a')); };
