/*
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=500,width=500,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
*/

window.onload = function() {
  initPopups();
  var featureBoxContainer = document.getElementById('showHide');
  if (featureBoxContainer) {
    initFeatureBoxes();
  }
}

function initFeatureBoxes() {
  featureLinks = document.getElementsByClassName('showHideLeft')[0].getElementsByTagName('a');
  for (var i = 0; i < featureLinks.length; i++) {
    featureLinks[i].relatedBoxId = 'ssafb' + (i+1);
    featureLinks[i].onclick = showFeatureBox;
  }
}

function showFeatureBox() {
  var box_id = this.relatedBoxId;
  visibleBoxes = document.getElementsByClassName('showHideRight')[0].getElementsByTagName('div');
  for (var i = 0; i < visibleBoxes.length; i++) {
    visibleBoxes[i].style.display = 'none';
  }
  new Effect.Appear(box_id, { duration: 1.0 });
  return false;
}

function initPopups() {
	// check to see that the browser supports the getElementsByTagName method
	// if not, exit the loop
	if (!document.getElementsByTagName) {
		return false;
	}
	// create an array of objects of each link in the document
	var popuplinks = document.getElementsByTagName("a");
	// loop through each of these links (anchor tags)
	for (var i=0; i < popuplinks.length; i++) {
	  var parts = popuplinks[i].className.split(" ");
		if (parts[0] == "js_popup") {
			// add an onclick event on the fly to pass the href attribute
			// of the link to our second function, openPopUp
			if (parts.length == 1) {
			  popuplinks[i].popupHeight = 500;
		  }
			else {
			  popuplinks[i].popupHeight = parts[1];
			}
			popuplinks[i].onclick = function() {
			openPopUp  (
				this.getAttribute("href"),
				this.popupHeight
				);
			return false;
			}
		}
	}
}

function openPopUp(linkURL,height) {
window.open(linkURL,'popup','width=500,height='+height+',scrollbars=yes');
}