var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

//this little diddy will fix dreamwever mousovers when we're done with the menu
function fixMouseover() {
	MM_swapImgRestore();
}


/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge, forceAlign){
var edgeoffset=0
if (whichedge=="rightedge"){
	var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	if (forceAlign=="left") 
		edgeoffset=0;
	if (forceAlign=="right") 
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	if (forceAlign=="center") 
		edgeoffset=(dropmenuobj.contentmeasure-obj.offsetWidth)/2
		
} else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID, alignment){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge", alignment)+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge", '')+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)

//THIS IS INSERTED TO PUT BACK THE ORIGINAL IMAGE ON A MOUSEOVER -- IF USING THE DREAMWEAVER "onMouseover" function
fixMouseover();

}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}










/*******************************************
********************************************
********************************************

	SITE MAP FUNCTION
	
********************************************
********************************************
*******************************************/
/*
This function will allow us to create a site map from the div tags that were used on the "nav_menu" 
It will remove the <div> tags from each property, so they should just display as links
*/
function siteMapFromNavBar() {
	var browser=navigator.appName;
	var siteMap = "";
	var elem = document.getElementsByTagName('div');

	for (i=0; i<elem.length; i++) {
	
		//if this div has a class of "nav_menu", then take the contents of the tag, and add it to our new sitemap string in a new div tag
		if (browser == "Microsoft Internet Explorer") {
			var elemClass = elem[i].getAttribute("className");	
		} else {
			var elemClass = elem[i].getAttribute("class");
		}
		
		if (elemClass == "nav_menu") {
			var usefulLinks = elem[i].innerHTML;
			
			/*
			now, we want to get the link on the page that class this set of drop-down link on the nav_menu
			this is messy -- we're going to loop through the "navbar" <div> and find all the link links, and then we're going 
			each <a> tag to see if the onMouseOver tag has the element id of the links that we're looking at.
			if it does have that, then it's the code that call this function, and we will add this link as
			the primary link on our section
			*/
			var mainLink = "";
			var elemID = elem[i].getAttribute("id");
			var aLinks = document.getElementsByTagName('a');
			for (x=0; x<aLinks.length; x++) {
				var linkCode = String(aLinks[x].onmouseover);
				
	
				//test if the element id is in the link
				var findIt = linkCode.search(elemID);
				//if we have it, recreate a more friendly format to use as the title link for this section
				if (findIt >= 0) {
					if (aLinks[x].href) {
						var linkHref = aLinks[x].href
					} else {
						var linkHref = "";
					}
					
					if (aLinks[x].target) {
						var linkTarget = aLinks[x].target
					} else {
						var linkTarget = "";
					}
					
					if (aLinks[x].rel) {
						var linkRel = aLinks[x].rel
					} else {
						var linkRel = "";
					}
					
					if (aLinks[x].title) {
						var linkTitle = aLinks[x].title
					} else {
						var linkTitle = "";
					}
					
					var mainLink = "<h1><a href=\"" + linkHref + "\" title=\"" + linkTitle + "\" target=\"" + linkTarget + "\" rel=\"" + linkRel + "\">" + aLinks[x].innerHTML + "</a></h1>";
				}
				
			}
			
			//add the main link and useful links together
			siteMap += "<div>\n" + mainLink + "\n" + usefulLinks + "\n</div>\n\n";
			
			//unset the main link
			var mainLink = "";
		}		
	}
	
	//if the site map div tag is on the screen, the put the site map there
	if (document.getElementById('siteMapGoesHere')) {
		document.getElementById('siteMapGoesHere').innerHTML = siteMap;
		//alert (aLinks.length);
	} else {
		alert ('Missing siteMapGoesHere Div Tag to Place Site Map Into');
	}
}

