function addTestiListeners() {
  // Get the third column's divs.
  var tds = document.getElementById('corpus').getElementsByTagName("div");
  // Run through the divs
  for (e = 0; e < tds.length; e++) {
	// Find the testimonial cases.
	if (tds[e].className == 'testi_case') {
	  // Get the case.
	  var d = tds[e];
	  if (window.addEventListener) {
		// When you mouse over it, the text color becomes the background color.
		d.addEventListener('mouseover', colorToBack, false);
		// When you mouse off of it, the background color becomes the text color.
		d.addEventListener('mouseout', backToColor, false);
		// When you click it, the banner image changes.
		if (document.getElementById('testis-preload')) {d.addEventListener('click', bgbecomes, false);}
	  }
	  else {
		d.setAttribute('onmouseover', 'iesuckscolorToBack(this)');
		d.setAttribute('onmouseout', 'iesucksbackToColor(this)');
		if (document.getElementById('testis-preload')) {d.setAttribute('onclick', 'iesucksbgbecomes(this)');}
	  }
	}
  }
}
if (window.addEventListener) {window.addEventListener('load', addTestiListeners, false);}
else { if (!((BrowserDetect.browser == 'Explorer') && (parseInt(BrowserDetect.version) == 6))) {addTestiListeners();} }


function colorToBack() {
  this.style.backgroundColor = document.getElementById(this.getAttribute('banner') + '_testibar').style.backgroundColor;
}
function iesuckscolorToBack(obj) {
  obj.style.backgroundColor = document.getElementById(obj.getAttribute('banner') + '_testibar').style.backgroundColor;
}
function backToColor() {
  this.style.backgroundColor = '';
}
function iesucksbackToColor(obj) {
  obj.style.backgroundColor = '';
}

function bgbecomes() {
  // Remove the previous banner if it exists.
  if (document.getElementById('testitxt_' + document.getElementById('currtesti').value + '_copy')) {
	document.getElementById('banner_space').removeChild(document.getElementById('testitxt_' + document.getElementById('currtesti').value + '_copy'));
  }
  // Switch the background image.
  document.getElementById('banner_space').style.backgroundImage = "url(/images/testimonials/testi-" + this.getAttribute('banner') + ".jpg)";
  // Duplicate the testimonial div.
  var nd = document.getElementById('testitxt_' + this.getAttribute('banner')).cloneNode(true);
  // Rename it.
  nd.id = nd.id + '_copy';
  // Stick it in the banner element.
  document.getElementById('banner_space').appendChild(nd);
  // And make it appear.
  nd.style.display = 'block';
  // And set the testimonial hidden value.
  document.getElementById('currtesti').value = this.getAttribute('banner');
  // And set the hash value.
  window.location.hash = '#' + this.getAttribute('banner');
}
function iesucksbgbecomes(obj) {
  // Remove the previous banner if it exists.
  if (document.getElementById('testitxt_' + document.getElementById('currtesti').value + '_copy')) {
	document.getElementById('banner_space').removeChild(document.getElementById('testitxt_' + document.getElementById('currtesti').value + '_copy'));
  }
  // Switch the background image.
  document.getElementById('banner_space').style.backgroundImage = "url(/images/testimonials/testi-" + obj.getAttribute('banner') + ".jpg)";
  // Duplicate the testimonial div.
  var nd = document.getElementById('testitxt_' + obj.getAttribute('banner')).cloneNode(true);
  // Rename it.
  nd.id = nd.id + '_copy';
  // Stick it in the banner element.
  document.getElementById('banner_space').appendChild(nd);
  // And make it appear.
  nd.style.display = 'block';
  // And set the testimonial hidden value.
  document.getElementById('currtesti').value = obj.getAttribute('banner');
  // And set the hash value.
  window.location.hash = '#' + obj.getAttribute('banner');
}

