    /* ////////////////////////////////
    pb2AE.com Nav
	By Brian Sage, semaphorellc.com
//////////////////////////////// */

function solveForE(e) {
	var targ;

	if (!e) var e = window.event;                  // for IE's event model
	if (e.target) targ = e.target;                 // for W3C/Moz Event model
	else if (e.srcElement) targ = e.srcElement;    // also for IE's event model
	if (targ.nodeType == 3)                        // defeat Safari bug (thanks, quirksmode.org)
	targ = targ.parentNode;                        // realize the target node, itself

	return targ;
}

pb2navHide = function (){
	$$('#nav ul ul').each(function(s) {
			//if(s.style.display = 'block') s.style.display = 'none';
		if( (s.up(2).id == 'nav') && (s.style.display != 'none')) Effect.BlindLeft( s, {duration : .5} );
		if( (s.up(4).id == 'nav') && (s.style.display != 'none')) s.style.display = 'none';
	});
}
pb2navHideTier = function ( tierN ) {
	$$('#nav ul ul ul').each(function(s) {
		if( s.style.display != 'none' ) Effect.BlindUp( s, {duration : .5} );
	});
}
pb2navDeactivateTier = function ( tierN ){
	switch( tierN ) {
	case 0:
		$$('#nav .active').each(function(s) {
			s.removeClassName('active');
		});
		break;
	case 1:
		$$('#nav ul ul .active').each(function(s) {
			s.removeClassName('active');
		});
		break;
	case 2:
		$$('#nav ul ul ul .active').each(function(s) {
			s.removeClassName('active');
		});
		break;
	}
}

pb2navNodeClick = function( e ) {
	targ = solveForE(e);
	targ.blur();
	if ( ( targ.className == 'navNode' ) || ( targ.className == 'navNode hover' ) ) {
		if ( targ.parentNode.className == 'active' ) return false;
	
		if ( targ.parentNode.parentNode.parentNode.parentNode.id == 'nav' ) {
			pb2navHide();
			pb2navDeactivateTier(0);
			targ.up('a',0).addClassName('active');
			Effect.BlindRight( targ.up('a',0).next('ul'), {duration : .5} );
		} else if ( targ.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id == 'nav' ) {
			pb2navHideTier(1);
			pb2navDeactivateTier(1);
			targ.up('a',0).addClassName('active');
			Effect.BlindDown( targ.up('a',0).next('ul') );
		}
		return false;
	}
	return true;
}

pb2navActiveOpen = function (){
	$$('#nav a.active').each( function(s){
		if( s.next(0) != undefined ) { if( s.next(0).tagName == 'UL' ) s.next(0).style.display = 'block'; }
		if( s.up('ul') != undefined ) {
			for( var i=0; i < s.ancestors().length; i++ ) {

				if( s.ancestors()[i].tagName == 'BODY' ) return;

				if( s.ancestors()[i].tagName == 'UL' ) s.ancestors()[i].style.display = 'block';
				if( s.ancestors()[i].tagName == 'LI' ) s.ancestors()[i].down('a').addClassName('active');
			}
		}
	});
}

pb2navInit = function (){
	$$('#nav ul ul').each(function(s) {
			if(s.style.display != 'none') s.style.display = 'none';
	});
	var navAs = $('nav').getElementsByTagName('A');
	for (var i=0; i<navAs.length; i++) {
		if( navAs[i].parentNode.childNodes.length >= 2 ) {
			var nn = document.createElement('IMG');
			nn.src = GR+'dot_clear.gif';
			nn.width = '20';
			nn.height = '10';

			/*
			var nn = document.createElement('SPAN');
			nnText = document.createTextNode(' ');
	    nn.appendChild(nnText);
			*/
			nn.title = 'click to expand';
			nn.className = 'navNode';
	    nn.onmouseover = function(){ this.className = 'navNode hover' };
	    nn.onmouseout = function(){ this.className = 'navNode' };
	    nn.onclick = function(e){ return pb2navNodeClick(e) };
	    navAs[i].appendChild(nn);
		}
	}
	pb2navActiveOpen();
}
