// <!--

/* --------------------------------- */
/* Drop down menu builder            */
/* Created:      2000-10-21          */
/* Issued:       2001-01-11          */
/* Modified:     2001-07-14          */
/* Copyright (c) 2001-2004 by        */
/* Philip Shaw, all rights reserved. */
/* --------------------------------- */

///////////////////////////////////////
// Successfully debugged for:        //
//   Mozilla                         //
//     M15                           //
//   Netscape                        //
//     3, 4.5, 6.0                   //
//   Internet Explorer               //
//     4.0 5.0, 5.5                  //
//   Opera                           //
//     3.62, 4.0, 5.0, 5.11. 6.0     //
///////////////////////////////////////

// See also:
// visibility-HorizontalMenuWriter.js
///////////////////////////////////////

// Declare the number of menus
// N.B. Add menu IDs and adjust
// widths of divs in stylesheet
///////////////////////////////////////

// Global number for total menus:
///////////////////////////////////////
var totalmenus = 4;

// Global number for counting the tab
// sequence
///////////////////////////////////////
var tabcount = 0;

// Global string for menu output:
///////////////////////////////////////
var menutxt = '';

// Global array for menu data:
///////////////////////////////////////
var menu = new makeArray(totalmenus);

// Custom array constructor,
// indexed from 1:
///////////////////////////////////////
function makeArray(n){
  this.size = n;
  for(i=1; i<=n; i++){
    this[i] = 0;
  }
  return(this);
}

// Menu group constructor:
///////////////////////////////////////
function menuObject(n,MenuTitle,MenuURL){
  this.size =       n;
  this.MenuTitle =  MenuTitle;
  this.MenuURL =    MenuURL;
  this.Bullet =     new makeArray(n);
}

// Menu item constructor:
///////////////////////////////////////
function bulletObject(BulletTitle,BulletURL){
  this.BulletTitle =  BulletTitle;
  this.BulletURL =    BulletURL;
}

// Define menus. Add new items by
// increasing menu bullets argument
// and adding a new indexed bullet
// object to the end of the list.
//
// Menu arguments:
// 1 = No. of bullets
// 2 = Menu title
// 3 = Menu URL

// Bullet arguments:
// 1 = Bullet title
// 2 = Bullet URL
///////////////////////////////////////

// First menu
///////////////////////////////////////
menu[1] = new menuObject(6,'About BAAQMD','/');
menu[1].Bullet[1] = new bulletObject('Board&nbsp;of&nbsp;Directors','http://www.baaqmd.gov/brd/brddirectors/members.htm');
menu[1].Bullet[2] = new bulletObject('Calendar','http://www.baaqmd.gov/calendar/');
menu[1].Bullet[3] = new bulletObject('Contacts','http://www.baaqmd.gov/dst/contacts.htm');
menu[1].Bullet[4] = new bulletObject('Hours & Directions','http://www.baaqmd.gov/dst/directions/index.htm');
// menu[1].Bullet[5] = new bulletObject('Days/hours&nbsp;of&nbsp;OP','/dst/hrsop.htm');
menu[1].Bullet[5] = new bulletObject('Jurisdiction','http://www.baaqmd.gov/dst/jurisdiction.htm');
menu[1].Bullet[6] = new bulletObject('Mission&nbsp;Statement','http://www.baaqmd.gov/dst/mission_statement.htm');
// menu[1].Bullet[7] = new bulletObject('Org. Chart','/dst/orgcharts/orgchart.htm');

// Second menu
///////////////////////////////////////
menu[2] = new menuObject(5,'Business Assistance','#');
menu[2].Bullet[1] = new bulletObject('Compliance&nbsp;Assistance','http://www.baaqmd.gov/enf/compliance_assistance/index.htm');
menu[2].Bullet[2] = new bulletObject('Compliance Tips','/enf/compliance_assistance/tips/index.htm');
menu[2].Bullet[3] = new bulletObject('District Forms','http://www.baaqmd.gov/dst/forms_index.htm');
menu[2].Bullet[4] = new bulletObject('News &amp; Advisories','http://www.baaqmd.gov/dst/news_advisories.htm');
menu[2].Bullet[5] = new bulletObject('Permits','http://www.baaqmd.gov/pmt/index.htm');

