// -----------------------------------------------------------------------------
// -
// -----------------------------------------------------------------------------
      
Event.observe(window, 'load', function() { ol(); });

// -----------------------------------------------------------------------------
// -
// -----------------------------------------------------------------------------

function leapTo (link)
  {
  var new_url=link;
  
  if(recType == "DMV")
    {
    new_url = startURL + "/dmv2.html#" + link;
    }
  else if (recType == "Military")
    {
    new_url = startURL + "/military2.html";
    }
  else
    {
    new_url = startURL + "/" + link + "/" + recType + ".html";
    }
  window.location = "bg_search.php?include=" + new_url;
  }

// -----------------------------------------------------------------------------
// -
// -----------------------------------------------------------------------------

function recTypeSelect (rec)
  {
  recType = rec;
  }

// -----------------------------------------------------------------------------
// -
// ----------------------------------------------------------------------------- 

function showMenu()
  {
  var url   = document.location.href;
  var match = url.match(/([A-Za-z]*)_\w*.php/);
  var page  = match ? match[1] : "";  
  var index = ( url.lastIndexOf("/") == url.length-1 ) ? 0 : -1;
  
  switch( page )
    {
    case 'people':       index = 0; break;
    case 'address':      index = 1; break;
    case 'bus':          index = 2; break;
    case 'criminal':     index = 3; break;
    case 'sp':           index = 4; break;
    case 'ssn':          index = 4; break;
    case 'bg':           index = 5; break;
    case 'newhomebuyer': index = 6; break;
    }
  if( index != -1 )
    {
    $$('.accordion_content')[index].setStyle({ 'height' : 'auto'});
    }
  }

// -----------------------------------------------------------------------
// -
// -----------------------------------------------------------------------
      
var changeImage = function(e, state)
  {
  var imagename = e.target.src;
        
  if( (state == 'over') && imagename.match( '_out.gif' ) ) 
    {
    e.target.src = imagename.replace('_out.gif', '_over.gif');  
    }
  else if( (state == 'out') && imagename.match( '_over.gif' ) )
    {
    e.target.src = imagename.replace('_over.gif', '_out.gif');      
    } 
  }

// -----------------------------------------------------------------------
// -
// -----------------------------------------------------------------------
      
function ol()
  {
  $$('.accordion_toggle').each( function(el)
    {
    el.observe( 'click', function()
      {
      var content = el.next('div');
      var height = content.getHeight();
            
      $$('.accordion_content').each( function(el)
        {
        el.setStyle( {'height' : '1px'} );
        });
            
      content.setStyle( {'height' : 'auto'} );
      });
    });
 
  showMenu();
  if( $('template_form') ) { new Validation('template_form') };    
  $$('img.tab').invoke('observe', 'mouseover', function(e) { changeImage(e, 'over'); } );
  $$('img.tab').invoke('observe', 'mouseout',  function(e) { changeImage(e, 'out'); } );
  } 

