var minus;
var minuspath = "img/minus.png";
var plus;
var pluspath = "img/plus.gif";

var current;

function expandme( i, element_to_show )
{
   if ( document.getElementById && document.createTextNode )
   {
      var node = document.getElementById( "expand" + i );
      
      node = node.getElementsByTagName( element_to_show ).item(0);
      //alert( element_to_show  );
      
   
      /* list = document.getElementById( "list" ); */
/*       header = list.getElementsByTagName("li").item(idx); */
/*       link = header.getElementsByTagName("a").item(0).firstChild; */
/*       node = list.getElementsByTagName("div").item(idx);   */

      //alert(link.text);
      
      isshowing = ( node.style.display == "" ) ? "none" : node.style.display;
     
      
      if ( isshowing == "block" )
      {
         node.style.display = "none";
         //node.style.backgroundColor = null;
         //link.nodeValue = link.nodeValue.replace("--", "+");
      }
      else
      {
         node.style.display = "block";
         //node.style.backgroundColor = "#e0e0e0";
         //link.nodeValue = link.nodeValue.replace("+", "--");
      }
      
      changePlusMinus( i );
   }
}

function expandNode( node, i )
{
      isshowing = ( node.style.display == "" ) ? "none" : node.style.display;
      
      if ( isshowing == "block" )
      {
         node.style.display = "none";
      }
      else
      {
         node.style.display = "block";
      }
      
      changePlusMinus( i );
}


function changePlusMinus( i )
{
   if ( document.getElementById )
   {
       theImg = document.getElementById( "pm_" + i );
       
       theSrc = theImg.getAttribute("src");
       
       if ( theSrc == pluspath )
          theImg.setAttribute( "src", minuspath );
       else
          theImg.setAttribute( "src", pluspath );
   } 
}


function init()
{
   minus = new Image();
   minus.src = minuspath;
   
   plus = new Image();
   plus.src = pluspath;
   
   
   
   if ( document.getElementById )
   {
      // first, hide the adv options
      advopt = document.getElementById('advoptions');
      
      if ( advopt ) 
         advopt.style.display = "none";
      
      // next, expand or hide the various secondary distance boxes
      nr_lines = document.forms[0].elements["form_nr_lines"].value;
      
      if ( document.getElementById && document.getElementsByTagName )
      {
         for ( i = 1; i <= nr_lines; i++ )
         {      
         
            var dist_node = document.getElementById('distance2_' + i);
            
            if ( dist_node.value != '' )
            {
               var node = document.getElementById( "expand" + i );
               node = node.getElementsByTagName( 'div' ).item(0);
               expandNode( node, i );
            }
         }
      }
  }
}

window.onload = function()
{
  init();
}
