var moz, ie;
var ver='all';
var currentSub;
var currentIsSub=false;
var subPages=new Array('licensees','nickel','stationary');

function $(id){
	return document.getElementById(id);
}
 function $$(container,tag){
	return container.getElementsByTagName(tag);
 }
function mouseoff(targ){// hide sub nav
	if(targ) { targ.style.visibility='hidden'; }
/* 	setOpac('up');
 */}
function setOpac(stat){
	stat=='dn'?opac=0.2:opac=1;
	if(moz)
		$('iframe').style.opacity=opac;
	if(ie){
		opac=opac*100;
		$('iframe').style.filter="alpha(opacity="+opac+")";
	}
}
function init(){
	
	if(document.getElementsByTagName('BODY')[0].className == 'solar') {
		ver = 'solar';
	}
	
	var nav=$('left_nav');
	var a=$$(nav,'a');
	var file=location.href;
	var name=file.substring(file.lastIndexOf("/")+1,file.lastIndexOf("."));
	
/**** if on a subnav page, keep subnav visible ****/
	for(i in subPages){
 		if(name==subPages[i]){
			for(i in a){
				if(a[i].href==file){
					a[i].parentNode.parentNode.style.visibility='visible';
					currentIsSub=true;
				}
			}
		}
	}
/***************************************************/
	
	for(i=0;i<a.length;i++){		
		if(a[i].href==file){// left nav active state
			a[i].className=='sub' ? a[i].parentNode.style.background='url(images/arrow_sub_'+ver+'.gif) 0 5px no-repeat' : a[i].parentNode.style.background='url(images/arrow_static.gif) 0 5px no-repeat';
			if (ver=='solar') {
				a[i].parentNode.style.background='url(images/arrow_solar.gif) 0 5px no-repeat';
			}
		}
		
		a[i].onmouseover=function(){
			if(this.href!=file)// left nav over state
				this.parentNode.style.background='url(images/arrow_'+ver+'.gif) 0 5px no-repeat';
				
/*			if(this.className=='main'){// show subnav
 				//setOpac('dn');
				currentSub=this.parentNode.childNodes[2];
				currentSub.style.visibility='visible';
 				clearTimeout(timeout);
 			}
 */			else if(this.className=='sub'){// sub nav over state
/* 				setOpac('dn');
 */				this.parentNode.style.background='url(images/arrow_sub_'+ver+'.gif) 0 5px no-repeat';
 				if (typeof(timeout) != 'undefined') {
					clearTimeout(timeout);
				}
 			}
			else{
			if(!currentIsSub)// if not on a subnav page, hide subnav
				if(currentSub) { currentSub.style.visibility='hidden'; }
/* 				setOpac('up');
 */			}
		}
		a[i].onmouseout=function(){
			if(this.href!=file)// left nav off state
				this.parentNode.style.background='none';
			if(!currentIsSub)// if not on a subnav page, hide subnav
				timeout=setTimeout(function(){mouseoff(currentSub)},400);
 		}
	}
}


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