////////////////////////////////////////////////////////////////////////
// This script and menu system is copyrighted by Aaron Vance in 2004. //
// Do not remove this warning and attribution.                        //
// For more information email jsm at aaronvance dot com.              //
//                                                                    //
// This open/close drop-down menu works by dynamically increasing the //
// vertical size of a spacer image between each main menu item; as    //
// the main items below the nav that is moused-over drop, the         //
// clipping of the layer with the sub-nav items is decreased so that  //
// the sub-nav items show at the same rate that the space increases.  //
//                                                                    //
// In order to allow menu items to completely open or close before    //
// another item begins opening, I've put a layer over the menus while //
// they open/close; the layer has a spacer image and I've turned off  //
// the IE 6 image toolbar for the page.                               //
////////////////////////////////////////////////////////////////////////

var i = 0;                                                      // reset counter
var addFactor = 5;                                              // increase image size by this factor
var loops = 25;                                                 // define loops and set to 25
var loopTime = 20;                                              // delay between loops is .02 seconds
var loopTime2 = loopTime - (loopTime * .25);                    // delay between loops for contracting menus

function show(ln)
{ 
  showme('blocknav');                                           // displays layer that temporarily prevents mouseovers
  var testheight = document.images['opensettle1'].height + document.images['opentech1'].height + document.images['openins1'].height + document.images['openmarket1'].height + document.images['opencomp1'].height + document.images['openinvest1'].height  
  if(i==0 && testheight==6)                                     // if all six images spacing images are at default (1)
  {
  if (ln=='opensettle') { loops = 28; }                         // set the height each nav will open to
  if (ln=='opentech') { loops = 35; }
  if (ln=='openins') { loops = 13; }
  if (ln=='openmarket') { loops = 17; }
  if (ln=='opencomp') { loops = 17; }
  if (ln=='openinvest') { loops = 36; }
  var imagename = ln.substr(4,ln.length - 4);                   // get name of sub-nav image for downarrow
  document[imagename].src='/images/sn' + imagename + '_on.gif'; // display over state of nav image
  setTimeout("shows('"+ln+"')",200);                            // pause two tenths
  }
  else
  {
  hideme('blocknav');                                           // removes screen layer as expand routine aborts 
  }
}

function shows(lname)
{ 
    if (document.all)
    { document.all[lname].style.visibility = 'visible'; }
    else if (document.getElementById(lname))
    { document.getElementById(lname).style.visibility = 'visible'; }
    else if (document.layers)
    { document.layers[lname].visibility = 'show'; }
    expandMe(lname);                                           // move to the third function in expand chain
}

function expandMe(lname)
{ 
  if (lname) { lname1 = lname; lname2 = lname; }
  if (document.images[lname1 + '1'].height < addFactor*loops + 1)
  { document.images[lname1 + '1'].height += addFactor; }
  else if (document.images[lname1 + '1'].height < addFactor*loops + 2)
  { document.images[lname1 + '1'].height += addFactor; }

  if (document.all)
  { document.all(lname1).style.clip = "rect(auto auto " + document.images[lname1 + '1'].height + "px auto)"; }
  else if (document.getElementById)
  { document.getElementById(lname1).style.clip = "rect(auto auto " + document.images[lname1 + '1'].height + "px auto)"; }
  else if (document.layers)
  { document.layers[lname1].clip.bottom = document.images[lname1 + '1'].height;  }

  if (i < loops)
  {
  i=i+1;
  setTimeout('expandMe()',loopTime);
  }
  else
  { 
  hideme('blocknav');
  }
}

function hide(lname1)
{
  var con1 = 0;                                                // use to check if the sub-menu is actually open
  if (document.layers)
  {
  if (document.layers[lname1].visibility == 'show')
  { var con1 = 1; }
  }
  else if (document.getElementById(lname1))
  {
  if (document.getElementById(lname1).style.visibility == 'visible')
  { var con1 = 1; }
  }
  else if (document.all)
  {
  if (document.all[lname1].visibility == 'visible')
  { var con1 = 1; }
  }
  if (con1==1 && i==loops)
  {
  i=0; hide1(lname1);                                          // continue to next step
  }
}

 function hide1(lname1)
 {
  showme('blocknav');
  document.images[lname1 + '1'].height -= addFactor;

  if (document.all)
  { document.all(lname1).style.clip = "rect(auto auto " + document.images[lname1 + '1'].height + "px auto)"; }
  else if (document.getElementById)
  { document.getElementById(lname1).style.clip = "rect(auto auto " + document.images[lname1 + '1'].height + "px auto)"; }
  else if (document.layers)
  { document.layers[lname1].clip.bottom = document.images[lname1 + '1'].height;  }

  if (i < loops - 1) 
  {
    i=i+1;
    setTimeout('hide1(lname1)',loopTime2);
  }
  else if (i < loops)
  {
    i=i+1;
    setTimeout('hide1(lname1)',loopTime2);
  }
  else
  {
    if (document.layers)
    {
    if (document.layers[lname1].visibility == 'show')
    {document.layers[lname1].visibility = 'hide';}
    }
    else if (document.getElementById(lname1))
    {
    if (document.getElementById(lname1).style.visibility == 'visible')
    { document.getElementById(lname1).style.visibility = 'hidden';}
    }
    else if (document.all)
    {
    if (document.all[lname1].visibility == 'visible')
    { document.all[lname1].visibility = 'hidden'; }
    }

    var imagename = lname1.substr(4,lname1.length - 4);
    document.images[lname1 + '1'].height = 1;
    document[imagename].src='/images/sn' + imagename + '.gif';
    i=0; hideme('blocknav');
  }
}

//window.onerror=myErrorHandler                                  // if there's an error, refresh the page

function myErrorHandler()
{
location.href=location.href;
return true;
}

function removeThanks()
{
setTimeout('removeThanks2()',15000);
}

function removeThanks2()
{
hideme('success');
}

function hidehead()
{
hide('opensettle');
hide('opentech');
hide('openins');
hide('openmarket');
hide('opencomp');
hide('openinvest');
}

function hidecopy()
{
hideme('defaultl');
hideme('dsettle1');
hideme('dsettle2');
hideme('dsettle3');
hideme('dsettle4');
hideme('dsettle5');
hideme('dsettle6');
hideme('dsettle7');
hideme('dsettle8');
hideme('dtech1');
hideme('dtech2');
hideme('dtech3');
hideme('dtech4');
hideme('dtech5');
hideme('dtech6');
hideme('dtech7');
hideme('dtech8');
hideme('dtech9');
hideme('dtech10');
hideme('dins1');
hideme('dins2');
hideme('dins3');
hideme('dins4');
hideme('dmarket1');
hideme('dmarket2');
hideme('dmarket3');
hideme('dmarket4');
hideme('dmarket5');
hideme('dcomp1');
hideme('dcomp2');
hideme('dcomp3');
hideme('dcomp4');
hideme('dcomp5');
hideme('dinvest2');
hideme('dinvest3');
hideme('dinvest4');
hideme('dinvest6');
hideme('dinvest7');
hideme('dinvest8');
hideme('dinvest9');
hideme('dinvest10');
}
