
function init(genus){
	if(genus==0){
		if(navigator.userAgent.indexOf('MSIE 6')!=-1){
			pointerOffsetAdd=11;
			menuOffsetAdd=-33;
		}
		else{
			pointerOffsetAdd=6;
			menuOffsetAdd=-37;
		}
	}
	else{
		pointerOffsetAdd=2;
		menuOffsetAdd=-2;
	}
}
function getOffset(targ){// value by ie/gecko specific syntax
	ie?offset=targ.offsetParent.offsetLeft:offset=targ.offsetLeft;
	return offset;
}
function getTextWidth(targ){// width values for right_nav li
	switch (targ){
		case 0:
			itemWidth=126;
		break;
		case 1:
			itemWidth=110;
		break;
		case 2:
			itemWidth=56;
		break;
		case 3:
			itemWidth=114;
		break;
		case 4:
			itemWidth=74;
		break;
	}
	return itemWidth;
}
function hideMenu(targ){
	document.getElementById(targ).style.display='none';
}
function hasMenu(targ){
	switch(targ){
	case 2:
	return true;
	case 3:
	return true;
	case 4:
	return true;
	case 5:
	return true;
	case 6:
	return true;
	default:
	return false;
	}
}
function activateNav(){
/*---right_nav ---*/
	var navRight=document.getElementById('nav_right');
	var navText=navRight.getElementsByTagName('li');
	
	for(i=0;i<navText.length;i++){// load right_nav images, set <li> widths, set mouseover states
		navText[i].style.backgroundImage='url(images/nav_text_'+i+'.gif)';
		getTextWidth(i);
		navText[i].style.width=itemWidth+'px';
		navText[i].onmouseover=function(){
			this.style.backgroundPosition='0px -32px';
		}
		navText[i].onmouseout=function(){
			this.style.backgroundPosition='0px 0px';
		}
	}
/* ----------------*/

/*---left_nav ---*/
	var url=window.location.href;
	var pointerVar=url.substr(url.lastIndexOf('=')+1,url.length);// parse get var from url for pointer locating
	var locationPointer=document.getElementById('location_pointer');
	var navLeft=document.getElementById('nav_left');
	var navLeftAnchors=navLeft.getElementsByTagName('a');
	var itemMenu=Array();
	
/*--- locationPointer positioning ---*/	
		if(isNaN(pointerVar))
			pointerVar=0;

	locationPointer.style.left=getOffset(navLeftAnchors[pointerVar])+pointerOffsetAdd+'px';
/* -----------------------------------------*/	
	

		ul=document.getElementsByTagName('ul');
		for(i=0;i<ul.length;i++){
			if(ul[i].className == 'nav_drop_down')
				itemMenu.push(ul[i]);	
		}

	
	
	for(i=0;i<navLeftAnchors.length;i++){
		if(hasMenu(i+1))
		navLeftAnchors[i].menuId=itemMenu[i].id;// assign drop down ids to variable attached to anchors
		
		itemMenu[i].onmouseover=function(){//mouse on menu - clear timeout
			clearTimeout(t);
			anchors=this.getElementsByTagName('a');
			for(ii=0;ii<anchors.length;ii++){
				anchors[ii].onmouseout=function(){//mouse off menu link - clear timeout
					clearTimeout(t);
				}
				anchors[ii].onmouseover=function(){//mouse off menu link - clear timeout
					clearTimeout(t);
				}
			}
		}
		itemMenu[i].onmouseout=function(){//mouse off menu  - set timeout
			t=setTimeout(function(){hideMenu(targ);},80);
		}
	}
	
	for(i=0;i<navLeftAnchors.length;i++){
			
		/* --- dropdown menus ---*/	
		navLeftAnchors[i].onmouseover=function(){		//alert(this.menuId);

			for(i=0;i<itemMenu.length;i++){// mouse on nav button - close all but targeted menus to prevent artifact
				temp='drop_down_'+(i+1);
				this.menuId==temp?document.getElementById(temp).style.display='block':document.getElementById(temp).style.display='none';
				
			}
			document.getElementById(this.menuId).style.left=getOffset(this)+menuOffsetAdd+'px';
				clearTimeout(t);// mouse on nav button - clear timeout (prevent menu close on roll back from menu to button)
		}
		navLeftAnchors[i].onmouseout=function(){// mouse off nav button - set timeout 
			targ=this.menuId;
			t=setTimeout(function(){hideMenu(targ);},80);
		}
		/* ----------------------------*/	
	
	}
	locationPointer.style.display='block';//fix ie page change stutter
	
}

function addEvent(elm, evType, fn, useCapture){  //cross-browser event handling
	ie=false;
	ie8=false;
	if(elm.addEventListener){//firefox, safari, chrome, opera
		init(1);
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if(elm.attachEvent){//ie
															//determine ie version number
		ieVer=navigator.userAgent.charAt(navigator.userAgent.indexOf('MSIE')+5);
		ieVerNum=parseInt(ieVer);
		if(ieVerNum<=7){
			ie=true;
			init(0);
		}
		else{
			ie8=true;
			init(1);
		}
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}else{
		elm['on' + evType] = fn;
	}
}
addEvent(window, 'load', activateNav, false);