function getIndex(el) 
{    
  ind = null;
  for (i=0; i<document.layers.length; i++) 
  {
    whichEl = document.layers[i];
    if (whichEl.id == el) 
    {
      ind = i;
      break;
    }
  }    
  return ind;
}


function setNSImages(images)
{
  if(null==images)
  {
    return;
  }
  
  for(var i=0; i<images.length; i++)
  { 
    images[i].src="wfd.gif";
  }
}


function addNSStyle()
{
  if(!(document.layers==null))
  {
    document.write('<STYLE TYPE="text/css">.WFPARENT {position:absolute;} .WFCHILD {position:absolute;} .WFNSHIDE {display:none;}</STYLE>');
  }
}


function initNS()
{
  if (!(document.layers==null)) 
  {
    arrange(document, 0);
    for(var i=0; i<document.layers.length; i++)
    { 
      setNSImages(document.layers[i].document.images);
      tmpStr = document.layers[i].id
      
      // Check if this is a parent element
      //alert(tmpStr.substring(tmpStr.length-6));
      if((tmpStr.length>6) && (tmpStr.substring(tmpStr.length-6)=='Parent'))
      {
        //alert(tmpStr.length + ':' + i + ',' + tmpStr);
        expandStr = tmpStr.substring(0, tmpStr.length-6);
        setExpand(expandStr, false);
      }
    }
  }
}


function arrange(inDoc, inY) 
{
  if(inDoc.layers.length==0)
  {
    return;
  }
  nextY = inY + inDoc.layers[0].pageY + inDoc.layers[0].document.height;
  for (i=1; i<inDoc.layers.length; i++) 
  {
    whichEl = inDoc.layers[i];        
    
    if (whichEl.visibility != "hide") 
    {
      whichEl.pageY = nextY;            
      nextY += whichEl.document.height;
    }
  }
//  alert('End arrange');
  return nextY;
}

	function topClikker(a,b) 
	{
		event.cancelBubble = true;
		if( a == null || b == null ) return;
		
    var elA = document.all.item(a);
    var elB = document.all.item(b);
    
		
		if (elA.style.display =='') 
		{
			elA.style.display = 'none';
			elB.src='wfu.gif';		
		}
		else
		{
 			elA.style.display='';
			elB.src='wfd.gif';		
		}
	}
function resizeNS()
{
  if(!(document.layers==null))
  {
    document.location=document.location;
  }
}

function setExpand(el, inVal)
{
  if(el=='el0')
  {
    return;
  }
  
  if((document.layers==null)) return;
  
    whichEl = eval("document." + el + "Child");
    var picName = 'WFTOCSEC' + el.substring(2) + '_PIC';
    whichIm = eval("document." + el + "Parent.document.images['" + picName + "']");
    
    if(inVal)
    {
      whichEl.visibility = "show";
      whichIm.src = "wfd.gif";
    }
    else
    {
      whichEl.visibility = "hide";
      whichIm.src = "wfu.gif";    
    }
    arrange(document, 0);
}
    
function expandIt(el, cl1, cl2) 
{
  
  if(!(document.layers==null))
  {
    whichEl = eval("document." + el + "Child");
//    alert(el);
    var picName = 'WFTOCSEC' + el.substring(2) + '_PIC';
    //alert(el + ',' +picName);
    whichIm = eval("document." + el + "Parent.document.images['" + picName + "']");
    if (whichEl.visibility == "hide") 
    {
      whichEl.visibility = "show";
      whichIm.src = "wfd.gif";
    }
    else
    {
      whichEl.visibility = "hide";
      whichIm.src = "wfu.gif";    
    }
    arrange(document, 0);
  }
  else
  {
    topClikker(cl1, cl2);
  }
  
}

