﻿// Create expanding titles for Legends with className 'EditorPartTitle'
  function CreateExpandingTitles() {
    var elements = document.getElementsByTagName("LEGEND");
    var first;
    first = 0;
    for (i=0; i<elements.length; i++) {
      if (elements[i].className && elements[i].className == "EditorPartTitle")
        elements[i].onclick = new Function("toggle(this);");
        elements[i].style.backgroundImage = "url(images/plus.gif)";
        if ( first <= 0 ) {
            toggle(elements[i]);
            first = first + 1;
        }
      }      
  }

  // Call function CreateExpandingTitles on window onload
  if (window.addEventListener) {
    window.addEventListener('load', CreateExpandingTitles, false);
  }
  else if (window.attachEvent) {
    window.attachEvent('onload', CreateExpandingTitles);
  }  

  function toggle(titleElement) {
    // Find nextSibling's firstChild (i.e. DIV with class 'EditorPartStyleHidden')
    // For IE this is nextSibling.childNodes[0], but due to an error in current
    // version of FireFox (1.0.4) this is nextSibling.childNodes[1]
    var firstChild = (titleElement.nextSibling.childNodes[0].id)
      ? titleElement.nextSibling.childNodes[0] 
      : titleElement.nextSibling.childNodes[1];

    // Toggle image and show/hide EditorPart display 
    if (firstChild.style.display == "block" ) {
      firstChild.style.display = "none";
      titleElement.style.backgroundImage = "url(images/plus.gif)";
    } else {
      firstChild.style.display = "block";
      titleElement.style.backgroundImage = "url(images/minus.gif)";
    }
  }

function getObject(name) {
	var object;	
	if ( document.getElementById ) {
		object = document.getElementById(name);
	}
	else if ( document.all ) {
		object = document.all[name];
	}
	else if ( document.layers ) {
		object = document.layers[name];
	}
	return object;
}	