// unobtrusive popups

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
} 

var popupLinkConfig = new Array;
// Delete/copy/modify the following lines to configure your popup windows.
popupLinkConfig["detail"] = new Array ( "detail", "width=600,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=yes");
popupLinkConfig["external"] = new Array ( "external", "");

/* ====================== */

function menuStatus() {
	m = $('active-menu');
	l = m.getElementsByTagName("LI");
	
	for (i=0; i < l.length; i++) {
		//alert(Element.hasClassName(l[i],'open'));
		if (Element.hasClassName(l[i],'open')) {
			alert(Element.classNames(l[i]));
			menuSwitch(l[i]);
		}
	}
}

function menuSwitch(link) {
	p = link;
	c = p.getElementsByTagName("UL");
	
	for (i=0; i < c.length; i++) {
		if(Element.hasClassName(c[i],'hide')) {
			swapClasses(c[i],'hide','show');
			swapClasses(link,'closed','open');
		} else {
			swapClasses(c[i],'show','hide');
			swapClasses(link,'open','closed');
		}
	}
}

function swapClasses(target,class1,class2) {
	Element.removeClassName(target,class1);
	Element.addClassName(target,class2);
}