// JavaScript Document - ATI Menu
// Pieces: Menu.html, menu.css, menu.js, Header.html <body onLoad="loadXML(); selMenuItem()">
// Rev. 1.1 LNixon 02/04/09 changed show and hide functions to showPopUp and hidePopUp - conflict with prototype.js

function selMenuItem() {
	// <li id="menu_inactive"><a id="index.php" href="index.php">Home</a></li>
	// get the dir name
	var dir = document.getElementById('dir').name;	// php writes <div id="dir" name="'.$_SESSION['dir'].'"></div>
	var pathname = location.pathname;	// read the current URL pathname such as /Alpha/index.php
	page = pathname.slice(pathname.lastIndexOf("/")+1, pathname.length);	// parse page name such as index.php
	var parent = document.getElementById(page).parentNode;	// use anchor id to get the li id 
	parent.id = "menu_active";	// set the id to menu_active to affect menu.css styles
}
/*
<div id="pop_up"></div> <!-- recepticle -->

<?xml version="1.0" encoding="iso-8859-1"?>
<index_page>
	<bbn_info>
	The Business Breakfast Network is an association of TOWLVCC members who are dedicated to helping to build one anothers businesses. [The information displayed here demostrates the interactivity that can be built into your site.  To learn more, press Contact Us and send us a message.]"
	</bbn_info>
	<towlvcc_info>
	Link here to the Thousand Oaks Westlake Village Chamber of Commerce.  [The information displayed here demostrates the interactivity that can be built into your site.  To learn more, press Contact Us and send us a message.]">
	</towlvcc_info>
</index_page>

<a href="http://www.bbnto.com" onmouseover="showPopUp('pop_up', 'bbn_info')" onmouseout="hide('pop_up')">

*/
var xmlDoc;
function loadXML(xml) {
	// use explicit argument value or parse and build name from current location
	// file is always considered to be in the current domain
	if(!xml) {
		dir = document.getElementById('dir').name;	// php writes <div id="dir" name="'.$_SESSION['dir'].'"></div>
		pathname = location.pathname;	// read the current URL pathname such as /Alpha/index.php
		page = pathname.slice(pathname.lastIndexOf("/")+1, pathname.length);	// parse page name such as index.php
		//confirm(page);
		if(!page) page = 'index.php';	// page is empty make it default
		xml = page.slice(0, page.lastIndexOf("."))+'.xml';	// parse page name root such as index of index.php
	}
	//confirm(xml);

	// code for IE
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("","",null);
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
	xmlDoc.async = false;	// make sure the xml will be loaded before caller gets control 
	//load xml file
	xmlDoc.load(xml);
	showPopUp('pop_up', page, 'content', 1);	// get initial content pop up info
}

var prior;
var dir;	// php writes <div id="dir" name="'.$_SESSION['dir'].'"></div>
var pathname = location.pathname;	// read the current URL pathname such as /Alpha/index.php
// parse page name such as index.php; however, if called without file name, default index.php is provided
var page = pathname.slice(pathname.lastIndexOf("/")+1, pathname.length);	

function showPopUp(receptacle, xml_tag, class_id, append) {
	// the receptacle says where to put it, xml_tag is the xml pointer, class_id is the css class
	// usually the receptacle is pop_up of <div id='pop_up'></div>
	//confirm(receptacle+' '+xml_tag+' '+class_id+' '+append);
	if(append == '1') prior = document.getElementById(class_id).innerHTML;
	else prior = '';
	var txt = prior + xmlDoc.getElementsByTagName(xml_tag)[0].childNodes[0].nodeValue;
	document.getElementById(receptacle).innerHTML = '<div class="'+class_id+'">'+txt+'</div>';
}
function hidePopUp(receptacle, xml_tag, class_id) {
	// see if the data is sticky
	prior = document.getElementById(class_id).innerHTML;
	//if(page != xml_tag)	document.getElementById(receptacle).innerHTML = '<div></div>';
	var txt = prior + xmlDoc.getElementsByTagName(page)[0].childNodes[0].nodeValue;
	document.getElementById(receptacle).innerHTML = '<div class="'+class_id+'">'+txt+'</div>';
}