// Third menu
///////////////////////////////////////
// menu[3] = new menuObject(2,'E-Mail Sign-Up','#');
// menu[3].Bullet[1] = new bulletObject('Air District','http://lb.bcentral.com/ex/manage/subscriberprefs.aspx?customerid=13430');
// menu[3].Bullet[2] = new bulletObject('Spare The Air','http://airalert.sparetheair.org/');

// Fourth menu
///////////////////////////////////////
menu[3] = new menuObject(1,'Public&nbsp;Records&nbsp;Request','http://www.baaqmd.gov/adm/public_records_request.htm');
menu[3].Bullet[1] = new bulletObject('Forms&nbsp;&amp;&nbsp;Instructions','http://www.baaqmd.gov/adm/public_records_request.htm');

// Fifth menu
///////////////////////////////////////
menu[4] = new menuObject(4,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Help','#');
menu[4].Bullet[1] = new bulletObject('Abbreviations/Acronymns','http://www.baaqmd.gov/dst/abbreviations.htm');
menu[4].Bullet[2] = new bulletObject('Glossary','http://www.baaqmd.gov/dst/glossary.htm');
menu[4].Bullet[3] = new bulletObject('Hotlines&nbsp;&amp;&nbsp;Special&nbsp;Contacts','http://www.baaqmd.gov/dst/hotlines.htm');
menu[4].Bullet[4] = new bulletObject('Links','http://www.baaqmd.gov/dst/links.htm');
// menu[4].Bullet[5] = new bulletObject('Public&nbsp;Records&nbsp;Request','/adm/public_records_request.htm');
// menu[4].Bullet[6] = new bulletObject('Schools','/help/schools.htm');
// menu[4].Bullet[7] = new bulletObject('Site&nbsp;Index','/help/siteindex.htm?Top=Y');



// Compile the static menu headings:
///////////////////////////////////////
menutxt += '<div id="LinkBar">\n';
for(i=1;i<=totalmenus;i++){
    // Increment the tabindex counter for every link
    tabcount++;
    menutxt += '\t<div id="Link' + i + '">';
    menutxt += '<a href="' + menu[i].MenuURL + '"';

    // Add an explicit tab sequence
    menutxt += ' tabindex="' + tabcount + '"';

    // Only compile the event handlers if able to handle them
    if(document.getElementById){// DOM1 compliant
      menutxt += ' onmouseover="menuOver(\'Menu' + i + '\'); return true;"';
      // To activate via tab navigation
      menutxt += ' onfocus="menuOver(\'Menu' + i + '\'); return true;"';
      menutxt += ' onmouseout="menuOut(\'Menu' + i + '\'); return true;"';
      // To de-activate when tab focus is lost
      menutxt += ' onblur="menuOut(\'Menu' + i + '\'); return true;"';

      // Increment the tabindex to allow for the bullets
      tabcount += menu[i].Bullet.size;
    }
    menutxt += '>' + menu[i].MenuTitle + '</a>';
    menutxt += '<\/div>\n';
  }
menutxt += '<\/div>\n';




/* adjust left indent of LIs in dropdown menus by -40px
for NN6 and Safari; adjustleft plugs into LI below */
var adjustleft = null;
if (document.all)
		{adjustleft = ' class="mmhide_IElistmargin"';}
else 
		{adjustleft = ' class="mmhide_NNSafarilistmargin"';}

// If DOM1 compliant, add the
// drop-down menus:
///////////////////////////////////////
if(document.getElementById){// DOM1 compliant
  // Reset the tab counter
  tabcount = 0;
  menutxt += '<div id="MenuBar">\n';
  for(i=1;i<=totalmenus;i++){
    // Increment the tab counter
    tabcount++;
    menutxt += '<div id="Menu' + i + '">';
    // Build the bullet list
    menutxt += '<ul>\n\t';
    for(j=1;j<=menu[i].size;j++){
      // Increment the tab couter
      tabcount++
      menutxt += '<li' + adjustleft + '><img src="http://www.baaqmd.gov/images/common/gold_arrow.gif" width="12" height="11" alt="" border="0" /><a href="' + menu[i].Bullet[j].BulletURL + '"';
      menutxt += ' onmouseover="stayOpen(\'Menu' + i + '\'); return true;"';
      menutxt += ' onfocus="stayOpen(\'Menu' + i + '\'); return true;"';
      menutxt += ' onmouseout="menuOut(\'Menu' + i + '\'); return true;"';
      menutxt += ' onblur="menuOut(\'Menu' + i + '\'); return true;"';
      // Add an explicit tab sequence
      menutxt += ' tabindex="' + tabcount + '"';
      menutxt += '>' + menu[i].Bullet[j].BulletTitle;
      menutxt += '<\/a><\/li>\n\t';
    }
    menutxt += '<\/ul>\n<\/div>\n';
  }
  menutxt += '<\/div>\n';
}

// Global menu element handle:
///////////////////////////////////////
var LiveMenu = null;

// Global menu timeout handle:
///////////////////////////////////////
var Timeout_ID = null;

// Opens or keeps open a given menu
// and shuts any previous menu:
///////////////////////////////////////
function menuOver(MenuID){
  // If DOM1 supported and element exists ...
  if((document.getElementById)&&(document.getElementById(MenuID)!=null)){
    // If this menu is already open ...
    if(LiveMenu==document.getElementById(MenuID)){
      // Do not close it
      clearTimeout(Timeout_ID);
    }
    // Another might still be open ...
    else{
      // If another menu is open ...
      if(LiveMenu!=null){
        // Do not wait, shut it now
        clearTimeout(Timeout_ID);
        hideNow();
      }
    }
    // This is the new 'live' menu, make it visible
    LiveMenu = document.getElementById(MenuID);
    // LiveMenu.style.visibility is
    // initially empty in IE5 until
    // it is assigned by these
    // functions, so must check that
    // it's not null before proceeding...
    if((LiveMenu.style)&&(LiveMenu.style.visibility!=null)){
      LiveMenu.style.visibility = 'visible';
    }
  }
}

// Stops menu links from opening menu
// onmouseover when shut to
// workaround mouse events which are
// not hidden by z-index in Opera 4!
///////////////////////////////////////
function stayOpen(MenuID){
  // If menuOver has not been called or the menu is hidden, do nothing
  if((LiveMenu==null)||((LiveMenu.style)&&(LiveMenu.style.visibility)&&(LiveMenu.style.visibility=='hidden')))return;
  else menuOver(MenuID);
}

// Shuts a given menu in 250
// milliseconds, unless timeout is
// cleared by menuOver()
///////////////////////////////////////
function menuOut(MenuID){
  // If DOM1 supported and a menu is open ...
  if((document.getElementById)&&(document.getElementById(MenuID)!=null)){
    // Get the current live menu
    LiveMenu = document.getElementById(MenuID);
    // Prepare to shut it in 250 milliseconds
    Timeout_ID = window.setTimeout('hideNow();',250);
  }
}

// Called by menu handlers to shut
// previous menu immediately
///////////////////////////////////////
function hideNow(){
  if((LiveMenu.style)&&(LiveMenu.style.visibility)){
    LiveMenu.style.visibility = 'hidden';
  }
}
///////////// End MenuBuilder for Top Nav//////////////////////////



/* --------------------------------- */
/* Created:  2000-11-12              */
/* Issued:   2001-01-11              */
/* Modified: 2001-07-14              */
/* Drop down menu writer             */
/* Copyright (c) 2001-2004 by        */
/* Philip Shaw, all rights reserved. */
/* --------------------------------- */

///////////////////////////////////////
// Successfully debugged for:        //
//   Mozilla                         //
//     M15                           //
//   Netscape                        //
//     3, 4.5, 6.0                   //
//   Internet Explorer               //
//     4.0 5.0, 5.5                  //
//   Opera                           //
//     3.62, 4.0, 5.0, 5.11, 6.0     //
///////////////////////////////////////

// See also:
// visibility-HorizontalMenuBuilder.js
///////////////////////////////////////

// If menutxt is defined and not
// empty, write it to the document
///////////////////////////////////////
if((menutxt)&&(menutxt!='')){
  document.write(menutxt);
}
///////////// End MenuWriter for Top Nav//////////////////////////

















// |||||||||||||||||||| L E F T  N A V  |||||||||||||||||||||||||||||||||||||||||||||||
// 
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 06/02/03 ---------------------------------------------------------

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Node Functions

if(!window.Node){
	var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}
function checkNode(node, filter){
	return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}
function getChildren(node, filter){
	var result = new Array();
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		if(checkNode(children[i], filter)) result[result.length] = children[i];
	}
	return result;
}
function getChildrenByElement(node){
	return getChildren(node, "ELEMENT_NODE");
}
function getFirstChild(node, filter){
	var child;
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		child = children[i];
		if(checkNode(child, filter)) return child;
	}
	return null;
}
function getFirstChildByText(node){
	return getFirstChild(node, "TEXT_NODE");
}
function getNextSibling(node, filter){
	for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
		if(checkNode(sibling, filter)) return sibling;
	}
	return null;
}
function getNextSiblingByElement(node){
	return getNextSibling(node, "ELEMENT_NODE");
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Menu Functions & Properties

var activeMenu = null;



function showMenu(){
	if(this == activeMenu){
		this.className = "";
		getNextSiblingByElement(this).style.display = "none";
		activeMenu = null;
	}else{
		if(activeMenu){
			getNextSiblingByElement(activeMenu).style.display = "none";
			activeMenu.className = "";
			}
		this.className = "active";
		getNextSiblingByElement(this).style.display = "block";
		activeMenu = this;
	}
	return false;
}


// any onLoad stuff here, if combining

function initMenu(){
	var menus, menuLeft, text, a, i, j, m;
	//detect with directory this file is in
	j=-1;
	
	pathis=location.pathname;

if (pathis.indexOf("/brd/") != -1) {
j=2;
}

else if (pathis.indexOf("/hro/employment_ops/") != -1) {
j=5;
}

else if (pathis.indexOf("/adm/requests/") != -1) {
j=5;
}

else if (pathis.indexOf("/adm/") != -1) {
j=3;
}

/* dst should be closed
else if (pathis.indexOf("/dst/") != -1) {
j=3;
}
*/ 
else if (pathis.indexOf("/CARE/") != -1) {
j=8;
}

else if (pathis.indexOf("/exc/") != -1) {
j=3;
}
else if (pathis.indexOf("/enf/") != -1) {
j=3;
}

else if (pathis.indexOf("/hro/") != -1) {
j=3;
}

else if (pathis.indexOf("/iss/") != -1) {
j=3;
}

else if (pathis.indexOf("/pio/") != -1) {
j=3;
}

else if (pathis.indexOf("/tec/openburn.htm") != -1) {
j=1;
}


/* pln encompasses grants, prevention and district/offices */
else if (pathis.indexOf("/pln/grants_and_incentives/") != -1) {
j=4;
}	

else if (pathis.indexOf("/pln/prevention/") != -1) {
j=7;
}

else if (pathis.indexOf("/pln/ruledev/") != -1) {
j=10;
}

else if (pathis.indexOf("/pln/") != -1) {
j=3;
}


else if (pathis.indexOf("/dst/regulations/") != -1) {
j=10;
}


else if (pathis.indexOf("/pmt/") != -1) {
j=3;
}

else if (pathis.indexOf("/tec/") != -1) {
j=3;
}
	
	menus = getChildrenByElement(document.getElementById("mmhide_menu"));
	for(i = 0; i < menus.length; i++){
		menuLeft = menus[i];
		text = getFirstChildByText(menuLeft);
		a = document.createElement("a");
		menuLeft.replaceChild(a, text);
		a.appendChild(text);
		a.href = "#";
		if (j != -1) {
		if (i == j){ getNextSiblingByElement(a).style.display = "block"; 
		activeMenu=a;
		}/////////// this reveals left subnav
		}
		a.onclick = showMenu; 
		a.onfocus = function(){this.blur()};
	}
	

	
} // initMenu()


if(document.createElement) window.onload = initMenu;

// |||||||||||||||||End all JS for Left Nav |||||||||
// ||||||||||||||||||||||||||||||||||||||||||||||||||

// -->

