function ToggleElementClass(parentNode){
    if (parentNode){
      parentNode.className = parentNode.className == "showInfo" ? "hideInfo" : "showInfo"; 
  }
}

var SHOW = "images/showdetails.png";
var SHOW_HOVER = "images/showdetailsHOVER.png";
var HIDE = "images/hidedetails.png";
var HIDE_HOVER = "images/hidedetailsHOVER.png";

function ToggleImageSource(imageNode){
  if (imageNode){
    if (imageNode.showDetails){
    	imageNode.showDetails = false;
    	SetHoverImage( imageNode );
    }
    else {
      imageNode.showDetails = true;
    	SetHoverImage( imageNode );
    }
	  var parentNode = imageNode.parentNode;
	  if (parentNode){
	      parentNode.className = parentNode.className == "showInfo" ? "hideInfo" : "showInfo"; 
	  }
  }
}

function SetHoverImage(imageNode){
  if (imageNode){
    if (imageNode.showDetails){
      imageNode.src = SHOW_HOVER;
      imageNode.title = "Click to Show Additional Details";
    }
    else {
      imageNode.src = HIDE_HOVER;
      imageNode.title = "Click to Hide Details";
    }
  }
}

function SetDefaultImage(imageNode){
  if (imageNode){
    if (imageNode.showDetails){
      imageNode.src = SHOW;
      imageNode.title = "Click to Show Additional Details";
    }
    else {
      imageNode.src = HIDE;
      imageNode.title = "Click to Hide Details";
    }
  }

}

function InitializeDivs(){
  var infos = document.getElementsByTagName("li");
  for (i=0; i<infos.length; i++){
    var el = infos[i];
    if ( el.className == "hoverInfo" || el.className == "showInfo" ){
      el.className = "hideInfo";
      var button;
      if (true){
        button = document.createElement("img");
	      button.src = "images/showdetails.png";
	      button.alt = "Show Details";
	      button.title = "Click to Show Additional Details";
	      button.showDetails = true;
	      button.className = "infoButton";
	      button.onclick = function(){ ToggleImageSource(this); };
	      button.onmouseover = function(){ SetHoverImage( this ); };
	      button.onmouseout = function(){ SetDefaultImage( this ); };
	      el.insertBefore(button, el.firstChild);
      }
    }
  }
}