/* copyright Robert E Walker 2009 */

function initPopups ()
{
 /* find all elements with class containing "popup" and hide them */
 var elements;
 var element;
 var index = 0;
//  alert ('initPopups');
 /* currently not working, unable to get anchor object only href */
 //alert(document.getElementById('btn_close_wendy_yarn'));
}// function initPopups


function openPopup (which)
{
 var popup = document.getElementById(which);
 popup.style.display = 'block';
}// function openPopup

function closePopup (which)
{
 var popup = document.getElementById(which);
 popup.style.display = 'none';
}// function closePopup

function getClassedNodes (element, needle, exact)
{
 var collectedElements = new Array();
 var tempElements;
 var index = 0;
 try
 {
  if (!element) {throw 'No element';}
  if (!needle) {throw 'No class name was specified in needle';}
  if (element.childNodes)
  {
   /* look for child nodes with matching class */
   for (index; index < element.childNodes.length; index++)
   {
    tempElements = getClassedNodes(element.childNodes[index], needle, exact);
  	if (tempElements.length > 0)
  	{
  	 collectedElements[collectedElements.length] = tempElements;
  	}// if (tempElement)
   }// for
  }// if (element.childNodes)
  /* check if this element has matching class */
  if (element.className)
  {
   if (exact)
   {
    if (element.className == needle) 
    {
     collectedElements.push(element);
    }
   }
   else
   {
    if (element.className.indexOf(needle) > -1) 
    {
     collectedElements[collectedElements.length] = element;
    }
   }// if (exact)
  }// if (element.className)
 return collectedElements;
 }
 catch (error)
 {
  alert ('getClassedNodes: Unable to get classed nodes - ' + error + '.');
  return false;
 }
}// getClassedNodes